From 703f865749fda58ce6e88bd9239506df59e8c4e2 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Wed, 18 Dec 2019 10:52:08 -0500 Subject: [PATCH] tests: fix endian bug in test_typelist [7.2 version] Fix a byte-swapping bug that appeared on big-endian arch but wasn't visible on little-endian. Signed-off-by: Mark Stapp --- tests/lib/test_typelist.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/lib/test_typelist.h b/tests/lib/test_typelist.h index 7ff210cae3..6bb7e92299 100644 --- a/tests/lib/test_typelist.h +++ b/tests/lib/test_typelist.h @@ -98,12 +98,13 @@ static void ts_hash(const char *text, const char *expect) unsigned i = 0; uint8_t hash[32]; char hashtext[65]; - uint32_t count; + uint32_t swap_count, count; - count = htonl(list_count(&head)); + count = list_count(&head); + swap_count = htonl(count); SHA256_Init(&ctx); - SHA256_Update(&ctx, &count, sizeof(count)); + SHA256_Update(&ctx, &swap_count, sizeof(swap_count)); frr_each (list, &head, item) { struct { @@ -115,7 +116,7 @@ static void ts_hash(const char *text, const char *expect) }; SHA256_Update(&ctx, &hashitem, sizeof(hashitem)); i++; - assert(i < count); + assert(i <= count); } SHA256_Final(hash, &ctx); -- 2.39.5