From: Piotr Azarewicz Date: Wed, 9 Dec 2015 09:33:50 +0000 (+0100) Subject: examples/ip_pipeline: fix coverity warnings X-Git-Tag: spdx-start~7805 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2d8d97b734d3a921be3f12454f04e557bdc4fa94;p=dpdk.git examples/ip_pipeline: fix coverity warnings The source and destination both are the arrays of cmdline_parse_ctx_t. So the goal is to copy elements size of cmdline_parse_ctx_t not cmdline_parse_ctx_t*. 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. Coverity issue: 120412 Fixes: b4aee0fb9c6d ("examples/ip_pipeline: reconfigure thread binding dynamically") Fixes: ea0908c4ab89 ("examples/ip_pipeline: add master pipeline") Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters") Signed-off-by: Stephen Hemminger Signed-off-by: Piotr Azarewicz Acked-by: John McNamara --- diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 52aab53ed2..bc6d6d945b 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -1472,7 +1472,7 @@ app_pipeline_type_cmd_push(struct app_params *app, /* Push pipeline commands into the application */ memcpy(&app->cmds[app->n_cmds], cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c index 87ec1646da..1e16ad6f21 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c @@ -1292,7 +1292,7 @@ app_pipeline_common_cmd_push(struct app_params *app) /* Push pipeline commands into the application */ memcpy(&app->cmds[app->n_cmds], pipeline_common_cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; diff --git a/examples/ip_pipeline/thread_fe.c b/examples/ip_pipeline/thread_fe.c index 7a3bbf86b3..95f01071ed 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;