]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix pointer wraparound warning
authorSami Kerola <kerolasa@iki.fi>
Thu, 13 Feb 2020 21:28:37 +0000 (21:28 +0000)
committerSami Kerola <kerolasa@iki.fi>
Sat, 15 Feb 2020 15:24:02 +0000 (15:24 +0000)
libfdisk/src/gpt.c:1713:6: warning: assuming pointer wraparound does not
occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libfdisk/src/gpt.c

index 79b95f710ee18f28ef13e1f9d1298765ae0d6c41..11bf9fefb76f3ff891871d140cdf04a4847ad5af 100644 (file)
@@ -1710,13 +1710,13 @@ static int gpt_entry_attrs_to_string(struct gpt_entry *e, char **res)
                p += l - 1;
        }
        if (isset(bits, GPT_ATTRBIT_NOBLOCK)) {
-               if (p > *res)
+               if (p != *res)
                        *p++ = ' ';
                memcpy(p, GPT_ATTRSTR_NOBLOCK, (l = sizeof(GPT_ATTRSTR_NOBLOCK)));
                p += l - 1;
        }
        if (isset(bits, GPT_ATTRBIT_LEGACY)) {
-               if (p > *res)
+               if (p != *res)
                        *p++ = ' ';
                memcpy(p, GPT_ATTRSTR_LEGACY, (l = sizeof(GPT_ATTRSTR_LEGACY)));
                p += l - 1;
@@ -1728,7 +1728,7 @@ static int gpt_entry_attrs_to_string(struct gpt_entry *e, char **res)
                if (!isset(bits, n))
                        continue;
                if (!count) {
-                       if (p > *res)
+                       if (p != *res)
                                *p++ = ' ';
                        p += sprintf(p, "GUID:%u", n);
                } else