use sizeof to avoid double use of a length define
authorOlivier Matz <olivier.matz@6wind.com>
Tue, 24 Apr 2018 14:46:47 +0000 (16:46 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 24 Apr 2018 22:51:31 +0000 (00:51 +0200)
Only a cosmetic change: the *_LEN defines are already used
when defining the buffer. Using sizeof() ensures that the length
stays consistent, even if the definition is modified.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
examples/tep_termination/main.c
examples/vhost/main.c
lib/librte_eal/bsdapp/eal/eal.c
lib/librte_eal/bsdapp/eal/eal_thread.c
lib/librte_eal/common/eal_common_proc.c
lib/librte_eal/linuxapp/eal/eal.c
lib/librte_eal/linuxapp/eal/eal_interrupts.c
lib/librte_eal/linuxapp/eal/eal_thread.c
lib/librte_eal/linuxapp/eal/eal_timer.c
lib/librte_vhost/socket.c

index 8543a98..52b9502 100644 (file)
@@ -1208,7 +1208,7 @@ main(int argc, char *argv[])
                ret = pthread_create(&tid, NULL, (void *)print_stats, NULL);
                if (ret != 0)
                        rte_exit(EXIT_FAILURE, "Cannot create print-stats thread\n");
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
+               snprintf(thread_name, sizeof(thread_name), "print-stats");
                ret = rte_thread_setname(tid, thread_name);
                if (ret != 0)
                        RTE_LOG(DEBUG, VHOST_CONFIG, "Cannot set print-stats name\n");
index 84e0d63..e33a0f3 100644 (file)
@@ -1499,7 +1499,7 @@ main(int argc, char *argv[])
                                "Cannot create print-stats thread\n");
 
                /* Set thread_name for aid in debugging.  */
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
+               snprintf(thread_name, sizeof(thread_name), "print-stats");
                ret = rte_thread_setname(tid, thread_name);
                if (ret != 0)
                        RTE_LOG(DEBUG, VHOST_CONFIG,
index d315cde..10d8dc0 100644 (file)
@@ -657,7 +657,7 @@ rte_eal_init(int argc, char **argv)
 
        eal_thread_init_master(rte_config.master_lcore);
 
-       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+       ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
 
        RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
                rte_config.master_lcore, thread_id, cpuset,
@@ -683,7 +683,7 @@ rte_eal_init(int argc, char **argv)
                        rte_panic("Cannot create thread\n");
 
                /* Set thread_name for aid in debugging. */
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+               snprintf(thread_name, sizeof(thread_name),
                                "lcore-slave-%d", i);
                rte_thread_setname(lcore_config[i].thread_id, thread_name);
        }
index d602daf..309b587 100644 (file)
@@ -119,7 +119,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)
        if (eal_thread_set_affinity() < 0)
                rte_panic("cannot set affinity\n");
 
-       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+       ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
 
        RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
                lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
index 9136fb0..c450c84 100644 (file)
@@ -682,11 +682,11 @@ rte_mp_channel_init(void)
        }
 
        /* try best to set thread name */
-       strlcpy(thread_name, "rte_mp_handle", RTE_MAX_THREAD_NAME_LEN);
+       strlcpy(thread_name, "rte_mp_handle", sizeof(thread_name));
        rte_thread_setname(mp_handle_tid, thread_name);
 
        /* try best to set thread name */
-       strlcpy(thread_name, "rte_mp_async_handle", RTE_MAX_THREAD_NAME_LEN);
+       strlcpy(thread_name, "rte_mp_async_handle", sizeof(thread_name));
        rte_thread_setname(async_reply_handle_tid, thread_name);
 
        /* unlock the directory */
index 5b23bf0..200e879 100644 (file)
@@ -895,7 +895,7 @@ rte_eal_init(int argc, char **argv)
 
        eal_thread_init_master(rte_config.master_lcore);
 
-       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+       ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
 
        RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
                rte_config.master_lcore, (int)thread_id, cpuset,
@@ -926,7 +926,7 @@ rte_eal_init(int argc, char **argv)
                        rte_panic("Cannot create thread\n");
 
                /* Set thread_name for aid in debugging. */
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+               snprintf(thread_name, sizeof(thread_name),
                        "lcore-slave-%d", i);
                ret = rte_thread_setname(lcore_config[i].thread_id,
                                                thread_name);
index 58e9328..b5bcfc5 100644 (file)
@@ -877,7 +877,7 @@ rte_eal_intr_init(void)
                        "Failed to create thread for interrupt handling\n");
        } else {
                /* Set thread_name for aid in debugging. */
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+               snprintf(thread_name, sizeof(thread_name),
                        "eal-intr-thread");
                ret_1 = rte_thread_setname(intr_thread, thread_name);
                if (ret_1 != 0)
index 08e150b..f652ff9 100644 (file)
@@ -119,7 +119,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)
        if (eal_thread_set_affinity() < 0)
                rte_panic("cannot set affinity\n");
 
-       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+       ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
 
        RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
                lcore_id, (int)thread_id, cpuset, ret == 0 ? "" : "...");
index 161322f..098e22a 100644 (file)
@@ -189,7 +189,7 @@ rte_eal_hpet_init(int make_default)
        /*
         * Set thread_name for aid in debugging.
         */
-       snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "hpet-msb-inc");
+       snprintf(thread_name, sizeof(thread_name), "hpet-msb-inc");
        ret = rte_thread_setname(msb_inc_thread_id, thread_name);
        if (ret != 0)
                RTE_LOG(DEBUG, EAL,
index 636fc25..6eec427 100644 (file)
@@ -485,7 +485,7 @@ vhost_user_reconnect_init(void)
                                "failed to destroy reconnect mutex");
                }
        } else {
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+               snprintf(thread_name, sizeof(thread_name),
                         "vhost-reconn");
 
                if (rte_thread_setname(reconn_tid, thread_name)) {
@@ -1029,7 +1029,7 @@ rte_vhost_driver_start(const char *path)
                        fdset_pipe_uninit(&vhost_user.fdset);
                        return -1;
                } else {
-                       snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+                       snprintf(thread_name, sizeof(thread_name),
                                 "vhost-events");
 
                        if (rte_thread_setname(fdset_tid, thread_name)) {