Skip to contentSkip to conversation

drivers/virtio: fix duplicate naming of include guard

PATCH Superseded Andrius Sirvys 4 participants 7 messages Mar 20, 2019 – Mar 27, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/virtio: fix duplicate naming of include guard

The LGTM static code analysis tool is reporting

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
---
 drivers/net/virtio/virtio_user/vhost.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +2 -2
index 83a85cc..f8d26b6 100644
@@ -2,8 +2,8 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef ANOTHER_VHOST_NET_USER_H
+#define ANOTHER_VHOST_NET_USER_H
 
 #include <stdint.h>
 #include <linux/types.h>
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Andrius Sirvys

The LGTM static code analysis tool is reporting

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

Quoted 9 lines

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

---

#2 lore raw
In reply to Andrius Sirvys
Quoted 7 lines · Andrius Sirvys

The LGTM static code analysis tool is reporting

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Above two files are private headers in two individual modules, there is no chance that they will be included by the same file. But I agree it's not a good name for any of them.

Quoted 13 lines
Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
---
 drivers/net/virtio/virtio_user/vhost.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +0 -0
index 83a85cc..f8d26b6 100644

drivers/net/virtio/virtio_user/vhost.h line 6

Quoted 7 lines
drivers/net/virtio/virtio_user/vhost.h +2 -2
@@ -2,8 +2,8 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef ANOTHER_VHOST_NET_USER_H
+#define ANOTHER_VHOST_NET_USER_H

If we want to change it, I prefer to change it to _PATH_NAME_, e.g. _VIRTIO_USER_VHOST_H_ or similar.

Thanks,
Tiwei

Quoted 6 lines
drivers/net/virtio/virtio_user/vhost.h +0 -0
 #include <stdint.h>
 #include <linux/types.h>
Signature · 1 line
2.7.4
#3 lore raw
Quoted 29 lines · Tiwei Bie
Quoted 7 lines · Andrius Sirvys

The LGTM static code analysis tool is reporting

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Above two files are private headers in two individual modules, there is no chance that they will be included by the same file. But I agree it's not a good name for any of them.

Quoted 16 lines
Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
---
  drivers/net/virtio/virtio_user/vhost.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +0 -0
index 83a85cc..f8d26b6 100644
@@ -2,8 +2,8 @@
   * Copyright(c) 2010-2016 Intel Corporation
   */
 
Quoted 7 lines

drivers/net/virtio/virtio_user/vhost.h line 6

Quoted 4 lines
drivers/net/virtio/virtio_user/vhost.h +2 -2
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef ANOTHER_VHOST_NET_USER_H
+#define ANOTHER_VHOST_NET_USER_H

If we want to change it, I prefer to change it to _PATH_NAME_, e.g. _VIRTIO_USER_VHOST_H_ or similar.

+1 for _VIRTIO_USER_VHOST_H_

Quoted 10 lines

Thanks,
Tiwei

Quoted 6 lines
drivers/net/virtio/virtio_user/vhost.h +0 -0
  #include <stdint.h>
  #include <linux/types.h>
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 1/1 drivers/virtio: fix duplicate naming of include guard

In reply to Andrius Sirvys

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

---
v2: changed the name of the variable

---
 drivers/net/virtio/virtio_user/vhost.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +2 -2
index 83a85cc..55f4703 100644
@@ -2,8 +2,8 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef _VIRTIO_USER_VHOST_H
+#define _VIRTIO_USER_VHOST_H
 
 #include <stdint.h>
 #include <linux/types.h>
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#5 lore raw
Quoted 33 lines · Andrius Sirvys

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

---
v2: changed the name of the variable

---
 drivers/net/virtio/virtio_user/vhost.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +2 -2
index 83a85cc..55f4703 100644
@@ -2,8 +2,8 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef _VIRTIO_USER_VHOST_H
+#define _VIRTIO_USER_VHOST_H
 
 #include <stdint.h>
 #include <linux/types.h>
Signature · 1 line
2.7.4
#6 lore raw
In reply to Andrius Sirvys
Quoted 22 lines · Andrius Sirvys

"The macro name '_VHOST_NET_USER_H' of this include guard is used in 2 different header files."

lib/librte_vhost/vhost_user.h has the same include guard. Renamed the include guard in vhost.h to differentiate.

Fixes 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")

---
v2: changed the name of the variable

---
  drivers/net/virtio/virtio_user/vhost.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_user/vhost.h +0 -0
index 83a85cc..55f4703 100644

drivers/net/virtio/virtio_user/vhost.h line 9

Quoted 10 lines
drivers/net/virtio/virtio_user/vhost.h +2 -2
@@ -2,8 +2,8 @@
   * Copyright(c) 2010-2016 Intel Corporation
   */
 
-#ifndef _VHOST_NET_USER_H
-#define _VHOST_NET_USER_H
+#ifndef _VIRTIO_USER_VHOST_H
+#define _VIRTIO_USER_VHOST_H
 
  #include <stdint.h>
  #include <linux/types.h>

Applied to dpdk-next-virtio/master.

Next time please run the check-git-log script before posting, I fixed the issues while applying.

Thanks,
Maxime