Skip to contentSkip to conversation

hw/watchdog/wdt_diag288: Remove unnecessary includes

PATCH Applied Thomas Huth 6 participants 11 messages Nov 18, 2020 – Nov 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/watchdog/wdt_diag288: Remove unnecessary includes

Both headers, sysbus.h and module.h, are not required to compile this file.

---
 hw/watchdog/wdt_diag288.c | 2 --
 1 file changed, 2 deletions(-)
hw/watchdog/wdt_diag288.c +0 -2
index 71a945f0bd..4c4b6a6ab7 100644
@@ -14,12 +14,10 @@
 #include "qemu/osdep.h"
 #include "sysemu/reset.h"
 #include "sysemu/watchdog.h"
-#include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "hw/watchdog/wdt_diag288.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
-#include "qemu/module.h"
 
 static WatchdogTimerModel model = {
     .wdt_name = TYPE_WDT_DIAG288,
Signature · 1 line
2.18.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

It is not a sysbus device and not a module.

Quoted 22 lines
---
 hw/watchdog/wdt_diag288.c | 2 --
 1 file changed, 2 deletions(-)
hw/watchdog/wdt_diag288.c +0 -2
index 71a945f0bd..4c4b6a6ab7 100644
@@ -14,12 +14,10 @@
 #include "qemu/osdep.h"
 #include "sysemu/reset.h"
 #include "sysemu/watchdog.h"
-#include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "hw/watchdog/wdt_diag288.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
-#include "qemu/module.h"
 
 static WatchdogTimerModel model = {
     .wdt_name = TYPE_WDT_DIAG288,
#2 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

---
 hw/watchdog/wdt_diag288.c | 2 --
 1 file changed, 2 deletions(-)
hw/watchdog/wdt_diag288.c +0 -0
index 71a945f0bd..4c4b6a6ab7 100644

hw/watchdog/wdt_diag288.c line 17

Quoted 4 lines
hw/watchdog/wdt_diag288.c +0 -1
@@ -14,12 +14,10 @@
 #include "qemu/osdep.h"
 #include "sysemu/reset.h"
 #include "sysemu/watchdog.h"
-#include "hw/sysbus.h"

OK

hw/watchdog/wdt_diag288.c line 22

Quoted 5 lines
hw/watchdog/wdt_diag288.c +0 -1
 #include "qemu/timer.h"
 #include "hw/watchdog/wdt_diag288.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
-#include "qemu/module.h"

Cc'ing Markus because of:

commit 0b8fa32f551e863bb548a11394239239270dd3dc

Author: Markus Armbruster <[email protected]>
Date:   Thu May 23 16:35:07 2019 +0200

Include qemu/module.h where needed, drop it from qemu-common.h

Quoted 4 lines
hw/watchdog/wdt_diag288.c +0 -0
 static WatchdogTimerModel model = {
     .wdt_name = TYPE_WDT_DIAG288,
 
#3 lore raw
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 24 lines
Quoted 11 lines
---
 hw/watchdog/wdt_diag288.c | 2 --
 1 file changed, 2 deletions(-)
hw/watchdog/wdt_diag288.c +0 -0
index 71a945f0bd..4c4b6a6ab7 100644

hw/watchdog/wdt_diag288.c line 17

Quoted 4 lines
hw/watchdog/wdt_diag288.c +0 -1
@@ -14,12 +14,10 @@
 #include "qemu/osdep.h"
 #include "sysemu/reset.h"
 #include "sysemu/watchdog.h"
-#include "hw/sysbus.h"

OK

hw/watchdog/wdt_diag288.c line 22

Quoted 5 lines
hw/watchdog/wdt_diag288.c +0 -1
 #include "qemu/timer.h"
 #include "hw/watchdog/wdt_diag288.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
-#include "qemu/module.h"
Quoted 7 lines

Cc'ing Markus because of:

commit 0b8fa32f551e863bb548a11394239239270dd3dc

Author: Markus Armbruster <[email protected]>
Date:   Thu May 23 16:35:07 2019 +0200

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Quoted 4 lines
Quoted 4 lines
hw/watchdog/wdt_diag288.c +0 -0
 static WatchdogTimerModel model = {
     .wdt_name = TYPE_WDT_DIAG288,
 
#4 lore raw
Quoted 14 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 6 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Quoted 5 lines
Quoted 3 lines

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

thanks
-- PMM

#5 lore raw
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 6 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

So what's now our expectation here? Should every file that uses type_init() also include module.h ? That's IMHO not very intuitive...
Or are we fine that type_init() is provided by qom/object.h which needs to be pulled in by every device sooner or later anyway?

Thomas

#6 lore raw
Quoted 22 lines · Thomas Huth
Quoted 21 lines · Peter Maydell
Quoted 19 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 9 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Quoted 7 lines
Quoted 2 lines

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

So what's now our expectation here? Should every file that uses type_init() also include module.h ? That's IMHO not very intuitive...
Or are we fine that type_init() is provided by qom/object.h which needs to be pulled in by every device sooner or later anyway?

I think it's okay to rely on indirect inclusion.

#7 lore raw
Quoted 27 lines · On Mon, 23 Nov 2020 11:47:25 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 25 lines · Thomas Huth
Quoted 23 lines · Peter Maydell
Quoted 14 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 6 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Quoted 5 lines
Quoted 3 lines

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

Quoted 6 lines
Quoted 4 lines

So what's now our expectation here? Should every file that uses type_init() also include module.h ? That's IMHO not very intuitive...
Or are we fine that type_init() is provided by qom/object.h which needs to be pulled in by every device sooner or later anyway?

I think it's okay to rely on indirect inclusion.

So, what's the final verdict? Maybe just tweak the description?

"Neither sysbus.h nor module.h are required to compile this file. diag288 is not a sysbus device, and module.h (for type_init) is included eventually through qom/object.h."

#8 lore raw
Quoted 35 lines · Cornelia Huck
Quoted 32 lines · On Mon, 23 Nov 2020 11:47:25 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 29 lines · Thomas Huth
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 6 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

So what's now our expectation here? Should every file that uses type_init() also include module.h ? That's IMHO not very intuitive...
Or are we fine that type_init() is provided by qom/object.h which needs to be pulled in by every device sooner or later anyway?

Quoted 7 lines
Quoted 1 line

I think it's okay to rely on indirect inclusion.

So, what's the final verdict? Maybe just tweak the description?

"Neither sysbus.h nor module.h are required to compile this file. diag288 is not a sysbus device, and module.h (for type_init) is included eventually through qom/object.h."

Yes, I think that's the way to go. Could you update the description when picking up the patch, or shall I send a v2?

Thomas

#10 lore raw
In reply to Thomas Huth
Quoted 14 lines · On Wed, 18 Nov 2020 10:03:44 +0100 Thomas Huth <[email protected]> wrote:

Both headers, sysbus.h and module.h, are not required to compile this file.

---
 hw/watchdog/wdt_diag288.c | 2 --
 1 file changed, 2 deletions(-)
hw/watchdog/wdt_diag288.c +0 -0
index 71a945f0bd..4c4b6a6ab7 100644
@@ -14,12 +14,10 @@
 #include "qemu/osdep.h"
 #include "sysemu/reset.h"

hw/watchdog/wdt_diag288.c line 23

Quoted 10 lines
hw/watchdog/wdt_diag288.c +0 -2
 #include "sysemu/watchdog.h"
-#include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "hw/watchdog/wdt_diag288.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
-#include "qemu/module.h"
 
 static WatchdogTimerModel model = {
     .wdt_name = TYPE_WDT_DIAG288,

Thanks, applied.

#9 lore raw
In reply to Thomas Huth
Quoted 38 lines · On Mon, 23 Nov 2020 19:41:40 +0100 Thomas Huth <[email protected]> wrote:
Quoted 37 lines · Cornelia Huck
Quoted 33 lines · On Mon, 23 Nov 2020 11:47:25 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 22 lines · Thomas Huth
Quoted 21 lines · Peter Maydell
Quoted 19 lines · Markus Armbruster
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Thomas Huth

Both headers, sysbus.h and module.h, are not required to compile this file.

module.h is: it defines type_init().

Quoted 9 lines
Quoted 5 lines

#include "qemu/timer.h"
#include "hw/watchdog/wdt_diag288.h"
#include "migration/vmstate.h"
#include "qemu/log.h"
-#include "qemu/module.h"

Cc'ing Markus because of:

Include qemu/module.h where needed, drop it from qemu-common.h

If it still compiles and links, it must get it via some other header.

Quoted 7 lines
Quoted 2 lines

Yes: wdt_diag288.c -> include/hw/watchdog/wdt_diag288.h ->
include/qom/object.h -> include/qemu/module.h

So what's now our expectation here? Should every file that uses type_init() also include module.h ? That's IMHO not very intuitive...
Or are we fine that type_init() is provided by qom/object.h which needs to be pulled in by every device sooner or later anyway?

I think it's okay to rely on indirect inclusion.

Quoted 8 lines
Quoted 5 lines

So, what's the final verdict? Maybe just tweak the description?

"Neither sysbus.h nor module.h are required to compile this file. diag288 is not a sysbus device, and module.h (for type_init) is included eventually through qom/object.h."

Yes, I think that's the way to go. Could you update the description when picking up the patch, or shall I send a v2?

No need for a v2, I queued it to s390-next with an updated description.