DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement
@ 2016-05-23 12:19 Piotr Azarewicz
  2016-06-08 20:36 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Azarewicz @ 2016-05-23 12:19 UTC (permalink / raw)
  To: dev; +Cc: Piotr Azarewicz

qw app at its init stage reserve 2*sizeof(int) memory space for quota
and low_watermark shared variables, but both apps (qw and qwctl) assign
wrong address for low_watermark pointer (out of reserved memzone space)
due to wrong pointer arithmetic.

CID 30709 : Extra sizeof expression (SIZEOF_MISMATCH)
suspicious_pointer_arithmetic: Adding 4UL /* sizeof (int) */ to pointer
(unsigned int *)(*qw_memzone).addr of type unsigned int * is suspicious
because adding an integral value to this pointer automatically scales
that value by the size, 4 bytes, of the pointed-to type, unsigned int.
Most likely, sizeof (int) is extraneous and should be replaced with 1.

Coverity issue: 30709
Fixes: 1d6c3ee3321a ("examples/quota_watermark: initial import")

Signed-off-by: Piotr Azarewicz <piotrx.t.azarewicz@intel.com>
---
 examples/quota_watermark/qw/init.c     |    2 +-
 examples/quota_watermark/qwctl/qwctl.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c
index afc1366..c208721 100644
--- a/examples/quota_watermark/qw/init.c
+++ b/examples/quota_watermark/qw/init.c
@@ -170,5 +170,5 @@ setup_shared_variables(void)
         rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
 
     quota = qw_memzone->addr;
-    low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int);
+    low_watermark = (unsigned int *) qw_memzone->addr + 1;
 }
diff --git a/examples/quota_watermark/qwctl/qwctl.c b/examples/quota_watermark/qwctl/qwctl.c
index eb2f618..4961089 100644
--- a/examples/quota_watermark/qwctl/qwctl.c
+++ b/examples/quota_watermark/qwctl/qwctl.c
@@ -68,7 +68,7 @@ setup_shared_variables(void)
         rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
 
     quota = qw_memzone->addr;
-    low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int);
+    low_watermark = (unsigned int *) qw_memzone->addr + 1;
 }
 
 int main(int argc, char **argv)
-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement
  2016-05-23 12:19 [dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement Piotr Azarewicz
@ 2016-06-08 20:36 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-06-08 20:36 UTC (permalink / raw)
  To: Piotr Azarewicz; +Cc: dev

2016-05-23 14:19, Piotr Azarewicz:
> qw app at its init stage reserve 2*sizeof(int) memory space for quota
> and low_watermark shared variables, but both apps (qw and qwctl) assign
> wrong address for low_watermark pointer (out of reserved memzone space)
> due to wrong pointer arithmetic.
> 
> CID 30709 : Extra sizeof expression (SIZEOF_MISMATCH)
> suspicious_pointer_arithmetic: Adding 4UL /* sizeof (int) */ to pointer
> (unsigned int *)(*qw_memzone).addr of type unsigned int * is suspicious
> because adding an integral value to this pointer automatically scales
> that value by the size, 4 bytes, of the pointed-to type, unsigned int.
> Most likely, sizeof (int) is extraneous and should be replaced with 1.
> 
> Coverity issue: 30709
> Fixes: 1d6c3ee3321a ("examples/quota_watermark: initial import")
> 
> Signed-off-by: Piotr Azarewicz <piotrx.t.azarewicz@intel.com>

Applied, thanks

Is this example really useful?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-08 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23 12:19 [dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement Piotr Azarewicz
2016-06-08 20:36 ` Thomas Monjalon

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).