]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: clean up variable-shadow warnings
authorMark Stapp <mjs@cisco.com>
Thu, 27 Mar 2025 17:29:24 +0000 (13:29 -0400)
committerMark Stapp <mjs@cisco.com>
Tue, 8 Apr 2025 18:41:27 +0000 (14:41 -0400)
Clean up -Wshadow warnings in unit-tests

Signed-off-by: Mark Stapp <mjs@cisco.com>
tests/isisd/test_common.c
tests/isisd/test_fuzz_isis_tlv.c
tests/lib/test_darr.c
tests/lib/test_printfrr.c

index e47456965e0e2f43734d61cc49263269fb34ab7b..e22ee2136505eaae51f94f3f0d9019411294e625 100644 (file)
@@ -33,11 +33,11 @@ test_topology_find_node(const struct isis_topology *topology,
 }
 
 const struct isis_topology *
-test_topology_find(struct isis_topology *test_topologies, uint16_t number)
+test_topology_find(struct isis_topology *topologies, uint16_t number)
 {
-       for (size_t i = 0; test_topologies[i].number; i++)
-               if (test_topologies[i].number == number)
-                       return &test_topologies[i];
+       for (size_t i = 0; topologies[i].number; i++)
+               if (topologies[i].number == number)
+                       return &topologies[i];
 
        return NULL;
 }
index 48a2caacce48a0d88d80b322af8f53be167380a4..2a8a5bc5d76eca5246f13d413c8608eac1eb7c22 100644 (file)
@@ -161,7 +161,7 @@ static int test(FILE *input, FILE *output)
        struct listnode *node;
        for (ALL_LIST_ELEMENTS_RO(fragments, node, tlvs)) {
                stream_reset(s);
-               int rv = isis_pack_tlvs(tlvs, s, (size_t)-1, false, false);
+               rv = isis_pack_tlvs(tlvs, s, (size_t)-1, false, false);
                if (rv) {
                        fprintf(output, "Could not pack fragment, too large.\n");
                        assert(0);
index be319db1c131d194b3b2b08ae50afe36217290d4..d980db505d9c92397f230e806b99f03a62c3c028 100644 (file)
@@ -157,12 +157,17 @@ static void test_int(void)
 
        assert(!memcmp(da2, a1, sizeof(a1)));
 
-       assert(darr_pop(da2) == 4);
-       assert(darr_pop(da2) == 3);
-       assert(darr_pop(da2) == 2);
+       i = darr_pop(da2);
+       assert(i == 4);
+       i = darr_pop(da2);
+       assert(i == 3);
+       i = darr_pop(da2);
+       assert(i == 2);
        assert(darr_len(da2) == 2);
-       assert(darr_pop(da2) == 1);
-       assert(darr_pop(da2) == 0);
+       i = darr_pop(da2);
+       assert(i == 1);
+       i = darr_pop(da2);
+       assert(i == 0);
        assert(darr_len(da2) == 0);
 
        darr_free(da2);
@@ -323,38 +328,47 @@ static void test_string(void)
        char *da2 = NULL;
        const char **strings = NULL;
        uint sum = 0;
+       uint i;
 
-       assert(darr_strlen(da1) == 0);
+       i = darr_strlen(da1);
+       assert(i == 0);
 
        da1 = darr_strdup(src);
-       assert(darr_strlen(da1) == strlen(da1));
-       assert(darr_strlen(da1) == srclen);
+       i = darr_strlen(da1);
+       assert(i == strlen(da1));
+       i = darr_strlen(da1);
+       assert(i == srclen);
        assert(darr_len(da1) == srclen + 1);
        assert(darr_ilen(da1) == (int)srclen + 1);
        assert(darr_cap(da1) >= 8);
        assert(darr_last(da1) == darr_strnul(da1));
-       assert(darr_strnul(da1) == da1 + darr_strlen(da1));
+       i = darr_strlen(da1);
+       assert(darr_strnul(da1) == da1 + i);
 
        da2 = da1;
        darr_in_strdup(da1, src);
        assert(da1 == da2);
-       assert(darr_strlen(da1) == strlen(da1));
-       assert(darr_strlen(da1) == srclen);
+       i = darr_strlen(da1);
+       assert(i == strlen(da1));
+       assert(i == srclen);
        assert(darr_len(da1) == srclen + 1);
        darr_free(da1);
        assert(da1 == NULL);
 
        da1 = darr_strdup_cap(src, 128);
-       assert(darr_strlen(da1) == srclen);
+       i = darr_strlen(da1);
+       assert(i == srclen);
        assert(darr_cap(da1) >= 128);
 
        darr_in_strdup_cap(da1, src, 256);
-       assert(darr_strlen(da1) == srclen);
+       i = darr_strlen(da1);
+       assert(i == srclen);
        assert(darr_cap(da1) >= 256);
        darr_free(da1);
 
        da1 = darr_strdup_cap(add, 2);
-       assert(darr_strlen(da1) == addlen);
+       i = darr_strlen(da1);
+       assert(i == addlen);
        assert(darr_cap(da1) >= 8);
 
        darr_in_strdup(da1, "ab");
@@ -377,7 +391,8 @@ static void test_string(void)
        da2 = darr_strdup(add);
        darr_in_strcat_tail(da1, da2);
        assert(!strcmp("abHIJ", da1));
-       assert(darr_strlen(da1) == 5);
+       i = darr_strlen(da1);
+       assert(i == 5);
        assert(darr_len(da1) == 6);
        darr_free(da1);
        darr_free(da2);
@@ -386,14 +401,16 @@ static void test_string(void)
        da2 = darr_strdup(add);
        darr_in_strcat_tail(da1, da2);
        assert(!strcmp("abcde", da1));
-       assert(darr_strlen(da1) == 5);
+       i = darr_strlen(da1);
+       assert(i == 5);
        assert(darr_len(da1) == 6);
        darr_free(da1);
        darr_free(da2);
 
        da1 = darr_sprintf("0123456789: %08X", 0xDEADBEEF);
        assert(!strcmp(da1, "0123456789: DEADBEEF"));
-       assert(darr_strlen(da1) == 20);
+       i = darr_strlen(da1);
+       assert(i == 20);
        assert(darr_cap(da1) == 128);
        da2 = da1;
        darr_in_sprintf(da1, "9876543210: %08x", 0x0BADF00D);
@@ -405,11 +422,13 @@ static void test_string(void)
        da1 = NULL;
        darr_in_sprintf(da1, "0123456789: %08X", 0xDEADBEEF);
        assert(!strcmp(da1, "0123456789: DEADBEEF"));
-       assert(darr_strlen(da1) == 20);
+       i = darr_strlen(da1);
+       assert(i == 20);
        assert(darr_cap(da1) == 128);
 
        da1[5] = 0;
-       assert(darr_strlen_fixup(da1) == 5);
+       i = darr_strlen_fixup(da1);
+       assert(i == 5);
        darr_free(da1);
 
        da1 = darr_sprintf("0123456789: %08x", 0xDEADBEEF);
index a81ebcdbcd78ddcb77855fb0ee3a946894a0cbfc..c915587c130d87581c0be404beae2d3753b3ba59 100644 (file)
@@ -107,7 +107,7 @@ static int printchk(const char *ref, const char *fmt, ...)
                errors++;
        }
 
-       for (size_t i = 0; i < fb.outpos_i; i++)
+       for (i = 0; i < fb.outpos_i; i++)
                printf("\t[%zu: %u..%u] = \"%.*s\"\n", i,
                        outpos[i].off_start,
                        outpos[i].off_end,