Skip to contentSkip to conversation

virtio-pci: Improve code style for including header files

PATCH In review Feng Liu 2 participants 5 messages May 29, 2023 – May 30, 2023 virtio core

lore
Share & tools
lore

Feng Liu

author
#0 lore raw

PATCH 1/1 virtio-pci: Improve code style for including header files

Fix code style related to including header file. Include header files before declaring macro definitions to avoid conflicts.

---
 drivers/virtio/virtio_pci_modern.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_modern.c +2 -1
index d6bb68ba84e5..b21a489e0086 100644
@@ -15,9 +15,10 @@
  */
 
 #include <linux/delay.h>
+#include "virtio_pci_common.h"
+
 #define VIRTIO_PCI_NO_LEGACY
 #define VIRTIO_RING_NO_LEGACY
-#include "virtio_pci_common.h"
 
 static u64 vp_get_features(struct virtio_device *vdev)
 {
Signature · 1 line
2.37.1 (Apple Git-137.1)
#1 lore raw
Quoted 5 lines · Feng Liu

Fix code style related to including header file. Include header files before declaring macro definitions to avoid conflicts.

Which conflicts? These macros are there precisely to change how the header behaves.

Quoted 22 lines
---
 drivers/virtio/virtio_pci_modern.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_modern.c +2 -1
index d6bb68ba84e5..b21a489e0086 100644
@@ -15,9 +15,10 @@
  */
 
 #include <linux/delay.h>
+#include "virtio_pci_common.h"
+
 #define VIRTIO_PCI_NO_LEGACY
 #define VIRTIO_RING_NO_LEGACY
-#include "virtio_pci_common.h"
 
 static u64 vp_get_features(struct virtio_device *vdev)
 {
Signature · 1 line
2.37.1 (Apple Git-137.1)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#2 lore raw
Quoted 4 lines · Michael S. Tsirkin

External email: Use caution opening links or attachments

On Mon, May 29, 2023 at 02:17:29PM -0400, Feng Liu wrote:

Quoted 9 lines
Quoted 5 lines

Fix code style related to including header file. Include header files before declaring macro definitions to avoid conflicts.

Which conflicts? These macros are there precisely to change how the header behaves.

Hi Michael
I think including the header files should be placed before the
macro definition.
If VIRTIO_PCI_NO_LEGACY and VIRTIO_RING_NO_LEGACY are needed for
control header file, we should put them at the beginning of virtio_pci_common.h.

What do you think?

Quoted 18 lines
Quoted 18 lines
---
  drivers/virtio/virtio_pci_modern.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_modern.c +2 -1
index d6bb68ba84e5..b21a489e0086 100644
@@ -15,9 +15,10 @@
   */
 
  #include <linux/delay.h>
+#include "virtio_pci_common.h"
+
  #define VIRTIO_PCI_NO_LEGACY
  #define VIRTIO_RING_NO_LEGACY
-#include "virtio_pci_common.h"
 
Quoted 5 lines
Quoted 4 lines
drivers/virtio/virtio_pci_modern.c +0 -1
  static u64 vp_get_features(struct virtio_device *vdev)
  {
--

2.37.1 (Apple Git-137.1)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 17 lines · Feng Liu
Quoted 4 lines · Michael S. Tsirkin

External email: Use caution opening links or attachments

On Mon, May 29, 2023 at 02:17:29PM -0400, Feng Liu wrote:

Quoted 9 lines
Quoted 5 lines

Fix code style related to including header file. Include header files before declaring macro definitions to avoid conflicts.

Which conflicts? These macros are there precisely to change how the header behaves.

Quoted 7 lines

Hi Michael
I think including the header files should be placed before the macro
definition.
If VIRTIO_PCI_NO_LEGACY and VIRTIO_RING_NO_LEGACY are needed for control
header file, we should put them at the beginning of virtio_pci_common.h.

What do you think?

I think you should read the code in question not make guesses.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
---
  drivers/virtio/virtio_pci_modern.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_modern.c +2 -1
index d6bb68ba84e5..b21a489e0086 100644
@@ -15,9 +15,10 @@
   */
 
  #include <linux/delay.h>
+#include "virtio_pci_common.h"
+
  #define VIRTIO_PCI_NO_LEGACY
  #define VIRTIO_RING_NO_LEGACY
-#include "virtio_pci_common.h"
 
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/virtio/virtio_pci_modern.c +0 -1
  static u64 vp_get_features(struct virtio_device *vdev)
  {
--

2.37.1 (Apple Git-137.1)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author
#4 lore raw
Quoted 27 lines · Michael S. Tsirkin

External email: Use caution opening links or attachments

Quoted 23 lines · Feng Liu
Quoted 4 lines · Michael S. Tsirkin

External email: Use caution opening links or attachments

On Mon, May 29, 2023 at 02:17:29PM -0400, Feng Liu wrote:

Quoted 9 lines
Quoted 5 lines

Fix code style related to including header file. Include header files before declaring macro definitions to avoid conflicts.

Which conflicts? These macros are there precisely to change how the header behaves.

Hi Michael
I think including the header files should be placed before the macro
definition.
If VIRTIO_PCI_NO_LEGACY and VIRTIO_RING_NO_LEGACY are needed for control
header file, we should put them at the beginning of virtio_pci_common.h.

Quoted 4 lines
Quoted 1 line

What do you think?

I think you should read the code in question not make guesses.

Okey. I see, thx

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
---
   drivers/virtio/virtio_pci_modern.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_pci_modern.c +2 -1
index d6bb68ba84e5..b21a489e0086 100644
@@ -15,9 +15,10 @@
    */
 
   #include <linux/delay.h>
+#include "virtio_pci_common.h"
+
   #define VIRTIO_PCI_NO_LEGACY
   #define VIRTIO_RING_NO_LEGACY
-#include "virtio_pci_common.h"
 
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/virtio/virtio_pci_modern.c +0 -1
   static u64 vp_get_features(struct virtio_device *vdev)
   {
--

2.37.1 (Apple Git-137.1)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization