Raise WARNS to 6:
authorChris Pressey <cpressey@dragonflybsd.org>
Sat, 5 Feb 2005 01:05:12 +0000 (01:05 +0000)
committerChris Pressey <cpressey@dragonflybsd.org>
Sat, 5 Feb 2005 01:05:12 +0000 (01:05 +0000)
- Move the print() function above the display() function so that it can
  be inlined by the compiler.
- Un-nest extern declarations; put them into the shared header file.
- Initialize some local variables.

usr.bin/hexdump/Makefile
usr.bin/hexdump/display.c
usr.bin/hexdump/hexdump.h
usr.bin/hexdump/parse.c

index 3ea9652..4481f44 100644 (file)
@@ -1,8 +1,9 @@
 #      @(#)Makefile    8.1 (Berkeley) 6/6/93
 # $FreeBSD: src/usr.bin/hexdump/Makefile,v 1.3.8.1 2001/04/25 11:29:22 ru Exp $
-# $DragonFly: src/usr.bin/hexdump/Makefile,v 1.2 2003/06/17 04:29:27 dillon Exp $
+# $DragonFly: src/usr.bin/hexdump/Makefile,v 1.3 2005/02/05 01:05:12 cpressey Exp $
 
 PROG=  hexdump
+WARNS?=        6
 SRCS=  conv.c display.c hexdump.c hexsyntax.c odsyntax.c parse.c
 MAN=   hexdump.1 od.1
 MLINKS=        hexdump.1 hd.1
index 8963b07..82051c5 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)display.c       8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.bin/hexdump/display.c,v 1.4.2.2 2002/07/23 14:27:06 tjr Exp $
- * $DragonFly: src/usr.bin/hexdump/display.c,v 1.4 2004/08/30 18:06:49 eirikn Exp $
+ * $DragonFly: src/usr.bin/hexdump/display.c,v 1.5 2005/02/05 01:05:12 cpressey Exp $
  */
 
 #include <sys/param.h>
@@ -53,61 +53,6 @@ static off_t eaddress;                       /* end address */
 
 static __inline void print(PR *, u_char *);
 
-void
-display(void)
-{
-       extern FU *endfu;
-       register FS *fs;
-       register FU *fu;
-       register PR *pr;
-       register int cnt;
-       register u_char *bp;
-       off_t saveaddress;
-       u_char savech, *savebp;
-
-       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) {
-                       if (fu->flags&F_IGNORE)
-                               break;
-                       for (cnt = fu->reps; cnt; --cnt)
-                           for (pr = fu->nextpr; pr; address += pr->bcnt,
-                               bp += pr->bcnt, pr = pr->nextpr) {
-                                   if (eaddress && address >= eaddress &&
-                                       !(pr->flags & (F_TEXT|F_BPAD)))
-                                           bpad(pr);
-                                   if (cnt == 1 && pr->nospace) {
-                                       savech = *pr->nospace;
-                                       *pr->nospace = '\0';
-                                   }
-                                   print(pr, bp);
-                                   if (cnt == 1 && pr->nospace)
-                                       *pr->nospace = savech;
-                           }
-                   }
-       if (endfu) {
-               /*
-                * If eaddress not set, error or file size was multiple of
-                * blocksize, and no partial block ever found.
-                */
-               if (!eaddress) {
-                       if (!address)
-                               return;
-                       eaddress = address;
-               }
-               for (pr = endfu->nextpr; pr; pr = pr->nextpr)
-                       switch(pr->flags) {
-                       case F_ADDRESS:
-                               (void)printf(pr->fmt, (quad_t)eaddress);
-                               break;
-                       case F_TEXT:
-                               (void)printf("%s", pr->fmt);
-                               break;
-                       }
-       }
-}
-
 static __inline void
 print(PR *pr, u_char *bp)
 {
@@ -205,6 +150,61 @@ print(PR *pr, u_char *bp)
        }
 }
 
+void
+display(void)
+{
+       
+       FS *fs;
+       register FU *fu;
+       register PR *pr;
+       register int cnt;
+       register u_char *bp;
+       off_t saveaddress;
+       u_char savech = '\0', *savebp;
+
+       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) {
+                       if (fu->flags&F_IGNORE)
+                               break;
+                       for (cnt = fu->reps; cnt; --cnt)
+                           for (pr = fu->nextpr; pr; address += pr->bcnt,
+                               bp += pr->bcnt, pr = pr->nextpr) {
+                                   if (eaddress && address >= eaddress &&
+                                       !(pr->flags & (F_TEXT|F_BPAD)))
+                                           bpad(pr);
+                                   if (cnt == 1 && pr->nospace) {
+                                       savech = *pr->nospace;
+                                       *pr->nospace = '\0';
+                                   }
+                                   print(pr, bp);
+                                   if (cnt == 1 && pr->nospace)
+                                       *pr->nospace = savech;
+                           }
+                   }
+       if (endfu) {
+               /*
+                * If eaddress not set, error or file size was multiple of
+                * blocksize, and no partial block ever found.
+                */
+               if (!eaddress) {
+                       if (!address)
+                               return;
+                       eaddress = address;
+               }
+               for (pr = endfu->nextpr; pr; pr = pr->nextpr)
+                       switch(pr->flags) {
+                       case F_ADDRESS:
+                               (void)printf(pr->fmt, (quad_t)eaddress);
+                               break;
+                       case F_TEXT:
+                               (void)printf("%s", pr->fmt);
+                               break;
+                       }
+       }
+}
+
 void
 bpad(PR *pr)
 {
@@ -303,7 +303,6 @@ get(void)
 int
 next(char **argv)
 {
-       extern int exitval;
        static int done;
        int statok;
 
index 3ef73c7..9e6ea6f 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     @(#)hexdump.h   8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.bin/hexdump/hexdump.h,v 1.2.6.1 2002/07/23 14:27:06 tjr Exp $
- * $DragonFly: src/usr.bin/hexdump/hexdump.h,v 1.2 2003/06/17 04:29:27 dillon Exp $
+ * $DragonFly: src/usr.bin/hexdump/hexdump.h,v 1.3 2005/02/05 01:05:12 cpressey Exp $
  */
 
 typedef struct _pr {
@@ -79,6 +79,8 @@ extern int length;                    /* amount of data to read */
 extern off_t skip;                     /* amount of data to skip at start */
 enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */
 extern enum _vflag vflag;
+extern FU *endfu;
+extern int exitval;
 
 void    add(const char *);
 void    addfile(char *);
index b15fde6..6c4bb94 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)parse.c 8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.bin/hexdump/parse.c,v 1.4.2.1 2002/07/23 14:27:06 tjr Exp $
- * $DragonFly: src/usr.bin/hexdump/parse.c,v 1.4 2004/08/30 18:06:49 eirikn Exp $
+ * $DragonFly: src/usr.bin/hexdump/parse.c,v 1.5 2005/02/05 01:05:12 cpressey Exp $
  */
 
 #include <sys/types.h>
@@ -204,11 +204,11 @@ void
 rewrite(FS *fs)
 {
        enum { NOTOKAY, USEBCNT, USEPREC } sokay;
-       register PR *pr, **nextpr;
+       register PR *pr, **nextpr = NULL;
        register FU *fu;
        unsigned char *p1, *p2, *fmtp;
        char savech, cs[3];
-       int nconv, prec;
+       int nconv, prec = 0;
 
        for (fu = fs->nextfu; fu; fu = fu->nextfu) {
                /*