From 57f7f9e7bc7cbcf1eb4dc00692d0229c73057d69 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 20 Jul 2018 14:35:12 +1000 Subject: 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 --- tests/testutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/testutils.c b/tests/testutils.c index 3c83b96..378869a 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -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; -- cgit v1.1