]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: revert global exitval variable change
authorSami Kerola <kerolasa@iki.fi>
Sun, 8 Sep 2013 16:09:09 +0000 (17:09 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Sep 2013 10:57:31 +0000 (12:57 +0200)
The change f2a037fb7b153954d5d34cca48182b6d8832fcfa had unfavorable
effect of making hexdump to return non-zero exit value always.

This happen because oversight when 'exitval' gets to be set.  By clance,
one might expect main() to call next() which will return value for
'exitval'.  That assessment misses later call chain main() -> display()
-> get() -> next(), which in reverse should return correct value for
'exitval'.

It was mentioned in util-linux maillist that Ondrej Oprala is working on
major renewal of the hexdump .  That in mind it seems best to simply to
revert the global 'exitval' and avoid conflict with Ondrej's work.

Reference: http://markmail.org/message/sbnvuhkboreujj5p
Reported-by: Dave Reisner <d@falconindy.com>
CC: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/display.c
text-utils/hexdump.c
text-utils/hexdump.h

index 41ddd8db5931072fd381050fac4f5e828546bf45..1f9a11b4c92ce59f3cc867892628b4707a7d1d40 100644 (file)
@@ -295,7 +295,7 @@ get(void)
 int next(char **argv)
 {
        static int done;
-       int statok, exitval = 0;
+       int statok;
 
        if (argv) {
                _argv = argv;
@@ -305,14 +305,14 @@ int next(char **argv)
                if (*_argv) {
                        if (!(freopen(*_argv, "r", stdin))) {
                                warn("%s", *_argv);
-                               exitval = 1;
+                               exitval = EXIT_FAILURE;
                                ++_argv;
                                continue;
                        }
                        statok = done = 1;
                } else {
                        if (done++)
-                               return(exitval);
+                               return(0);
                        statok = 0;
                }
                if (skip)
index 411d8098689ecce516b96041224e9b4e8e46f38e..e966cc313241224448c152a8d2ce42eb62ade6b1 100644 (file)
 
 FS *fshead;                            /* head of format strings */
 ssize_t blocksize;                     /* data block size */
+int exitval;                           /* final exit value */
 ssize_t length = -1;                   /* max bytes to read */
 
 int main(int argc, char **argv)
 {
-       int exitval;                    /* final exit value */
        FS *tfs;
        char *p;
 
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
        for (tfs = fshead; tfs; tfs = tfs->nextfs)
                rewrite(tfs);
 
-       exitval = next(argv);
+       (void)next(argv);
        display();
        return exitval;
 }
index b2ea1f152b38114d6d69178a557eee4c40f5f3a0..fa8f632c1f65fd149d3e3d0b2ea3978a6db2e2b8 100644 (file)
@@ -73,6 +73,7 @@ typedef struct _fs {                  /* format strings */
 extern FU *endfu;
 extern FS *fshead;                     /* head of format strings list */
 extern ssize_t blocksize;              /* data block size */
+extern int exitval;                    /* final exit value */
 extern ssize_t length;                 /* max bytes to read */
 extern off_t skip;                      /* bytes to skip */