net: fix build with -Wpedantic

Message ID 20220929065006.832858-1-alialnu@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series net: fix build with -Wpedantic |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Ali Alnubani Sept. 29, 2022, 6:50 a.m. UTC
  Adds the __extension__ attribute to resolve the following warning
with gcc 4.8.5 on CentOS 7:
lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
  a GCC extension [-Werror=pedantic]

Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
Cc: gakhil@marvell.com

Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
---
 lib/net/rte_macsec.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Akhil Goyal Sept. 29, 2022, 7:01 a.m. UTC | #1
> Adds the __extension__ attribute to resolve the following warning
> with gcc 4.8.5 on CentOS 7:
> lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
>   a GCC extension [-Werror=pedantic]
> 
> Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
> Cc: gakhil@marvell.com
> 
> Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> ---
>  lib/net/rte_macsec.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
> index 9228ebd083..d0cd2f69ab 100644
> --- a/lib/net/rte_macsec.h
> +++ b/lib/net/rte_macsec.h
> @@ -28,6 +28,7 @@ extern "C" {
>  /**
>   * MACsec Header (SecTAG)
>   */
> +__extension__

RTE_STD_C11 ??


>  struct rte_macsec_hdr {
>  	/**
>  	 * Tag control information and Association number of secure channel.
> --
> 2.25.1
  
Ali Alnubani Sept. 29, 2022, 7:07 a.m. UTC | #2
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Thursday, September 29, 2022 10:02 AM
> To: Ali Alnubani <alialnu@nvidia.com>; dev@dpdk.org
> Subject: RE: [EXT] [PATCH] net: fix build with -Wpedantic
> 
> > Adds the __extension__ attribute to resolve the following warning
> > with gcc 4.8.5 on CentOS 7:
> > lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
> >   a GCC extension [-Werror=pedantic]
> >
> > Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
> > Cc: gakhil@marvell.com
> >
> > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> > ---
> >  lib/net/rte_macsec.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
> > index 9228ebd083..d0cd2f69ab 100644
> > --- a/lib/net/rte_macsec.h
> > +++ b/lib/net/rte_macsec.h
> > @@ -28,6 +28,7 @@ extern "C" {
> >  /**
> >   * MACsec Header (SecTAG)
> >   */
> > +__extension__
> 
> RTE_STD_C11 ??

Replacing the __extension__ attribute with RTE_STD_C11 doesn't resolve the build failure for me.
  
Akhil Goyal Sept. 29, 2022, 7:09 a.m. UTC | #3
> > > Adds the __extension__ attribute to resolve the following warning
> > > with gcc 4.8.5 on CentOS 7:
> > > lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
> > >   a GCC extension [-Werror=pedantic]
> > >
> > > Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
> > > Cc: gakhil@marvell.com
> > >
> > > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> > > ---
> > >  lib/net/rte_macsec.h | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
> > > index 9228ebd083..d0cd2f69ab 100644
> > > --- a/lib/net/rte_macsec.h
> > > +++ b/lib/net/rte_macsec.h
> > > @@ -28,6 +28,7 @@ extern "C" {
> > >  /**
> > >   * MACsec Header (SecTAG)
> > >   */
> > > +__extension__
> >
> > RTE_STD_C11 ??
> 
> Replacing the __extension__ attribute with RTE_STD_C11 doesn't resolve the
> build failure for me.

Ok, Thanks for the fix.

Acked-by: Akhil Goyal <gakhil@marvell.com>
  
Thomas Monjalon Sept. 29, 2022, 7:09 a.m. UTC | #4
29/09/2022 09:01, Akhil Goyal:
> > Adds the __extension__ attribute to resolve the following warning
> > with gcc 4.8.5 on CentOS 7:
> > lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
> >   a GCC extension [-Werror=pedantic]
> > 
> > Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
> > Cc: gakhil@marvell.com
> > 
> > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> > ---
> > --- a/lib/net/rte_macsec.h
> > +++ b/lib/net/rte_macsec.h
> > @@ -28,6 +28,7 @@ extern "C" {
> >  /**
> >   * MACsec Header (SecTAG)
> >   */
> > +__extension__
> 
> RTE_STD_C11 ??

We use RTE_STD_C11 only for anonymous struct and union.
I don't know why we don't use it for bitfield in struct.
It seems to be part of C11 standard, right?

In doubt, I would continue with __extension__
and we can replace all similar occurences in a separate patch,
if confirmed it is well defined in C11.
  
Thomas Monjalon Sept. 29, 2022, 7:20 a.m. UTC | #5
29/09/2022 09:09, Akhil Goyal:
> > > > Adds the __extension__ attribute to resolve the following warning
> > > > with gcc 4.8.5 on CentOS 7:
> > > > lib/net/rte_macsec.h:38:2: error: type of bit-field 'short_length' is
> > > >   a GCC extension [-Werror=pedantic]
> > > >
> > > > Fixes: 0aaf097585a6 ("ethdev: add MACsec flow item")
> > > > Cc: gakhil@marvell.com
> > > >
> > > > Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> > > > ---
> > > >  lib/net/rte_macsec.h | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
> > > > index 9228ebd083..d0cd2f69ab 100644
> > > > --- a/lib/net/rte_macsec.h
> > > > +++ b/lib/net/rte_macsec.h
> > > > @@ -28,6 +28,7 @@ extern "C" {
> > > >  /**
> > > >   * MACsec Header (SecTAG)
> > > >   */
> > > > +__extension__
> > >
> > > RTE_STD_C11 ??
> > 
> > Replacing the __extension__ attribute with RTE_STD_C11 doesn't resolve the
> > build failure for me.
> 
> Ok, Thanks for the fix.
> 
> Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied, thanks.
  

Patch

diff --git a/lib/net/rte_macsec.h b/lib/net/rte_macsec.h
index 9228ebd083..d0cd2f69ab 100644
--- a/lib/net/rte_macsec.h
+++ b/lib/net/rte_macsec.h
@@ -28,6 +28,7 @@  extern "C" {
 /**
  * MACsec Header (SecTAG)
  */
+__extension__
 struct rte_macsec_hdr {
 	/**
 	 * Tag control information and Association number of secure channel.