tests: Don't call memcmp() with NULL arguments

You're not supposed to pass NULL to memcmp(), and some sanitizers complain
about it, even when the length is zero.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2018-07-20 14:35:12 +10:00
parent c12b2b0c20
commit 57f7f9e7bc

View file

@ -127,7 +127,7 @@ void check_property(void *fdt, int nodeoffset, const char *name,
if (proplen != len)
FAIL("Size mismatch on property \"%s\": %d insead of %d",
name, proplen, len);
if (memcmp(val, prop->data, len) != 0)
if (len && memcmp(val, prop->data, len) != 0)
FAIL("Data mismatch on property \"%s\"", name);
}
@ -144,7 +144,7 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name,
if (proplen != len)
FAIL("Size mismatch on property \"%s\": %d insead of %d",
name, proplen, len);
if (memcmp(val, propval, len) != 0)
if (len && memcmp(val, propval, len) != 0)
FAIL("Data mismatch on property \"%s\"", name);
return propval;