[v2,4/4] event/octeontx2: fix build for O1 optimization

Message ID 20200508164546.2489396-4-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/4] ring: fix build for gcc O1 optimization |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit May 8, 2020, 4:45 p.m. UTC
  Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
gcc 7.3.0

Build error
In file included from .../drivers/event/octeontx2/ot
x2_evdev.c:15:0:
.../drivers/event/octeontx2/otx2_evdev_stats.h:
    In function ‘otx2_sso_xstats_get’:
.../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
    error: ‘xstats’ may be used uninitialized in this function
           [-Werror=maybe-uninitialized]
   xstat = &xstats[ids[i] - start_offset];
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is false positive, 'xstats_mode_count' should be preventing taking
the loop and accessing 'xstats'.
Returning in that case to silence the compiler warning.

Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ananyev, Konstantin May 8, 2020, 5:22 p.m. UTC | #1
> Subject: [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization
> 
> Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
> gcc 7.3.0
> 
> Build error
> In file included from .../drivers/event/octeontx2/ot
> x2_evdev.c:15:0:
> .../drivers/event/octeontx2/otx2_evdev_stats.h:
>     In function ‘otx2_sso_xstats_get’:
> .../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
>     error: ‘xstats’ may be used uninitialized in this function
>            [-Werror=maybe-uninitialized]
>    xstat = &xstats[ids[i] - start_offset];
>    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> This is false positive, 'xstats_mode_count' should be preventing taking
> the loop and accessing 'xstats'.
> Returning in that case to silence the compiler warning.
> 
> Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/event/octeontx2/otx2_evdev_stats.h b/drivers/event/octeontx2/otx2_evdev_stats.h
> index 9d7c694ee6..74fcec8a07 100644
> --- a/drivers/event/octeontx2/otx2_evdev_stats.h
> +++ b/drivers/event/octeontx2/otx2_evdev_stats.h
> @@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
> 
>  	switch (mode) {
>  	case RTE_EVENT_DEV_XSTATS_DEVICE:
> -		break;
> +		return 0;
>  	case RTE_EVENT_DEV_XSTATS_PORT:
>  		if (queue_port_id >= (signed int)dev->nb_event_ports)
>  			goto invalid_value;
> --

Tested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.25.4
  
Jerin Jacob May 10, 2020, 11:53 a.m. UTC | #2
On Fri, May 8, 2020 at 10:52 PM Ananyev, Konstantin
<konstantin.ananyev@intel.com> wrote:
>
>
>
> > Subject: [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization
> >
> > Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using
> > gcc 7.3.0
> >
> > Build error
> > In file included from .../drivers/event/octeontx2/ot
> > x2_evdev.c:15:0:
> > .../drivers/event/octeontx2/otx2_evdev_stats.h:
> >     In function ‘otx2_sso_xstats_get’:
> > .../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
> >     error: ‘xstats’ may be used uninitialized in this function
> >            [-Werror=maybe-uninitialized]
> >    xstat = &xstats[ids[i] - start_offset];
> >    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > This is false positive, 'xstats_mode_count' should be preventing taking
> > the loop and accessing 'xstats'.
> > Returning in that case to silence the compiler warning.
> >
> > Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> > ---
> >  drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/event/octeontx2/otx2_evdev_stats.h b/drivers/event/octeontx2/otx2_evdev_stats.h
> > index 9d7c694ee6..74fcec8a07 100644
> > --- a/drivers/event/octeontx2/otx2_evdev_stats.h
> > +++ b/drivers/event/octeontx2/otx2_evdev_stats.h
> > @@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
> >
> >       switch (mode) {
> >       case RTE_EVENT_DEV_XSTATS_DEVICE:
> > -             break;
> > +             return 0;
> >       case RTE_EVENT_DEV_XSTATS_PORT:
> >               if (queue_port_id >= (signed int)dev->nb_event_ports)
> >                       goto invalid_value;
> > --
>
> Tested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>



>
> > 2.25.4
>
  

Patch

diff --git a/drivers/event/octeontx2/otx2_evdev_stats.h b/drivers/event/octeontx2/otx2_evdev_stats.h
index 9d7c694ee6..74fcec8a07 100644
--- a/drivers/event/octeontx2/otx2_evdev_stats.h
+++ b/drivers/event/octeontx2/otx2_evdev_stats.h
@@ -67,7 +67,7 @@  otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
 	switch (mode) {
 	case RTE_EVENT_DEV_XSTATS_DEVICE:
-		break;
+		return 0;
 	case RTE_EVENT_DEV_XSTATS_PORT:
 		if (queue_port_id >= (signed int)dev->nb_event_ports)
 			goto invalid_value;