From c38cc7439c21c0932dbbdfcb87274dde7b8663ca Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Sun, 2 Dec 2001 12:09:41 +0000 Subject: [PATCH] WARNS=2 fixups. --- usr.bin/hexdump/Makefile | 1 + usr.bin/hexdump/conv.c | 30 ++++++++++++++++++++---------- usr.bin/hexdump/display.c | 11 +++++------ usr.bin/hexdump/hexdump.h | 6 +++--- usr.bin/hexdump/parse.c | 8 ++++---- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/usr.bin/hexdump/Makefile b/usr.bin/hexdump/Makefile index 4cd3cc5dc62f..70e216ecae27 100644 --- a/usr.bin/hexdump/Makefile +++ b/usr.bin/hexdump/Makefile @@ -3,6 +3,7 @@ PROG= hexdump SRCS= conv.c display.c hexdump.c hexsyntax.c odsyntax.c parse.c +WARNS?= 2 MAN= hexdump.1 od.1 MLINKS= hexdump.1 hd.1 LINKS= ${BINDIR}/hexdump ${BINDIR}/od diff --git a/usr.bin/hexdump/conv.c b/usr.bin/hexdump/conv.c index daae174cbd80..5b3941a1362e 100644 --- a/usr.bin/hexdump/conv.c +++ b/usr.bin/hexdump/conv.c @@ -29,10 +29,12 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef lint -static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93"; +static const char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93"; #endif /* not lint */ #include @@ -48,36 +50,44 @@ conv_c(pr, p) { extern int deprecated; char buf[10], *str; + static char nul[] = "\\0"; + static char alarm[] = "\\a"; + static char backspace[] = "\\b"; + static char formfeed[] = "\\f"; + static char newline[] = "\\n"; + static char carriageret[] = "\\r"; + static char verticaltab[] = "\\v"; + static char tab[] = "\\t"; switch(*p) { case '\0': - str = "\\0"; + str = nul; goto strpr; /* case '\a': */ case '\007': if (deprecated) /* od didn't know about \a */ break; - str = "\\a"; + str = alarm; goto strpr; case '\b': - str = "\\b"; + str = backspace; goto strpr; case '\f': - str = "\\f"; + str = formfeed; goto strpr; case '\n': - str = "\\n"; + str = newline; goto strpr; case '\r': - str = "\\r"; + str = carriageret; goto strpr; case '\t': - str = "\\t"; + str = tab; goto strpr; case '\v': if (deprecated) break; - str = "\\v"; + str = verticaltab; goto strpr; default: break; @@ -98,7 +108,7 @@ conv_u(pr, p) u_char *p; { extern int deprecated; - static char *list[] = { + static const char *list[] = { "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "lf", "vt", "ff", "cr", "so", "si", "dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb", diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index a09a5715e4f6..4af83ecb5080 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -69,7 +69,7 @@ display() off_t saveaddress; u_char savech, *savebp; - while (bp = get()) + while ((bp = get())) for (fs = fshead, savebp = bp, saveaddress = address; fs; fs = fs->nextfs, bp = savebp, address = saveaddress) for (fu = fs->nextfu; fu; fu = fu->nextfu) { @@ -208,7 +208,7 @@ void bpad(pr) PR *pr; { - static char *spec = " -0+#"; + static char spec[] = " -0+#"; register char *p1, *p2; /* @@ -220,7 +220,7 @@ bpad(pr) pr->cchar[1] = '\0'; for (p1 = pr->fmt; *p1 != '%'; ++p1); for (p2 = ++p1; *p1 && index(spec, *p1); ++p1); - while (*p2++ = *p1++); + while ((*p2++ = *p1++)); } static char **_argv; @@ -228,7 +228,6 @@ static char **_argv; u_char * get() { - extern enum _vflag vflag; extern int length; static int ateof = 1; static u_char *curp, *savp; @@ -255,7 +254,7 @@ get() * and no other files are available, zero-pad the rest of the * block and set the end flag. */ - if (!length || ateof && !next((char **)NULL)) { + if (!length || (ateof && !next((char **)NULL))) { if (need == blocksize) return((u_char *)NULL); if (vflag != ALL && @@ -340,7 +339,7 @@ next(argv) void doskip(fname, statok) - char *fname; + const char *fname; int statok; { register int cnt; diff --git a/usr.bin/hexdump/hexdump.h b/usr.bin/hexdump/hexdump.h index 1856618bab18..86073c38abe6 100644 --- a/usr.bin/hexdump/hexdump.h +++ b/usr.bin/hexdump/hexdump.h @@ -75,17 +75,17 @@ extern FS *fshead; /* head of format strings list */ extern int blocksize; /* data block size */ enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */ -void add __P((char *)); +void add __P((const char *)); void addfile __P((char *)); void badcnt __P((char *)); void badconv __P((char *)); -void badfmt __P((char *)); +void badfmt __P((const char *)); void badsfmt __P((void)); void bpad __P((PR *)); void conv_c __P((PR *, u_char *)); void conv_u __P((PR *, u_char *)); void display __P((void)); -void doskip __P((char *, int)); +void doskip __P((const char *, int)); void escape __P((char *)); u_char *get __P((void)); void newsyntax __P((int, char ***)); diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c index c05d5687f5dd..d11071b8c3a3 100644 --- a/usr.bin/hexdump/parse.c +++ b/usr.bin/hexdump/parse.c @@ -79,9 +79,9 @@ addfile(name) void add(fmt) - char *fmt; + const char *fmt; { - unsigned char *p, *savep; + unsigned const char *p, *savep; static FS **nextfs; FS *tfs; FU *tfu, **nextfu; @@ -151,7 +151,7 @@ add(fmt) } } -static char *spec = ".#-+ 0123456789"; +static char spec[] = ".#-+ 0123456789"; int size(fs) @@ -501,7 +501,7 @@ badsfmt() void badfmt(fmt) - char *fmt; + const char *fmt; { errx(1, "\"%s\": bad format", fmt); }