[dpdk-dev,3/4] examples/qos_sched: suppress GCC 7.1.1 warnings

Message ID 20170602112031.9112-3-jerin.jacob@caviumnetworks.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jerin Jacob June 2, 2017, 11:20 a.m. UTC
  This one is more of a compiler issue as application
checks the app_parse_opt_vals() return value.

Since this code is in slow path, adding a memset
to fix following "maybe-uninitialized" warning.

qos_sched/args.c: In function ‘app_parse_args’:
examples/qos_sched/args.c:254:32: error: ‘vals[0]’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
pconf->rx_port = (uint8_t)vals[0];
                            ~~~~^~~
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 examples/qos_sched/args.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Cristian Dumitrescu June 2, 2017, 6:18 p.m. UTC | #1
> -----Original Message-----

> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]

> Sent: Friday, June 2, 2017 12:21 PM

> To: dev@dpdk.org

> Cc: Richardson, Bruce <bruce.richardson@intel.com>;

> thomas@monjalon.net; Dumitrescu, Cristian

> <cristian.dumitrescu@intel.com>; yuanhan.liu@linux.intel.com;

> maxime.coquelin@redhat.com; Jerin Jacob

> <jerin.jacob@caviumnetworks.com>

> Subject: [dpdk-dev] [PATCH 3/4] examples/qos_sched: suppress GCC 7.1.1

> warnings

> 

> This one is more of a compiler issue as application

> checks the app_parse_opt_vals() return value.

> 

> Since this code is in slow path, adding a memset

> to fix following "maybe-uninitialized" warning.

> 

> qos_sched/args.c: In function ‘app_parse_args’:

> examples/qos_sched/args.c:254:32: error: ‘vals[0]’ may be

> used uninitialized in this function [-Werror=maybe-uninitialized]

> pconf->rx_port = (uint8_t)vals[0];

>                             ~~~~^~~

> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> ---


Acked-by: Cristian.Dumitrescu@intel.com
  

Patch

diff --git a/examples/qos_sched/args.c b/examples/qos_sched/args.c
index 476a0ee1c..2350d64f4 100644
--- a/examples/qos_sched/args.c
+++ b/examples/qos_sched/args.c
@@ -245,6 +245,7 @@  app_parse_flow_conf(const char *conf_str)
 	struct flow_conf *pconf;
 	uint64_t mask;
 
+	memset(vals, 0, sizeof(vals));
 	ret = app_parse_opt_vals(conf_str, ',', 6, vals);
 	if (ret < 4 || ret > 5)
 		return ret;