From: Eugene Syromyatnikov Date: Mon, 7 May 2018 06:51:06 +0000 (+0200) Subject: xlat.c: cleanup printxvals_ex a bit X-Git-Tag: v4.23~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fd42fc53a3197bce9134e854a4cf9e1a008ef3b;p=strace xlat.c: cleanup printxvals_ex a bit * xlat.c (printxvals_ex): Change "str" variable visibility to the whole function, jump to va_end instead of duplicating call and return, return !!str. --- diff --git a/xlat.c b/xlat.c index 65b2cd96..ff249464 100644 --- 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