[dpdk-dev] [PATCH 1/2] ip_pipeline: fix coverity warning
Stephen Hemminger
stephen at networkplumber.org
Tue Dec 8 17:51:08 CET 2015
Fix problem reported by latest Coverity scan.
It won't have a direct impact on anything.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
** CID 120412: Code maintainability issues (SIZEOF_MISMATCH)
/examples/ip_pipeline/thread_fe.c: 338 in app_pipeline_thread_cmd_push()
*** CID 120412: Code maintainability issues (SIZEOF_MISMATCH)
/examples/ip_pipeline/thread_fe.c: 338 in app_pipeline_thread_cmd_push()
332 /* Check for available slots in the application commands array */
333 n_cmds = RTE_DIM(thread_cmds) - 1;
334 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
335 return -ENOMEM;
336
337 /* Push thread commands into the application */
>>> CID 120412: Code maintainability issues (SIZEOF_MISMATCH)
>>> Passing argument "&app->cmds[app->n_cmds]" of type "cmdline_parse_ctx_t *" and argument "n_cmds * 8UL /* sizeof (cmdline_parse_ctx_t *) */" to function "memcpy" is suspicious. In this case, "sizeof (cmdline_parse_ctx_t *)" is equal to "sizeof (cmdline_parse_ctx_t)", but this is not a portable assumption.
338 memcpy(&app->cmds[app->n_cmds],
339 thread_cmds,
340 n_cmds * sizeof(cmdline_parse_ctx_t *));
341
342 for (i = 0; i < n_cmds; i++)
343 app->cmds[app->n_cmds + i]->data = app;
---
examples/ip_pipeline/thread_fe.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/examples/ip_pipeline/thread_fe.c b/examples/ip_pipeline/thread_fe.c
index 7a3bbf8..95f0107 100644
--- a/examples/ip_pipeline/thread_fe.c
+++ b/examples/ip_pipeline/thread_fe.c
@@ -335,9 +335,8 @@ app_pipeline_thread_cmd_push(struct app_params *app)
return -ENOMEM;
/* Push thread commands into the application */
- memcpy(&app->cmds[app->n_cmds],
- thread_cmds,
- n_cmds * sizeof(cmdline_parse_ctx_t *));
+ memcpy(&app->cmds[app->n_cmds], thread_cmds,
+ n_cmds * sizeof(cmdline_parse_ctx_t));
for (i = 0; i < n_cmds; i++)
app->cmds[app->n_cmds + i]->data = app;
--
2.1.4
More information about the dev
mailing list