From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org
Cc: Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH v3 1/5] eal: use sizeof to avoid a double use of a define
Date: Tue, 24 Apr 2018 16:46:47 +0200 [thread overview]
Message-ID: <20180424144651.13145-2-olivier.matz@6wind.com> (raw)
In-Reply-To: <20180424144651.13145-1-olivier.matz@6wind.com>
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 | 2 +-
examples/vhost/main.c | 2 +-
lib/librte_eal/bsdapp/eal/eal.c | 4 ++--
lib/librte_eal/bsdapp/eal/eal_thread.c | 2 +-
lib/librte_eal/common/eal_common_proc.c | 4 ++--
lib/librte_eal/linuxapp/eal/eal.c | 4 ++--
lib/librte_eal/linuxapp/eal/eal_interrupts.c | 2 +-
lib/librte_eal/linuxapp/eal/eal_thread.c | 2 +-
lib/librte_eal/linuxapp/eal/eal_timer.c | 2 +-
lib/librte_vhost/socket.c | 4 ++--
10 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 8543a9803..52b95025c 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -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");
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 84e0d6366..e33a0f3c9 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -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,
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index d315cdef8..10d8dc03f 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -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);
}
diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c b/lib/librte_eal/bsdapp/eal/eal_thread.c
index d602daf81..309b58726 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -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 ? "" : "...");
diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 9136fb0a3..c450c848f 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -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 */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 5b23bf0e0..200e879d2 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -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);
diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 58e93281a..b5bcfc59a 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -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)
diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c b/lib/librte_eal/linuxapp/eal/eal_thread.c
index 08e150b77..f652ff988 100644
--- a/lib/librte_eal/linuxapp/eal/eal_thread.c
+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c
@@ -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 ? "" : "...");
diff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c
index 161322f23..098e22a65 100644
--- a/lib/librte_eal/linuxapp/eal/eal_timer.c
+++ b/lib/librte_eal/linuxapp/eal/eal_timer.c
@@ -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,
diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 636fc25c6..6eec427e4 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -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)) {
--
2.11.0
next prev parent reply other threads:[~2018-04-24 14:47 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 13:04 [dpdk-dev] [PATCH v2 0/4] fix control thread affinities Olivier Matz
2018-04-03 13:04 ` [dpdk-dev] [PATCH v2 1/4] eal: use sizeof to avoid a double use of a define Olivier Matz
2018-04-10 16:18 ` Burakov, Anatoly
2018-04-03 13:04 ` [dpdk-dev] [PATCH v2 2/4] eal: new function to create control threads Olivier Matz
2018-04-10 16:18 ` Burakov, Anatoly
2018-04-03 13:04 ` [dpdk-dev] [PATCH v2 3/4] eal: set name when creating a control thread Olivier Matz
2018-04-10 16:34 ` Burakov, Anatoly
2018-04-23 12:49 ` Olivier Matz
2018-04-17 22:32 ` Thomas Monjalon
2018-04-23 12:52 ` Olivier Matz
2018-04-03 13:04 ` [dpdk-dev] [PATCH v2 4/4] eal: set affinity for control threads Olivier Matz
2018-04-10 16:18 ` Burakov, Anatoly
2018-04-03 13:13 ` [dpdk-dev] [PATCH v2 0/4] fix control thread affinities Olivier Matz
2018-04-10 16:20 ` Burakov, Anatoly
2018-04-24 14:46 ` [dpdk-dev] [PATCH v3 0/5] " Olivier Matz
2018-04-24 14:46 ` Olivier Matz [this message]
2018-04-24 14:46 ` [dpdk-dev] [PATCH v3 2/5] eal: new function to create control threads Olivier Matz
2018-04-24 14:46 ` [dpdk-dev] [PATCH v3 3/5] eal: set name when creating a control thread Olivier Matz
2018-04-24 16:08 ` Burakov, Anatoly
2018-04-27 15:46 ` Tan, Jianfeng
2018-04-27 16:17 ` Tan, Jianfeng
2018-04-27 16:46 ` Burakov, Anatoly
2018-04-24 14:46 ` [dpdk-dev] [PATCH v3 4/5] eal: set affinity for control threads Olivier Matz
2018-04-24 14:46 ` [dpdk-dev] [PATCH v3 5/5] examples: use new API to create " Olivier Matz
2018-04-24 22:53 ` [dpdk-dev] [PATCH v3 0/5] fix control thread affinities Thomas Monjalon
2018-04-30 15:45 ` [dpdk-dev] pthread_barrier_deadlock in -rc1 (was: "Re: [PATCH v3 0/5] fix control thread affinities") Maxime Coquelin
2018-04-30 18:46 ` Olivier Matz
2018-05-01 8:59 ` Thomas Monjalon
2018-05-02 8:19 ` [dpdk-dev] pthread_barrier_deadlock in -rc1 Tan, Jianfeng
2018-05-02 8:34 ` Maxime Coquelin
2018-05-02 8:50 ` Tan, Jianfeng
2018-05-02 9:05 ` Maxime Coquelin
2018-05-02 9:20 ` Olivier Matz
2018-05-02 9:32 ` Tan, Jianfeng
2018-05-02 9:41 ` Maxime Coquelin
2018-05-02 9:30 ` Burakov, Anatoly
2018-05-02 9:38 ` Tan, Jianfeng
2018-05-02 9:57 ` Olivier Matz
2018-05-02 10:01 ` Tan, Jianfeng
2018-05-02 10:08 ` Olivier Matz
2018-05-02 10:16 ` Tan, Jianfeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180424144651.13145-2-olivier.matz@6wind.com \
--to=olivier.matz@6wind.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).