From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by dpdk.org (Postfix) with ESMTP id 5D6335A4B for ; Tue, 1 Sep 2015 03:59:00 +0200 (CEST) Received: by pabzx8 with SMTP id zx8so158046889pab.1 for ; Mon, 31 Aug 2015 18:58:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r3H0RCCvq1KuGoLjhcVzUA6b22RqczPVt4H7rxlZ3V8=; b=bnj9mEv3+QxW5Tfr/QyCKDai2IZhM91hMtv/N4sw6ZTFacnAR63Rjc4sULH9TLMv3v hEyAp0dFboPch79TD8Vx7eqMhFGasNzR7bnOiPsb1atX3N60+geA+wmbIAhJZSJsDEJ0 ED/0xBEX3jKVzFScV0/uKhj++cc1DgPQOqhRAszLpwtAiOEbWEmepRN5DTuo9t1kH1cd C2Paw9rQrGQI98JhCENokpR4tcIk3kj/II97Z+MJ4Uo0dhoZIn5l8hveNl18EYhQc1NK qFb437mVE3Mwu14CHzAOB6gnEk/J2kD/lOJxJHEtibZ7zVzaSX0Eig1mIq6kghKZp0ko 7JdA== X-Gm-Message-State: ALoCoQn056iLv1pWuUFqGmab5j5tZG7XvqH8/4ofvSjyWqYqhCoHfOj3yU21aUiuYb2NO6MEa7nh X-Received: by 10.66.164.98 with SMTP id yp2mr41743732pab.58.1441072739619; Mon, 31 Aug 2015 18:58:59 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ld8sm15988418pbc.61.2015.08.31.18.58.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 18:58:59 -0700 (PDT) From: Stephen Hemminger To: cristian.dumitrescu@intel.com Date: Mon, 31 Aug 2015 18:59:04 -0700 Message-Id: <1441072746-29174-4-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> References: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 01:59:00 -0000 Found by Coverity: Sizeof not portable (SIZEOF_MISMATCH) suspicious_sizeof: 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. Signed-off-by: Stephen Hemminger --- examples/ip_pipeline/init.c | 2 +- examples/ip_pipeline/pipeline/pipeline_common_fe.c | 2 +- examples/ip_pipeline/pipeline/pipeline_flow_classification.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 3f9c68d..75e3767 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -1325,7 +1325,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 fcda0ce..4eec66b 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c @@ -1321,7 +1321,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/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c index 24cf7dc..e5141b0 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c @@ -126,7 +126,6 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in, { struct pkt_key_ipv6_5tuple *ipv6 = key_buffer; - memset(ipv6, 0, 64); ipv6->payload_length = 0; ipv6->proto = key_in->key.ipv6_5tuple.proto; ipv6->hop_limit = 0; -- 2.1.4