]> granicus.if.org Git - strace/commitdiff
sprintflags: skip zero flags
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 15 Nov 2015 20:44:13 +0000 (20:44 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 16 Nov 2015 03:08:41 +0000 (03:08 +0000)
Tweak sprintflags behaviour to match printflags.

* util.c (sprintflags): Skip zero flags unless the value passed
to sprintflags is also zero.

util.c

diff --git a/util.c b/util.c
index 5f1f733e4d4be076df7f475e0504b4cc8fd30ab5..68e825932c5bcc9a35196b75412498553a5a0410 100644 (file)
--- 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);