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.
This commit is contained in:
Thomas Haller
2015-05-04 15:10:27 +02:00
parent f167346534
commit d8d0c481b8

View File

@@ -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);
}
}