Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/dd - ANSI KNF



details:   https://anonhg.NetBSD.org/src/rev/9e4337bb1e89
branches:  trunk
changeset: 518128:9e4337bb1e89
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Nov 25 06:53:48 2001 +0000

description:
- ANSI KNF
- WARNS=2 (mainly converting some "char *" -> "const char *")

diffstat:

 bin/dd/Makefile   |    4 +-
 bin/dd/args.c     |  112 ++++++++++++++++++++++++++---------------------------
 bin/dd/conv.c     |   28 +++++++------
 bin/dd/dd.c       |   38 +++++++----------
 bin/dd/dd.h       |    4 +-
 bin/dd/extern.h   |   32 +++++++-------
 bin/dd/misc.c     |   12 ++---
 bin/dd/position.c |    8 +-
 8 files changed, 116 insertions(+), 122 deletions(-)

diffs (truncated from 634 to 300 lines):

diff -r 7e1fd8a82ce7 -r 9e4337bb1e89 bin/dd/Makefile
--- a/bin/dd/Makefile   Sun Nov 25 06:42:47 2001 +0000
+++ b/bin/dd/Makefile   Sun Nov 25 06:53:48 2001 +0000
@@ -1,7 +1,9 @@
-#      $NetBSD: Makefile,v 1.6 1997/07/20 22:36:45 christos Exp $
+#      $NetBSD: Makefile,v 1.7 2001/11/25 06:53:48 lukem Exp $
 #      @(#)Makefile    8.1 (Berkeley) 5/31/93
 
 PROG=  dd
 SRCS=  args.c conv.c conv_tab.c dd.c misc.c position.c
 
+WARNS=2
+
 .include <bsd.prog.mk>
diff -r 7e1fd8a82ce7 -r 9e4337bb1e89 bin/dd/args.c
--- a/bin/dd/args.c     Sun Nov 25 06:42:47 2001 +0000
+++ b/bin/dd/args.c     Sun Nov 25 06:53:48 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.16 2001/07/22 13:33:58 wiz Exp $    */
+/*     $NetBSD: args.c,v 1.17 2001/11/25 06:53:48 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c     8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.16 2001/07/22 13:33:58 wiz Exp $");
+__RCSID("$NetBSD: args.c,v 1.17 2001/11/25 06:53:48 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,25 +59,25 @@
 #include "dd.h"
 #include "extern.h"
 
-static int     c_arg __P((const void *, const void *));
-static int     c_conv __P((const void *, const void *));
-static void    f_bs __P((char *));
-static void    f_cbs __P((char *));
-static void    f_conv __P((char *));
-static void    f_count __P((char *));
-static void    f_files __P((char *));
-static void    f_ibs __P((char *));
-static void    f_if __P((char *));
-static void    f_obs __P((char *));
-static void    f_of __P((char *));
-static void    f_seek __P((char *));
-static void    f_skip __P((char *));
-static void    f_progress __P((char *));
-static u_long  get_bsz __P((char *));
+static int     c_arg(const void *, const void *);
+static int     c_conv(const void *, const void *);
+static void    f_bs(char *);
+static void    f_cbs(char *);
+static void    f_conv(char *);
+static void    f_count(char *);
+static void    f_files(char *);
+static void    f_ibs(char *);
+static void    f_if(char *);
+static void    f_obs(char *);
+static void    f_of(char *);
+static void    f_seek(char *);
+static void    f_skip(char *);
+static void    f_progress(char *);
+static u_long  get_bsz(const char *);
 
 static const struct arg {
-       char *name;
-       void (*f) __P((char *));
+       const char *name;
+       void (*f)(char *);
        u_int set, noset;
 } args[] = {
      /* the array needs to be sorted by the first column so
@@ -102,8 +102,7 @@
  * args -- parse JCL syntax of dd.
  */
 void
-jcl(argv)
-       char **argv;
+jcl(char **argv)
 {
        struct arg *ap, tmp;
        char *arg;
@@ -122,7 +121,8 @@
                    c_arg)))
                        errx(1, "unknown operand %s", tmp.name);
                if (ddflags & ap->noset)
-                       errx(1, "%s: illegal argument combination or already set",
+                       errx(1,
+                           "%s: illegal argument combination or already set",
                            tmp.name);
                ddflags |= ap->set;
                ap->f(arg);
@@ -164,7 +164,8 @@
                                cfunc = block;
                        }
                } else
-                       errx(1, "cbs meaningless if not doing record operations");
+                       errx(1,
+                           "cbs meaningless if not doing record operations");
                if (cbsz == 0)
                        errx(1, "cbs cannot be zero");
        } else
@@ -190,91 +191,91 @@
 }
 
 static int
-c_arg(a, b)
-       const void *a, *b;
+c_arg(const void *a, const void *b)
 {
+
        return (strcmp(((const struct arg *)a)->name,
            ((const struct arg *)b)->name));
 }
 
 static void
-f_bs(arg)
-       char *arg;
+f_bs(char *arg)
 {
+
        in.dbsz = out.dbsz = (int)get_bsz(arg);
 }
 
 static void
-f_cbs(arg)
-       char *arg;
+f_cbs(char *arg)
 {
+
        cbsz = (int)get_bsz(arg);
 }
 
 static void
-f_count(arg)
-       char *arg;
+f_count(char *arg)
 {
+
        cpy_cnt = (u_int)get_bsz(arg);
        if (!cpy_cnt)
                terminate(0);
 }
 
 static void
-f_files(arg)
-       char *arg;
+f_files(char *arg)
 {
+
        files_cnt = (int)get_bsz(arg);
 }
 
 static void
-f_ibs(arg)
-       char *arg;
+f_ibs(char *arg)
 {
+
        if (!(ddflags & C_BS))
                in.dbsz = (int)get_bsz(arg);
 }
 
 static void
-f_if(arg)
-       char *arg;
+f_if(char *arg)
 {
+
        in.name = arg;
 }
 
 static void
-f_obs(arg)
-       char *arg;
+f_obs(char *arg)
 {
+
        if (!(ddflags & C_BS))
                out.dbsz = (int)get_bsz(arg);
 }
 
 static void
-f_of(arg)
-       char *arg;
+f_of(char *arg)
 {
+
        out.name = arg;
 }
 
 static void
-f_seek(arg)
-       char *arg;
+f_seek(char *arg)
 {
+
        out.offset = (u_int)get_bsz(arg);
 }
 
 static void
-f_skip(arg)
-       char *arg;
+f_skip(char *arg)
 {
+
        in.offset = (u_int)get_bsz(arg);
 }
 
 static void
-f_progress(arg)
-       char *arg;
+f_progress(char *arg)
 {
+
        if (*arg != '0')
                progress = 1;
 }
@@ -282,15 +283,15 @@
 #ifdef NO_CONV
 /* Build a small version (i.e. for a ramdisk root) */
 static void
-f_conv(arg)
-       char *arg;
+f_conv(char *arg)
 {
+
        errx(1, "conv option disabled");
 }
 #else  /* NO_CONV */
 
 static const struct conv {
-       char *name;
+       const char *name;
        u_int set, noset;
        const u_char *ctab;
 } clist[] = {
@@ -312,8 +313,7 @@
 };
 
 static void
-f_conv(arg)
-       char *arg;
+f_conv(char *arg)
 {
        struct conv *cp, tmp;
 
@@ -332,8 +332,7 @@
 }
 
 static int
-c_conv(a, b)
-       const void *a, *b;
+c_conv(const void *a, const void *b)
 {
 
        return (strcmp(((const struct conv *)a)->name,
@@ -347,15 +346,14 @@
  *     1) A positive decimal number.
  *     2) A positive decimal number followed by a b (mult by 512).
  *     3) A positive decimal number followed by a k (mult by 1024).
- *     4) A positive decimal number followed by a m (mult by 512).
+ *     4) A positive decimal number followed by a m (mult by 1048576).
  *     5) A positive decimal number followed by a w (mult by sizeof int)
  *     6) Two or more positive decimal numbers (with/without k,b or w).
  *        separated by x (also * for backwards compatibility), specifying
  *        the product of the indicated values.
  */
 static u_long
-get_bsz(val)
-       char *val;
+get_bsz(const char *val)
 {
        u_long num, t;
        char *expr;
diff -r 7e1fd8a82ce7 -r 9e4337bb1e89 bin/dd/conv.c
--- a/bin/dd/conv.c     Sun Nov 25 06:42:47 2001 +0000
+++ b/bin/dd/conv.c     Sun Nov 25 06:53:48 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conv.c,v 1.11 2001/04/28 22:47:23 ross Exp $   */
+/*     $NetBSD: conv.c,v 1.12 2001/11/25 06:53:48 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)conv.c     8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: conv.c,v 1.11 2001/04/28 22:47:23 ross Exp $");
+__RCSID("$NetBSD: conv.c,v 1.12 2001/11/25 06:53:48 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -62,7 +62,7 @@
  * Worst case buffer calculation is (ibs + obs - 1).
  */
 void



Home | Main Index | Thread Index | Old Index