DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/2] ip_pipeline: fix coverity warning
Date: Tue,  8 Dec 2015 08:51:08 -0800	[thread overview]
Message-ID: <1449593469-16954-2-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1449593469-16954-1-git-send-email-stephen@networkplumber.org>

Fix problem reported by latest Coverity scan.
It won't have a direct impact on anything.

Signed-off-by: Stephen Hemminger <stephen@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

  reply	other threads:[~2015-12-08 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 16:51 [dpdk-dev] [PATCH 0/2] Trivial fixes for Coverity warnings Stephen Hemminger
2015-12-08 16:51 ` Stephen Hemminger [this message]
2015-12-08 16:51 ` [dpdk-dev] [PATCH 2/2] ethtool: fix dead code Stephen Hemminger
2015-12-08 16:58   ` Remy Horton
2015-12-09 20:36     ` Thomas Monjalon

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=1449593469-16954-2-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --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).