[v2] net: fix compilation with pedantic enabled

Message ID 1595320315-15549-1-git-send-email-rasland@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net: fix compilation with pedantic enabled |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Raslan Darawsheh July 21, 2020, 8:31 a.m. UTC
  when trying to compile rte_mpls with pedantic enabled,
on old compilers like 4.8 it will complain about bit field definition.

error: type of bit-field 'bs' is a GCC extension [-Werror=pedantic]
error: type of bit-field 'tc' is a GCC extension [-Werror=pedantic]
error: type of bit-field 'tag_lsb' is a GCC extension [-Werror=pedantic]

This fixes the compilation error by adding extension to the header
definition.

Fixes: e480cf487a0d ("net: add MPLS header structure")
Cc: olivier.matz@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
v2: fixed commit log spelling issue
    added reference to old compilers where it fail.
    change the implementation from changing the type of the bit fields
    to adding __extension__ to the header definition
---
 lib/librte_net/rte_mpls.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Ferruh Yigit July 21, 2020, 3:43 p.m. UTC | #1
On 7/21/2020 9:31 AM, Raslan Darawsheh wrote:
> when trying to compile rte_mpls with pedantic enabled,
> on old compilers like 4.8 it will complain about bit field definition.
> 
> error: type of bit-field 'bs' is a GCC extension [-Werror=pedantic]
> error: type of bit-field 'tc' is a GCC extension [-Werror=pedantic]
> error: type of bit-field 'tag_lsb' is a GCC extension [-Werror=pedantic]
> 
> This fixes the compilation error by adding extension to the header
> definition.
> 
> Fixes: e480cf487a0d ("net: add MPLS header structure")
> Cc: olivier.matz@6wind.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/lib/librte_net/rte_mpls.h b/lib/librte_net/rte_mpls.h
index db91707..3e8cb90 100644
--- a/lib/librte_net/rte_mpls.h
+++ b/lib/librte_net/rte_mpls.h
@@ -21,6 +21,7 @@  extern "C" {
 /**
  * MPLS header.
  */
+__extension__
 struct rte_mpls_hdr {
 	uint16_t tag_msb;   /**< Label(msb). */
 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN