Skip to contentSkip to conversation

virtio-net: Fix VirtIONet typedef redefinition

PATCH In review Philippe Mathieu-Daudé 5 participants 9 messages Jan 21, 2019 – Jan 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-net: Fix VirtIONet typedef redefinition

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.
However, when compiling with Clang in -std=gnu99 mode, this triggers the following warning/error:

CC hw/net/virtio-net.o
In file included from qemu/hw/net/virtio-net.c:22:
include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]

  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^

1 error generated.
make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Fix it by removing the duplicate typedef definition.

---
 include/hw/virtio/virtio-net.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/hw/virtio/virtio-net.h +2 -3
index c7ec1a755f..bd662752d2 100644
@@ -106,7 +106,6 @@ typedef struct VirtioNetRscSeg {
     NetClientState *nc;
 } VirtioNetRscSeg;
 
-struct VirtIONet;
 typedef struct VirtIONet VirtIONet;
 
 /* Chain is divided by protocol(ipv4/v6) and NetClientInfo */
@@ -136,7 +135,7 @@ typedef struct VirtIONetQueue {
     struct VirtIONet *n;
 } VirtIONetQueue;
 
-typedef struct VirtIONet {
+struct VirtIONet {
     VirtIODevice parent_obj;
     uint8_t mac[ETH_ALEN];
     uint16_t status;
@@ -186,7 +185,7 @@ typedef struct VirtIONet {
     int announce_counter;
     bool needs_vnet_hdr_swap;
     bool mtu_bypass_backend;
-} VirtIONet;
+};
 
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Quoted 14 lines

However, when compiling with Clang in -std=gnu99 mode, this triggers the following warning/error:

CC hw/net/virtio-net.o
In file included from qemu/hw/net/virtio-net.c:22:
include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]

  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^

1 error generated.
make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Quoted 7 lines

Fix it by removing the duplicate typedef definition.

---
 include/hw/virtio/virtio-net.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 6 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Thanks Eric.

Thomas, do you mind fixing this if you take this patch?

Quoted 24 lines
Quoted 14 lines

However, when compiling with Clang in -std=gnu99 mode, this triggers the following warning/error:

CC hw/net/virtio-net.o
In file included from qemu/hw/net/virtio-net.c:22:
include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]

  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^

1 error generated.
make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Quoted 7 lines

Fix it by removing the duplicate typedef definition.

---
 include/hw/virtio/virtio-net.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
#3 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Thanks Eric.

Thomas, do you mind fixing this if you take this patch?

No problem, just fixed it while picking up the patch.

Thanks,
Thomas

#4 lore raw
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Quoted 9 lines
Quoted 3 lines

Thanks Eric.

Thomas, do you mind fixing this if you take this patch?

No problem, just fixed it while picking up the patch.

Thanks,
Thomas

I'm not sure why it's going through that tree but sure go ahead. Sent Reviewed-by tag.

#5 lore raw
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Thanks Eric.

Thomas, do you mind fixing this if you take this patch?

No problem, just fixed it while picking up the patch.

I'm not sure why it's going through that tree but sure go ahead.

Sorry, I certainly don't want to step on your toes here. I just need this patch to fix compilation with "-std=gnu99" which is required for the patch in my PULL request that enables this compiler flag there:

https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg02695.html

Quoted 1 line

Sent Reviewed-by tag.

Thanks a lot!

Thomas

#6 lore raw
Quoted 17 lines · Thomas Huth
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Thomas Huth
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Eric Blake
Quoted 3 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.

s/be declarated forward/use a forward declaration/

Thanks Eric.

Thomas, do you mind fixing this if you take this patch?

No problem, just fixed it while picking up the patch.

Quoted 7 lines
Quoted 1 line

I'm not sure why it's going through that tree but sure go ahead.

Sorry, I certainly don't want to step on your toes here. I just need this patch to fix compilation with "-std=gnu99" which is required for the patch in my PULL request that enables this compiler flag there:

https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg02695.html

Oh. Your tree makes sense then.

Quoted 5 lines
Quoted 1 line

Sent Reviewed-by tag.

Thanks a lot!

Thomas

Reviewed-by on v1 1/1
#7 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · On Mon, 21 Jan 2019 19:10:30 +0100 Philippe Mathieu-Daudé <[email protected]>…

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.
However, when compiling with Clang in -std=gnu99 mode, this triggers the following warning/error:

CC hw/net/virtio-net.o
In file included from qemu/hw/net/virtio-net.c:22:
include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]

  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^
Quoted 8 lines

1 error generated.
make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Fix it by removing the duplicate typedef definition.

---

Quoted 33 lines
 include/hw/virtio/virtio-net.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/hw/virtio/virtio-net.h +2 -3
index c7ec1a755f..bd662752d2 100644
@@ -106,7 +106,6 @@ typedef struct VirtioNetRscSeg {
     NetClientState *nc;
 } VirtioNetRscSeg;
 
-struct VirtIONet;
 typedef struct VirtIONet VirtIONet;
 
 /* Chain is divided by protocol(ipv4/v6) and NetClientInfo */
@@ -136,7 +135,7 @@ typedef struct VirtIONetQueue {
     struct VirtIONet *n;
 } VirtIONetQueue;
 
-typedef struct VirtIONet {
+struct VirtIONet {
     VirtIODevice parent_obj;
     uint8_t mac[ETH_ALEN];
     uint16_t status;
@@ -186,7 +185,7 @@ typedef struct VirtIONet {
     int announce_counter;
     bool needs_vnet_hdr_swap;
     bool mtu_bypass_backend;
-} VirtIONet;
+};
 
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
Reviewed-by on v1 1/1
#8 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

Commit 2974e916df8 introduced the VirtioNetRscChain structure which refer to a VirtIONet, declared later, thus required VirtIONet typedef to be declarated forward.
However, when compiling with Clang in -std=gnu99 mode, this triggers the following warning/error:

CC hw/net/virtio-net.o
In file included from qemu/hw/net/virtio-net.c:22:
include/hw/virtio/virtio-net.h:189:3: error: redefinition of typedef 'VirtIONet' is a C11 feature [-Werror,-Wtypedef-redefinition]

  } VirtIONet;
    ^
  include/hw/virtio/virtio-net.h:110:26: note: previous definition is here
  typedef struct VirtIONet VirtIONet;
                           ^
Quoted 7 lines

1 error generated.
make: *** [rules.mak:69: hw/net/virtio-net.o] Error 1

Fix it by removing the duplicate typedef definition.

Quoted 36 lines
---
 include/hw/virtio/virtio-net.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/hw/virtio/virtio-net.h +2 -3
index c7ec1a755f..bd662752d2 100644
@@ -106,7 +106,6 @@ typedef struct VirtioNetRscSeg {
     NetClientState *nc;
 } VirtioNetRscSeg;
 
-struct VirtIONet;
 typedef struct VirtIONet VirtIONet;
 
 /* Chain is divided by protocol(ipv4/v6) and NetClientInfo */
@@ -136,7 +135,7 @@ typedef struct VirtIONetQueue {
     struct VirtIONet *n;
 } VirtIONetQueue;
 
-typedef struct VirtIONet {
+struct VirtIONet {
     VirtIODevice parent_obj;
     uint8_t mac[ETH_ALEN];
     uint16_t status;
@@ -186,7 +185,7 @@ typedef struct VirtIONet {
     int announce_counter;
     bool needs_vnet_hdr_swap;
     bool mtu_bypass_backend;
-} VirtIONet;
+};
 
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
Signature · 1 line
2.20.1