]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #5559 from mjstapp/fix_test_typelist
authorQuentin Young <qlyoung@users.noreply.github.com>
Wed, 18 Dec 2019 19:20:25 +0000 (14:20 -0500)
committerGitHub <noreply@github.com>
Wed, 18 Dec 2019 19:20:25 +0000 (14:20 -0500)
tests: fix endian bug in test_typelist

tests/lib/test_typelist.h

index f20bbc52d9bff902b242b0839d66d82de49d4f89..9039fa8a464d56647b9e3f1d6475fce0625d8e0f 100644 (file)
@@ -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);