[Qemu-devel] [PATCH 10/15] range: Remove Range from "qemu/typedefs.h"

Philippe Mathieu-Daudé posted 15 patches 7 years ago
Maintainers: "Philippe Mathieu-Daudé" <philmd@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Ben Warren <ben@skyportsystems.com>, Igor Mammedov <imammedo@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Laszlo Ersek <lersek@redhat.com>, Alistair Francis <alistair@alistair23.me>, Peter Crosthwaite <crosthwaite.peter@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Xiao Guangrong <xiaoguangrong.eric@gmail.com>, John Snow <jsnow@redhat.com>
There is a newer version of this series
[Qemu-devel] [PATCH 10/15] range: Remove Range from "qemu/typedefs.h"
Posted by Philippe Mathieu-Daudé 7 years ago
Range is only used in "hw/pci-host/q35.h" in the MCHPCIState, and
in "hw/pci/pci.h" by pci_bus_get_w64_range().  Let them include
"qemu/range.h" directly to simplify "qemu/typedefs.h".

To clean "qemu/typedefs.h", move the declaration to "qemu/range.h"
(removing the forward declaration).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/hw/pci-host/q35.h | 1 +
 include/hw/pci/pci.h      | 1 +
 include/qemu/range.h      | 4 ++--
 include/qemu/typedefs.h   | 1 -
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index 8f4ddde393..236ff008c9 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -22,6 +22,7 @@
 #ifndef HW_Q35_H
 #define HW_Q35_H
 
+#include "qemu/range.h"
 #include "hw/hw.h"
 #include "hw/isa/isa.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index d87f5f93e9..f9c020fd98 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -1,6 +1,7 @@
 #ifndef QEMU_PCI_H
 #define QEMU_PCI_H
 
+#include "qemu/range.h"
 #include "hw/qdev.h"
 #include "exec/memory.h"
 #include "sysemu/dma.h"
diff --git a/include/qemu/range.h b/include/qemu/range.h
index 7e75f4e655..aaa09c8306 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -29,7 +29,7 @@
  * - Ranges must not wrap around 0, but can include UINT64_MAX.
  */
 
-struct Range {
+typedef struct Range {
     /*
      * Do not access members directly, use the functions!
      * A non-empty range has @lob <= @upb.
@@ -37,7 +37,7 @@ struct Range {
      */
     uint64_t lob;        /* inclusive lower bound */
     uint64_t upb;        /* inclusive upper bound */
-};
+} Range;
 
 static inline void range_invariant(const Range *range)
 {
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 5e9a070ff3..fb9f29d892 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -97,7 +97,6 @@ typedef struct QNum QNum;
 typedef struct QObject QObject;
 typedef struct QString QString;
 typedef struct RAMBlock RAMBlock;
-typedef struct Range Range;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
-- 
2.17.2


Re: [Qemu-devel] [PATCH 10/15] range: Remove Range from "qemu/typedefs.h"
Posted by Thomas Huth 7 years ago
On 2019-01-11 15:08, Philippe Mathieu-Daudé wrote:
> Range is only used in "hw/pci-host/q35.h" in the MCHPCIState, and
> in "hw/pci/pci.h" by pci_bus_get_w64_range().  Let them include
> "qemu/range.h" directly to simplify "qemu/typedefs.h".
> 
> To clean "qemu/typedefs.h", move the declaration to "qemu/range.h"
> (removing the forward declaration).

Since Range seems to be meant as a common type (i.e. not specific to any
device like the other typedefs that you move in this series), I think
it's should be OK if this resides in typedefs.h ?

 Thomas

Re: [Qemu-devel] [PATCH 10/15] range: Remove Range from "qemu/typedefs.h"
Posted by Philippe Mathieu-Daudé 7 years ago
On 1/14/19 9:56 AM, Thomas Huth wrote:
> On 2019-01-11 15:08, Philippe Mathieu-Daudé wrote:
>> Range is only used in "hw/pci-host/q35.h" in the MCHPCIState, and
>> in "hw/pci/pci.h" by pci_bus_get_w64_range().  Let them include
>> "qemu/range.h" directly to simplify "qemu/typedefs.h".
>>
>> To clean "qemu/typedefs.h", move the declaration to "qemu/range.h"
>> (removing the forward declaration).
> 
> Since Range seems to be meant as a common type (i.e. not specific to any
> device like the other typedefs that you move in this series), I think
> it's should be OK if this resides in typedefs.h ?

My idea was to clean files not very used, and this one is only used
twice. Why rebuild the World if someone add another function or fix a
typo in "qemu/range.h"?
I agree this typedef is meant for global use however.

Since I don't have a strong opinion, I'll drop it (until someone else
respond to this thread).