Ensure that length argument of memcmp() isn't seen as negative.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 15 Feb 2022 22:28:17 +0000 (17:28 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 15 Feb 2022 22:28:17 +0000 (17:28 -0500)
I think this will shut up a weird warning from buildfarm member
serinus.  Perhaps it'd be better to change tsCompareString's
length arguments to unsigned, but that seems more invasive
than is justified.

Part of a general push to remove off-the-beaten-track warnings
where we can easily do so.

src/backend/utils/adt/tsvector_op.c

index 3a138186f1f1ebb17b4c84e9a9640fcfaa45c5b6..8ba9ef22f566fd9c18e522d4b59c3bcf73931e1a 100644 (file)
@@ -1167,7 +1167,7 @@ tsCompareString(char *a, int lena, char *b, int lenb, bool prefix)
    }
    else
    {
-       cmp = memcmp(a, b, Min(lena, lenb));
+       cmp = memcmp(a, b, Min((unsigned int) lena, (unsigned int) lenb));
 
        if (prefix)
        {