libbb/dump: fix a few broken commits and shrink code
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Jul 2017 14:03:43 +0000 (16:03 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Jul 2017 14:03:43 +0000 (16:03 +0200)
function                                             old     new   delta
next                                                 310     294     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/dump.c

index 87c1dce13da10cd222e765f52e9fc17314d18ff1..bc0c1ec80997c03b98f4be92209a6d56b7f1697b 100644 (file)
@@ -58,7 +58,7 @@ static NOINLINE int bb_dump_size(FS *fs)
        const char *p;
        int prec;
 
-       /* figure out the data block bb_dump_size needed for each format unit */
+       /* figure out the data block size needed for each format unit */
        for (cur_size = 0, fu = fs->nextfu; fu; fu = fu->nextfu) {
                if (fu->bcnt) {
                        cur_size += fu->bcnt * fu->reps;
@@ -320,7 +320,7 @@ static void do_skip(priv_dumper_t *dumper, const char *fname, int statok)
                if (!(S_ISCHR(sbuf.st_mode) || S_ISBLK(sbuf.st_mode) || S_ISFIFO(sbuf.st_mode))
                 && dumper->pub.dump_skip >= sbuf.st_size
                ) {
-                       /* If bb_dump_size valid and pub.dump_skip >= size */
+                       /* If st_size is valid and pub.dump_skip >= st_size */
                        dumper->pub.dump_skip -= sbuf.st_size;
                        dumper->address += sbuf.st_size;
                        return;
@@ -339,12 +339,14 @@ static NOINLINE int next(priv_dumper_t *dumper)
        int statok;
 
        for (;;) {
-               if (*dumper->argv) {
+               char *fname = *dumper->argv;
+
+               if (fname) {
+                       dumper->argv++;
                        dumper->next__done = statok = 1;
-                       if (!(freopen(*dumper->argv, "r", stdin))) {
-                               bb_simple_perror_msg(*dumper->argv);
+                       if (!freopen(fname, "r", stdin)) {
+                               bb_simple_perror_msg(fname);
                                dumper->exitval = 1;
-                               ++dumper->argv;
                                continue;
                        }
                } else {
@@ -355,9 +357,7 @@ static NOINLINE int next(priv_dumper_t *dumper)
                        statok = 0;
                }
                if (dumper->pub.dump_skip)
-                       do_skip(dumper, statok ? *dumper->argv : "stdin", statok);
-               if (*dumper->argv)
-                       ++dumper->argv;
+                       do_skip(dumper, statok ? fname : "stdin", statok);
                if (!dumper->pub.dump_skip)
                        return 1;
        }
@@ -670,7 +670,7 @@ int FAST_FUNC bb_dump_dump(dumper_t *pub_dumper, char **argv)
        FS *tfs;
        int blocksize;
 
-       /* figure out the data block bb_dump_size */
+       /* figure out the data block size */
        blocksize = 0;
        tfs = dumper->pub.fshead;
        while (tfs) {