]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #2486 from pacovn/cppcheck_fmt_validation
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 18 Jun 2018 19:23:49 +0000 (15:23 -0400)
committerGitHub <noreply@github.com>
Mon, 18 Jun 2018 19:23:49 +0000 (15:23 -0400)
babeld, lib, ospfd, tests: fmt fixes (cppcheck)

babeld/babel_interface.c
babeld/util.c
lib/csv.c
lib/ptm_lib.c
ospfd/ospf_dump.c
ospfd/ospf_interface.c
tests/lib/test_checksum.c
tests/lib/test_graph.c
tests/lib/test_timer_performance.c

index d4958ddf249e35c15d56c7f108510c127492d5a8..453fd8e04e62732c59a085e81717c8d283e75121 100644 (file)
@@ -1001,7 +1001,7 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty,
                 break;
             if(k > 0)
                 channels[j++] = ',';
-            snprintf(channels + j, 100 - j, "%d", route->channels[k]);
+            snprintf(channels + j, 100 - j, "%u", route->channels[k]);
             j = strlen(channels);
         }
         snprintf(channels + j, 100 - j, ")");
index 7dff11d124bddce3b20226eab3a6b4ecb4d94604..4a3ecace0ccad0748ac8dca4463b93fa273586fc 100644 (file)
@@ -303,7 +303,7 @@ format_thousands(unsigned int value)
     static char buf[4][15];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], 15, "%d.%.3d", value / 1000, value % 1000);
+    snprintf(buf[i], 15, "%u.%.3u", value / 1000, value % 1000);
     return buf[i];
 }
 
index e6a5eae2e2bba4306026e6de5c9f33643cb57943..ce84783aa6f7570da98027cabbc489a8cf1cd4b6 100644 (file)
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -663,8 +663,8 @@ int main()
 
        log_verbose("Mem: %d\n", get_memory_usage(getpid()));
        csv_init(&csv, buf, 256);
-       sprintf(hdr1, "%4u", 0);
-       sprintf(hdr2, "%4u", 1);
+       sprintf(hdr1, "%4d", 0);
+       sprintf(hdr2, "%4d", 1);
        log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
                    atoi(hdr2));
        rec = csv_encode(&csv, 2, hdr1, hdr2);
@@ -676,8 +676,8 @@ int main()
        }
        csv_encode(&csv, 2, "pdfadfadfadsadsaddfdfdsfdsd", "35444554545454545");
        log_verbose("%s\n", buf);
-       sprintf(hdr1, "%4u", csv.csv_len);
-       sprintf(hdr2, "%4u", 1);
+       sprintf(hdr1, "%4d", csv.csv_len);
+       sprintf(hdr2, "%4d", 1);
        log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
                    atoi(hdr2));
        rec = csv_encode_record(&csv, rec, 2, hdr1, hdr2);
index fea5a8cc4015ba6ac858dc1f8a91891b67bcd5e4..69fd61e2a06998ea914551f4b02b3aeb71e43c24 100644 (file)
@@ -60,10 +60,10 @@ static csv_record_t *_ptm_lib_encode_header(csv_t *csv, csv_record_t *rec,
        char client_buf[32];
        csv_record_t *rec1;
 
-       sprintf(msglen_buf, "%4u", msglen);
-       sprintf(vers_buf, "%4u", version);
-       sprintf(type_buf, "%4u", type);
-       sprintf(cmdid_buf, "%4u", cmd_id);
+       sprintf(msglen_buf, "%4d", msglen);
+       sprintf(vers_buf, "%4d", version);
+       sprintf(type_buf, "%4d", type);
+       sprintf(cmdid_buf, "%4d", cmd_id);
        snprintf(client_buf, 17, "%16.16s", client_name);
        if (rec) {
                rec1 = csv_encode_record(csv, rec, 5, msglen_buf, vers_buf,
index 1c911ebef86479cfdb62fbe1169641bdcb5c4b11..d8742943c0043022494ac545da87104a1926715b 100644 (file)
@@ -199,17 +199,17 @@ const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size)
        }
 
        if (w > 99)
-               snprintf(buf, size, "%ldw%1ldd", w, d);
+               snprintf(buf, size, "%luw%1lud", w, d);
        else if (w)
-               snprintf(buf, size, "%ldw%1ldd%02ldh", w, d, h);
+               snprintf(buf, size, "%luw%1lud%02luh", w, d, h);
        else if (d)
-               snprintf(buf, size, "%1ldd%02ldh%02ldm", d, h, m);
+               snprintf(buf, size, "%1lud%02luh%02lum", d, h, m);
        else if (h)
-               snprintf(buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
+               snprintf(buf, size, "%luh%02lum%02lds", h, m, (long)t->tv_sec);
        else if (m)
-               snprintf(buf, size, "%ldm%02lds", m, (long)t->tv_sec);
+               snprintf(buf, size, "%lum%02lds", m, (long)t->tv_sec);
        else if (ms)
-               snprintf(buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
+               snprintf(buf, size, "%ld.%03lus", (long)t->tv_sec, ms);
        else
                snprintf(buf, size, "%ld usecs", (long)t->tv_usec);
 
@@ -1683,7 +1683,7 @@ static int config_write_debug(struct vty *vty)
                return CMD_SUCCESS;
 
        if (ospf->instance)
-               sprintf(str, " %d", ospf->instance);
+               sprintf(str, " %u", ospf->instance);
 
        /* debug ospf ism (status|events|timers). */
        if (IS_CONF_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM)
index ea31d8c2ca2bbb8f50d6801d0a8750489a9b6c1b..23353b3c309f089a3e124ac5ff2ab2fb90bf364d 100644 (file)
@@ -857,7 +857,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
                        "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
                        ospf->vrf_id);
 
-       snprintf(ifname, sizeof(ifname), "VLINK%d", vlink_count);
+       snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
        vi = if_create(ifname, ospf->vrf_id);
        /*
         * if_create sets ZEBRA_INTERFACE_LINKDETECTION
index 3972f76763e3bbc4c21722763e0f94ec4df1484c..13d35b0e995862f9bc453cd7c01c9db7c8ab3817 100644 (file)
@@ -506,7 +506,7 @@ int main(int argc, char **argv)
                        printf("verify: lib failed\n");
 
                if (ospfd != lib) {
-                       printf("Mismatch in values at size %u\n"
+                       printf("Mismatch in values at size %d\n"
                               "ospfd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
                               "isisd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
                               "lib: 0x%04x\n",
index f21f8b793c731012385ea8620dd537ea30acd169..2801c48bc53bacb7d38f48e33712763dc2bc37aa 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char **argv)
 
        /* create vertices */
        for (unsigned int i = 0; i < NUMNODES; i++) {
-               snprintf(names[i], sizeof(names[i]), "%d", i);
+               snprintf(names[i], sizeof(names[i]), "%u", i);
                gn[i] = graph_new_node(g, names[i], NULL);
        }
 
index f9a244e2595f942ca808a1eec12cc303f5d61db9..d5f4badc85b5cdeff32971f96695e6e3a3733e10 100644 (file)
@@ -92,9 +92,9 @@ int main(int argc, char **argv)
        t_remove = 1000 * (tv_stop.tv_sec - tv_lap.tv_sec);
        t_remove += (tv_stop.tv_usec - tv_lap.tv_usec) / 1000;
 
-       printf("Scheduling %d random timers took %ld.%03ld seconds.\n",
+       printf("Scheduling %d random timers took %lu.%03lu seconds.\n",
               SCHEDULE_TIMERS, t_schedule / 1000, t_schedule % 1000);
-       printf("Removing %d random timers took %ld.%03ld seconds.\n",
+       printf("Removing %d random timers took %lu.%03lu seconds.\n",
               REMOVE_TIMERS, t_remove / 1000, t_remove % 1000);
        fflush(stdout);