]> granicus.if.org Git - strace/commitdiff
xlat.c: cleanup printxvals_ex a bit
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 7 May 2018 06:51:06 +0000 (08:51 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 5 Jun 2018 11:04:09 +0000 (11:04 +0000)
* xlat.c (printxvals_ex): Change "str" variable visibility to the whole
function, jump to va_end instead of duplicating call and return, return
!!str.

xlat.c

diff --git a/xlat.c b/xlat.c
index 65b2cd96b802bcddf06faad7e39e227d61ea9ea5..ff249464fa48923cc3333afdfb068b812066f4a7 100644 (file)
--- a/xlat.c
+++ b/xlat.c
@@ -119,11 +119,12 @@ printxvals_ex(const uint64_t val, const char *dflt, enum xlat_style style,
                return 0;
        }
 
+       const char *str = NULL;
        va_list args;
 
        va_start(args, xlat);
        for (; xlat; xlat = va_arg(args, const struct xlat *)) {
-               const char *str = xlookup(xlat, val);
+               str = xlookup(xlat, val);
 
                if (str) {
                        if (xlat_verbose(style) == XLAT_STYLE_VERBOSE) {
@@ -133,17 +134,18 @@ printxvals_ex(const uint64_t val, const char *dflt, enum xlat_style style,
                                tprints(str);
                        }
 
-                       va_end(args);
-                       return 1;
+                       goto printxvals_ex_end;
                }
        }
+
        /* No hits -- print raw # instead. */
        print_xlat_val(val, style);
        tprints_comment(dflt);
 
+printxvals_ex_end:
        va_end(args);
 
-       return 0;
+       return !!str;
 }
 
 int