From 8605a1aa6873567d7c3fdddcc62ca1559db5e135 Mon Sep 17 00:00:00 2001 From: lukem Date: Sun, 25 Nov 2001 06:53:48 +0000 Subject: [PATCH] - ANSI KNF - WARNS=2 (mainly converting some "char *" -> "const char *") --- 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(-) diff --git a/bin/dd/Makefile b/bin/dd/Makefile index b23453d92d53..914407e376a8 100644 --- a/bin/dd/Makefile +++ b/bin/dd/Makefile @@ -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 diff --git a/bin/dd/args.c b/bin/dd/args.c index 39e5d6279a23..9c9a4c32aeda 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -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 @@ __RCSID("$NetBSD: args.c,v 1.16 2001/07/22 13:33:58 wiz Exp $"); #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 @@ static char *oper; * args -- parse JCL syntax of dd. */ void -jcl(argv) - char **argv; +jcl(char **argv) { struct arg *ap, tmp; char *arg; @@ -122,7 +121,8 @@ jcl(argv) 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 @@ jcl(argv) 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 @@ jcl(argv) } 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 @@ f_progress(arg) #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 const struct conv { }; static void -f_conv(arg) - char *arg; +f_conv(char *arg) { struct conv *cp, tmp; @@ -332,8 +332,7 @@ f_conv(arg) } 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 @@ c_conv(a, b) * 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 --git a/bin/dd/conv.c b/bin/dd/conv.c index b350e5cfcdab..cdeac04650fb 100644 --- a/bin/dd/conv.c +++ b/bin/dd/conv.c @@ -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 @@ __RCSID("$NetBSD: conv.c,v 1.11 2001/04/28 22:47:23 ross Exp $"); * Worst case buffer calculation is (ibs + obs - 1). */ void -def() +def(void) { int cnt; u_char *inp; @@ -91,8 +91,9 @@ def() } void -def_close() +def_close(void) { + /* Just update the count, everything is already in the buffer. */ if (in.dbcnt) out.dbcnt = in.dbcnt; @@ -101,11 +102,11 @@ def_close() #ifdef NO_CONV /* Build a smaller version (i.e. for a miniroot) */ /* These can not be called, but just in case... */ -static char no_block[] = "unblock and -DNO_CONV?"; -void block() { errx(1, "%s", no_block + 2); } -void block_close() { errx(1, "%s", no_block + 2); } -void unblock() { errx(1, "%s", no_block); } -void unblock_close() { errx(1, "%s", no_block); } +static const char no_block[] = "unblock and -DNO_CONV?"; +void block(void) { errx(1, "%s", no_block + 2); } +void block_close(void) { errx(1, "%s", no_block + 2); } +void unblock(void) { errx(1, "%s", no_block); } +void unblock_close(void) { errx(1, "%s", no_block); } #else /* NO_CONV */ /* @@ -116,7 +117,7 @@ void unblock_close() { errx(1, "%s", no_block); } * max out buffer: obs + cbsz */ void -block() +block(void) { static int intrunc; int ch = 0; /* pacify gcc */ @@ -201,8 +202,9 @@ block() } void -block_close() +block_close(void) { + /* * Copy any remaining data into the output buffer and pad to a record. * Don't worry about truncation or translation, the input buffer is @@ -228,7 +230,7 @@ block_close() * max out buffer: obs + cbsz */ void -unblock() +unblock(void) { int cnt; u_char *inp; @@ -262,7 +264,7 @@ unblock() } void -unblock_close() +unblock_close(void) { int cnt; u_char *t; diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 5094d4c7710d..49a69e01c4e6 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -1,4 +1,4 @@ -/* $NetBSD: dd.c,v 1.20 2001/04/28 22:47:23 ross Exp $ */ +/* $NetBSD: dd.c,v 1.21 2001/11/25 06:53:48 lukem Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: dd.c,v 1.20 2001/04/28 22:47:23 ross Exp $"); +__RCSID("$NetBSD: dd.c,v 1.21 2001/11/25 06:53:48 lukem Exp $"); #endif #endif /* not lint */ @@ -70,16 +70,16 @@ __RCSID("$NetBSD: dd.c,v 1.20 2001/04/28 22:47:23 ross Exp $"); #include "dd.h" #include "extern.h" -static void dd_close __P((void)); -static void dd_in __P((void)); -static void getfdtype __P((IO *)); -static void setup __P((void)); +static void dd_close(void); +static void dd_in(void); +static void getfdtype(IO *); +static void setup(void); -int main __P((int, char *[])); +int main(int, char *[]); IO in, out; /* input/output state */ STAT st; /* statistics */ -void (*cfunc) __P((void)); /* conversion function */ +void (*cfunc)(void); /* conversion function */ u_long cpy_cnt; /* # of blocks to copy */ u_int ddflags; /* conversion options */ u_int cbsz; /* conversion block size */ @@ -89,9 +89,7 @@ const u_char *ctab; /* conversion table */ sigset_t infoset; /* a set blocking SIGINFO */ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int ch; @@ -124,7 +122,7 @@ main(argc, argv) } static void -setup() +setup(void) { u_int cnt; @@ -229,8 +227,7 @@ setup() } static void -getfdtype(io) - IO *io; +getfdtype(IO *io) { struct mtget mt; struct stat sb; @@ -244,7 +241,7 @@ getfdtype(io) } static void -dd_in() +dd_in(void) { int flags, n; @@ -346,8 +343,9 @@ dd_in() * is truncated. */ static void -dd_close() +dd_close(void) { + if (cfunc == def) def_close(); else if (cfunc == block) @@ -363,8 +361,7 @@ dd_close() } void -dd_out(force) - int force; +dd_out(int force) { static int warned; int cnt, n, nw; @@ -434,10 +431,7 @@ dd_out(force) * A protected against SIGINFO write */ ssize_t -bwrite(fd, buf, len) - int fd; - const void *buf; - size_t len; +bwrite(int fd, const void *buf, size_t len) { sigset_t oset; ssize_t rv; diff --git a/bin/dd/dd.h b/bin/dd/dd.h index b5b4aa6e4b36..e4a3f5fd6602 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -1,4 +1,4 @@ -/* $NetBSD: dd.h,v 1.6 2001/04/28 22:47:23 ross Exp $ */ +/* $NetBSD: dd.h,v 1.7 2001/11/25 06:53:48 lukem Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -53,7 +53,7 @@ typedef struct { #define NOREAD 0x08 /* not readable */ u_int flags; - char *name; /* name */ + const char *name; /* name */ int fd; /* file descriptor */ u_long offset; /* # of blocks to skip */ diff --git a/bin/dd/extern.h b/bin/dd/extern.h index 0abfed286ff9..0dc0ce6a259e 100644 --- a/bin/dd/extern.h +++ b/bin/dd/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.10 2000/08/02 16:46:16 christos Exp $ */ +/* $NetBSD: extern.h,v 1.11 2001/11/25 06:53:48 lukem Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -41,24 +41,24 @@ #include -void block __P((void)); -void block_close __P((void)); -void dd_out __P((int)); -void def __P((void)); -void def_close __P((void)); -void jcl __P((char **)); -void pos_in __P((void)); -void pos_out __P((void)); -void summary __P((void)); -void summaryx __P((int)); -void terminate __P((int)); -void unblock __P((void)); -void unblock_close __P((void)); -ssize_t bwrite __P((int, const void *, size_t)); +void block(void); +void block_close(void); +void dd_out(int); +void def(void); +void def_close(void); +void jcl(char **); +void pos_in(void); +void pos_out(void); +void summary(void); +void summaryx(int); +void terminate(int); +void unblock(void); +void unblock_close(void); +ssize_t bwrite(int, const void *, size_t); extern IO in, out; extern STAT st; -extern void (*cfunc) __P((void)); +extern void (*cfunc)(void); extern u_long cpy_cnt; extern u_int cbsz; extern u_int ddflags; diff --git a/bin/dd/misc.c b/bin/dd/misc.c index 566c7a4d3d84..6b6ffcc1d471 100644 --- a/bin/dd/misc.c +++ b/bin/dd/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.11 2001/04/28 22:47:23 ross Exp $ */ +/* $NetBSD: misc.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[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: misc.c,v 1.11 2001/04/28 22:47:23 ross Exp $"); +__RCSID("$NetBSD: misc.c,v 1.12 2001/11/25 06:53:48 lukem Exp $"); #endif #endif /* not lint */ @@ -62,7 +62,7 @@ __RCSID("$NetBSD: misc.c,v 1.11 2001/04/28 22:47:23 ross Exp $"); #define tv2mS(tv) ((tv).tv_sec * 1000LL + ((tv).tv_usec + 500) / 1000) void -summary() +summary(void) { char buf[100]; int64_t mS; @@ -101,8 +101,7 @@ summary() /* ARGSUSED */ void -summaryx(notused) - int notused; +summaryx(int notused) { summary(); @@ -110,8 +109,7 @@ summaryx(notused) /* ARGSUSED */ void -terminate(notused) - int notused; +terminate(int notused) { exit(0); diff --git a/bin/dd/position.c b/bin/dd/position.c index a94dc6f438b1..3f5cde102b56 100644 --- a/bin/dd/position.c +++ b/bin/dd/position.c @@ -1,4 +1,4 @@ -/* $NetBSD: position.c,v 1.10 2001/04/28 22:47:23 ross Exp $ */ +/* $NetBSD: position.c,v 1.11 2001/11/25 06:53:48 lukem Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: position.c,v 1.10 2001/04/28 22:47:23 ross Exp $"); +__RCSID("$NetBSD: position.c,v 1.11 2001/11/25 06:53:48 lukem Exp $"); #endif #endif /* not lint */ @@ -67,7 +67,7 @@ __RCSID("$NetBSD: position.c,v 1.10 2001/04/28 22:47:23 ross Exp $"); * output. */ void -pos_in() +pos_in(void) { int bcnt, cnt, nr, warned; @@ -122,7 +122,7 @@ pos_in() } void -pos_out() +pos_out(void) { struct mtop t_op; int cnt, n;