Skip to contentSkip to conversation

Can the empty struct rte_eth_txmode be enhanced?

PATCH In review lxu 3 participants 5 messages Jun 12, 2013 4 messages not in the archive

lore
Share & tools
lore

lxu

author Acked-by Olivier Matz
#0 lore raw

Great! Thanks for the quick feedback.

------------------ Original ------------------

From:  "Olivier MATZ"<[email protected]>;
Date:  Wed, Jun 12, 2013 05:17 PM
To:  "dev"<[email protected]>; 

Cc: "lxu"<[email protected]>;
Subject: Re: [dpdk-dev] Can the empty struct rte_eth_txmode be enhanced?

Hello,

Quoted 5 lines

Can we change the struct rte_eth_txmode ?

Such as :

struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */

I agree with your solution. Do you approve the following patch ?

From: lxu <[email protected]>
Date: Wed, 12 Jun 2013 09:32:30 +0200
Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0

The size of an empty structure is 0 when compiling with gcc, and 1 when compiling with g++. Adding an empty table forces the size fo be 0, in C or C++.

---
  lib/librte_ether/rte_ethdev.h |    1 +
  1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
index 5985496..e0a1ccf 100644
@@ -320,6 +320,7 @@ struct rte_eth_vmdq_dcb_conf {
   * For future extensions.
   */
  struct rte_eth_txmode {
+       int reserved[]; /* force the size of struct to be 0 */
  };
 
  /**
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to a message not in the archive

12/06/2013 14:23, lxu :

Quoted 10 lines

Great! Thanks for the quick feedback.

------------------ Original ------------------
From: "Olivier MATZ"<[email protected]>;

I agree with your solution. Do you approve the following patch ?

From: lxu <[email protected]>
Date: Wed, 12 Jun 2013 09:32:30 +0200
Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0

applied, thanks

Signature · 1 line
Thomas
#4 lore raw

PATCH 1/1 ethdev: fix empty struct rte_eth_txmode

In reply to a message not in the archive

The previous fix was for g++ but is broken with gcc:
error: flexible array member in otherwise empty struct
See http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Zero-Length.html

Let's fix it with #ifdef __cplusplus.

---
 lib/librte_ether/rte_ethdev.h |    2 ++
 1 file changed, 2 insertions(+)
lib/librte_ether/rte_ethdev.h +2 -0
index a253b3f..2280772 100644
@@ -320,7 +320,9 @@ struct rte_eth_vmdq_dcb_conf {
  * For future extensions.
  */
 struct rte_eth_txmode {
+#ifdef __cplusplus
 	int reserved[]; /* force size of struct to be 0 */
+#endif
 };
 
 /**
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [PATCH] ethdev: fix empty struct rte_eth_txmode

In reply to a message not in the archive
Quoted 5 lines · Thomas Monjalon

The previous fix was for g++ but is broken with gcc:
error: flexible array member in otherwise empty struct
See http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Zero-Length.html

Let's fix it with #ifdef __cplusplus.

Sorry Thomas for the previous one, I should have tested it.

This one looks good, I checked compilation and it works with gcc-4.6.3 and g++-4.6.3

#8 lore raw

Re: [PATCH] ethdev: fix empty struct rte_eth_txmode

In reply to a message not in the archive

12/06/2013 16:46, Olivier MATZ :

Quoted 5 lines · Thomas Monjalon
Quoted 2 lines

The previous fix was for g++ but is broken with gcc:
error: flexible array member in otherwise empty struct

Sorry Thomas for the previous one, I should have tested it.

No problem, I should also better test before pushing :)

Quoted 2 lines

This one looks good, I checked compilation and it works with gcc-4.6.3 and g++-4.6.3

pushed

Signature · 1 line
Thomas