From d8d0c481b8d1ad5e9599994c5e8f8fa83657ce5c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 4 May 2015 15:10:27 +0200 Subject: [PATCH] test: fix wrong use of memcmp() in nmtst_platform_ip4_routes_equal() And nmtst_platform_ip6_routes_equal(). As already indicated by the comment, using memcmp() doesn't really work here. It worked up to now, because the NMPlatformIP4Route structure has no padding at the end. If we would have a last 'guint8' member (as we will add later), initializing an arry of routes on the stack would not clear the bytes from the padding and the comparison using memcmp() would fail. --- include/nm-test-utils.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 04c5d5f1c5..94040c12c3 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -832,9 +832,6 @@ nmtst_platform_ip4_routes_equal (const NMPlatformIP4Route *a, const NMPlatformIP nmtst_static_1024_02 (nm_platform_ip4_route_to_string (&b[i]))); g_assert_not_reached (); } - - /* also check with memcmp, though this might fail for valid programs (due to field alignment) */ - g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0); } } @@ -867,9 +864,6 @@ nmtst_platform_ip6_routes_equal (const NMPlatformIP6Route *a, const NMPlatformIP nmtst_static_1024_02 (nm_platform_ip6_route_to_string (&b[i]))); g_assert_not_reached (); } - - /* also check with memcmp, though this might fail for valid programs (due to field alignment) */ - g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0); } }