From: Dmitry V. Levin Date: Sun, 15 Nov 2015 20:44:13 +0000 (+0000) Subject: sprintflags: skip zero flags X-Git-Tag: v4.11~146 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71af1158ec792a050d8591937906d6609067e599;p=strace sprintflags: skip zero flags Tweak sprintflags behaviour to match printflags. * util.c (sprintflags): Skip zero flags unless the value passed to sprintflags is also zero. --- diff --git a/util.c b/util.c index 5f1f733e..68e82593 100644 --- a/util.c +++ b/util.c @@ -326,8 +326,13 @@ sprintflags(const char *prefix, const struct xlat *xlat, int flags) outptr = stpcpy(outstr, prefix); + if (flags == 0 && xlat->val == 0 && xlat->str) { + strcpy(outptr, xlat->str); + return outstr; + } + for (; xlat->str; xlat++) { - if ((flags & xlat->val) == xlat->val) { + if (xlat->val && (flags & xlat->val) == xlat->val) { if (found) *outptr++ = '|'; outptr = stpcpy(outptr, xlat->str);