From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 1/2] ip_pipeline: fix coverity warning Date: Tue, 8 Dec 2015 08:51:08 -0800 Message-ID: <1449593469-16954-2-git-send-email-stephen@networkplumber.org> References: <1449593469-16954-1-git-send-email-stephen@networkplumber.org> To: dev@dpdk.org Return-path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 3B3AC4A63 for ; Tue, 8 Dec 2015 17:51:03 +0100 (CET) Received: by pfu207 with SMTP id 207so14699447pfu.2 for ; Tue, 08 Dec 2015 08:51:02 -0800 (PST) In-Reply-To: <1449593469-16954-1-git-send-email-stephen@networkplumber.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix problem reported by latest Coverity scan. It won't have a direct impact on anything. Signed-off-by: Stephen Hemminger ** 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