[dpdk-dev,v7,22/25] mlx5: work around spurious compilation errors

Message ID 1466774284-20932-23-git-send-email-nelio.laranjeiro@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Commit Message

NĂ©lio Laranjeiro June 24, 2016, 1:18 p.m. UTC
  From: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Since commit "mlx5: resurrect Tx gather support", older GCC versions (such
as 4.8.5) may complain about the following:

 mlx5_rxtx.c: In function `mlx5_tx_burst':
 mlx5_rxtx.c:705:25: error: `wqe' may be used uninitialized in this
     function [-Werror=maybe-uninitialized]

 mlx5_rxtx.c: In function `mlx5_tx_burst_inline':
 mlx5_rxtx.c:864:25: error: `wqe' may be used uninitialized in this
     function [-Werror=maybe-uninitialized]

In both cases, this code cannot be reached when wqe is not initialized.

Considering older GCC versions are still widely used, work around this
issue by initializing wqe preemptively, even if it should not be necessary.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Bruce Richardson June 27, 2016, 12:12 p.m. UTC | #1
On Fri, Jun 24, 2016 at 03:18:01PM +0200, Nelio Laranjeiro wrote:
> From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> 
> Since commit "mlx5: resurrect Tx gather support", older GCC versions (such
> as 4.8.5) may complain about the following:
> 
>  mlx5_rxtx.c: In function `mlx5_tx_burst':
>  mlx5_rxtx.c:705:25: error: `wqe' may be used uninitialized in this
>      function [-Werror=maybe-uninitialized]
> 
>  mlx5_rxtx.c: In function `mlx5_tx_burst_inline':
>  mlx5_rxtx.c:864:25: error: `wqe' may be used uninitialized in this
>      function [-Werror=maybe-uninitialized]
> 
> In both cases, this code cannot be reached when wqe is not initialized.
> 
> Considering older GCC versions are still widely used, work around this
> issue by initializing wqe preemptively, even if it should not be necessary.
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Since the previous patch is known to break the build on older compilers, I think
it would be better to merge this patch into the previous to prevent the break
from occurring in the first place. That will help with any future git-bisects
that people run.

If there is no objection, and no other issues appear requiring a new rev of
this patchset, I'll merge patches 21 and 22 on apply.

Regards,
/Bruce
  
Adrien Mazarguil June 27, 2016, 12:27 p.m. UTC | #2
On Mon, Jun 27, 2016 at 01:12:15PM +0100, Bruce Richardson wrote:
> On Fri, Jun 24, 2016 at 03:18:01PM +0200, Nelio Laranjeiro wrote:
> > From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> > 
> > Since commit "mlx5: resurrect Tx gather support", older GCC versions (such
> > as 4.8.5) may complain about the following:
> > 
> >  mlx5_rxtx.c: In function `mlx5_tx_burst':
> >  mlx5_rxtx.c:705:25: error: `wqe' may be used uninitialized in this
> >      function [-Werror=maybe-uninitialized]
> > 
> >  mlx5_rxtx.c: In function `mlx5_tx_burst_inline':
> >  mlx5_rxtx.c:864:25: error: `wqe' may be used uninitialized in this
> >      function [-Werror=maybe-uninitialized]
> > 
> > In both cases, this code cannot be reached when wqe is not initialized.
> > 
> > Considering older GCC versions are still widely used, work around this
> > issue by initializing wqe preemptively, even if it should not be necessary.
> > 
> > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> 
> Since the previous patch is known to break the build on older compilers, I think
> it would be better to merge this patch into the previous to prevent the break
> from occurring in the first place. That will help with any future git-bisects
> that people run.

Makes sense, in fact I only kept it separate to decribe why setting these
variables was necessary, in case someone wondered.

> If there is no objection, and no other issues appear requiring a new rev of
> this patchset, I'll merge patches 21 and 22 on apply.

That's fine by me.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index c72e7ce..8b67949 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -593,7 +593,7 @@  mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	unsigned int j = 0;
 	unsigned int max;
 	unsigned int comp;
-	volatile union mlx5_wqe *wqe;
+	volatile union mlx5_wqe *wqe = NULL;
 
 	if (unlikely(!pkts_n))
 		return 0;
@@ -741,7 +741,7 @@  mlx5_tx_burst_inline(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	unsigned int j = 0;
 	unsigned int max;
 	unsigned int comp;
-	volatile union mlx5_wqe *wqe;
+	volatile union mlx5_wqe *wqe = NULL;
 	unsigned int max_inline = txq->max_inline;
 
 	if (unlikely(!pkts_n))