]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: formatting and variable name cleanup
authorOndrej Oprala <ooprala@redhat.com>
Mon, 23 Sep 2013 13:39:18 +0000 (15:39 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Nov 2013 11:54:52 +0000 (12:54 +0100)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
text-utils/conv.c
text-utils/display.c
text-utils/hexdump.c
text-utils/hexsyntax.c
text-utils/parse.c

index 95b8cd296b25fff7ce65da3e07a2a6c6cca6c31e..4f7a248f297dba4c2c8f449093cd72eae30d8780 100644 (file)
@@ -73,12 +73,12 @@ conv_c(PR *pr, u_char *p)
        }
        if (isprint(*p)) {
                *pr->cchar = 'c';
-               (void)printf(pr->fmt, *p);
+               printf(pr->fmt, *p);
        } else {
-               (void)sprintf(buf, "%03o", (int)*p);
+               sprintf(buf, "%03o", (int)*p);
                str = buf;
 strpr:         *pr->cchar = 's';
-               (void)printf(pr->fmt, str);
+               printf(pr->fmt, str);
        }
 }
 
@@ -95,15 +95,15 @@ conv_u(PR *pr, u_char *p)
                                                /* od used nl, not lf */
        if (*p <= 0x1f) {
                *pr->cchar = 's';
-               (void)printf(pr->fmt, list[*p]);
+               printf(pr->fmt, list[*p]);
        } else if (*p == 0x7f) {
                *pr->cchar = 's';
-               (void)printf(pr->fmt, "del");
+               printf(pr->fmt, "del");
        } else if (isprint(*p)) {
                *pr->cchar = 'c';
-               (void)printf(pr->fmt, *p);
+               printf(pr->fmt, *p);
        } else {
                *pr->cchar = 'x';
-               (void)printf(pr->fmt, (int)*p);
+               printf(pr->fmt, (int)*p);
        }
 }
index 2fc781cb53893b1436363cb5fe5aee289c55806a..b2ed9753fa8041b9c14ba792a7d42fbbc686a161 100644 (file)
@@ -162,9 +162,17 @@ static void bpad(PR *pr)
        pr->flags = F_BPAD;
        pr->cchar[0] = 's';
        pr->cchar[1] = 0;
-       for (p1 = pr->fmt; *p1 != '%'; ++p1);
-       for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1);
-       while ((*p2++ = *p1++) != 0) ;
+
+       p1 = pr->fmt;
+       while (*p1 != '%')
+               ++p1;
+
+       p2 = ++p1;
+       while (*p1 && strchr(spec, *p1))
+               ++p1;
+
+       while ((*p2++ = *p1++))
+               ;
 }
 
 void display(void)
index cbf87dcb49a2557a60ebcf2997a1357eb21668c6..e3c3897ed92f2bd8ea1d2596864bea2ef6fcb492 100644 (file)
@@ -78,10 +78,8 @@ int main(int argc, char **argv)
        }
 
        /* rewrite the rules, do syntax checking */
-       list_for_each(p, &fshead) {
-               tfs = list_entry(p, FS, nextfs);
-               rewrite(tfs);
-       }
+       list_for_each(p, &fshead)
+               rewrite(list_entry(p, FS, nextfs));
 
        next(argv);
        display();
index 53ca13575185652dba9d57415df440af4c67171d..f7a96c5b7f96a825acf8448f70b4d4fb8e731ac7 100644 (file)
@@ -56,7 +56,7 @@ newsyntax(int argc, char ***argvp)
 {
        int ch;
        char **argv;
-       char *hex_offt_fmt = "\"%07.7_Ax\n\"";
+       char *hex_offt = "\"%07.7_Ax\n\"";
 
        static const struct option longopts[] = {
                {"one-byte-octal", no_argument, NULL, 'b'},
@@ -79,11 +79,11 @@ newsyntax(int argc, char ***argvp)
        while ((ch = getopt_long(argc, argv, "bcCde:f:n:os:vxhV", longopts, NULL)) != -1) {
                switch (ch) {
                case 'b':
-                       add(hex_offt_fmt);
+                       add(hex_offt);
                        add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"");
                        break;
                case 'c':
-                       add(hex_offt_fmt);
+                       add(hex_offt);
                        add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
                        break;
                case 'C':
@@ -92,7 +92,7 @@ newsyntax(int argc, char ***argvp)
                        add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
                        break;
                case 'd':
-                       add(hex_offt_fmt);
+                       add(hex_offt);
                        add("\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"");
                        break;
                case 'e':
@@ -105,7 +105,7 @@ newsyntax(int argc, char ***argvp)
                        length = strtosize_or_err(optarg, _("failed to parse length"));
                        break;
                case 'o':
-                       add(hex_offt_fmt);
+                       add(hex_offt);
                        add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"");
                        break;
                case 's':
@@ -115,7 +115,7 @@ newsyntax(int argc, char ***argvp)
                        vflag = ALL;
                        break;
                case 'x':
-                       add(hex_offt_fmt);
+                       add(hex_offt);
                        add("\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"");
                        break;
                case 'h':
@@ -130,7 +130,7 @@ newsyntax(int argc, char ***argvp)
        }
 
        if (list_empty(&fshead)) {
-               add(hex_offt_fmt);
+               add(hex_offt);
                add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"");
        }
 
index 544af879945bb515b60646370b35d1e9c8bf4005..45052982e7dd798110f98790d6102c5a6e19c0f6 100644 (file)
@@ -119,7 +119,7 @@ void add(const char *fmt)
                        tfu->reps = atoi((char *)savep);
                        tfu->flags = F_SETREP;
                        /* skip trailing white space */
-                       while (++p && isspace(*p))
+                       while (isspace(*++p))
                                ;
                }
 
@@ -137,7 +137,7 @@ void add(const char *fmt)
                                badfmt(fmt);
                        tfu->bcnt = atoi((char *)savep);
                        /* skip trailing white space */
-                       while (++p && isspace(*p))
+                       while (isspace(*++p))
                                ;
                }
 
@@ -455,10 +455,10 @@ void rewrite(FS *fs)
                if (fu->reps > 1) {
                        if (!list_empty(&fu->nextpr)) {
                                pr = list_last_entry(&fu->nextpr, PR, nextpr);
-                       for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
-                               p2 = isspace(*p1) ? p1 : NULL;
-                       if (p2)
-                               pr->nospace = p2;
+                               for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
+                                       p2 = isspace(*p1) ? p1 : NULL;
+                               if (p2)
+                                       pr->nospace = p2;
                        }
                }
        }