diff mbox series

[v2,6/7] misc: ensure qemu/osdep.h is included in all .c files

Message ID 20220704152303.760983-7-berrange@redhat.com
State New
Headers show
Series tests: introduce a tree-wide code style checking facility | expand

Commit Message

Daniel P. Berrangé July 4, 2022, 3:23 p.m. UTC
A few files relied on qemu/osdep.h being included via a common
header. Another file didn't need it because it was actually an
included file, so ought to have been named .c.inc

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 bsd-user/arm/signal.c                 | 2 ++
 bsd-user/arm/target_arch_cpu.c        | 3 +++
 bsd-user/{elfcore.c => elfcore.c.inc} | 0
 bsd-user/elfload.c                    | 2 +-
 bsd-user/freebsd/os-sys.c             | 2 ++
 bsd-user/i386/signal.c                | 2 ++
 bsd-user/qemu.h                       | 1 -
 bsd-user/x86_64/signal.c              | 2 ++
 crypto/rsakey.c                       | 1 +
 qga/cutils.c                          | 2 ++
 10 files changed, 15 insertions(+), 2 deletions(-)
 rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)

Comments

Warner Losh July 4, 2022, 3:38 p.m. UTC | #1
On Mon, Jul 4, 2022 at 9:28 AM Daniel P. Berrangé <berrange@redhat.com>
wrote:

> A few files relied on qemu/osdep.h being included via a common
> header. Another file didn't need it because it was actually an
> included file, so ought to have been named .c.inc
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  bsd-user/arm/signal.c                 | 2 ++
>  bsd-user/arm/target_arch_cpu.c        | 3 +++
>  bsd-user/{elfcore.c => elfcore.c.inc} | 0
>  bsd-user/elfload.c                    | 2 +-
>  bsd-user/freebsd/os-sys.c             | 2 ++
>  bsd-user/i386/signal.c                | 2 ++
>  bsd-user/qemu.h                       | 1 -
>  bsd-user/x86_64/signal.c              | 2 ++
>  crypto/rsakey.c                       | 1 +
>  qga/cutils.c                          | 2 ++
>  10 files changed, 15 insertions(+), 2 deletions(-)
>  rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)
>

The change to bsd-user is fine, though will cause many ripples in the
upstream
branch when I merge it. The ripples likely are worth it in the long run,
and knowing
they are coming and helps me prepare the tree for the merge.

It also reminds me that once I'm done upstreaming, there's likely benefit
from having
a common elf loader / core generator as much of this code is copied from
linux-user
with the qemu style layered on top....

Reviewed-by: Warner Losh <imp@bsdimp.com>


> diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c
> index 2b1dd745d1..eca20ac4d7 100644
> --- a/bsd-user/arm/signal.c
> +++ b/bsd-user/arm/signal.c
> @@ -17,6 +17,8 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include "qemu/osdep.h"
> +
>  #include "qemu.h"
>
>  /*
> diff --git a/bsd-user/arm/target_arch_cpu.c
> b/bsd-user/arm/target_arch_cpu.c
> index 02bf9149d5..186cf43fb9 100644
> --- a/bsd-user/arm/target_arch_cpu.c
> +++ b/bsd-user/arm/target_arch_cpu.c
> @@ -16,6 +16,9 @@
>   *  You should have received a copy of the GNU General Public License
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
> +
> +#include "qemu/osdep.h"
> +
>  #include "target_arch.h"
>
>  void target_cpu_set_tls(CPUARMState *env, target_ulong newtls)
> diff --git a/bsd-user/elfcore.c b/bsd-user/elfcore.c.inc
> similarity index 100%
> rename from bsd-user/elfcore.c
> rename to bsd-user/elfcore.c.inc
> diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
> index f8edb22f2a..1717a454dc 100644
> --- a/bsd-user/elfload.c
> +++ b/bsd-user/elfload.c
> @@ -121,7 +121,7 @@ static void bswap_note(struct elf_note *en) { }
>
>  #endif /* ! BSWAP_NEEDED */
>
> -#include "elfcore.c"
> +#include "elfcore.c.inc"
>
>  /*
>   * 'copy_elf_strings()' copies argument/envelope strings from user
> diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
> index 309e27b9d6..1eab1be6f6 100644
> --- a/bsd-user/freebsd/os-sys.c
> +++ b/bsd-user/freebsd/os-sys.c
> @@ -17,6 +17,8 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include "qemu/osdep.h"
> +
>  #include "qemu.h"
>  #include "target_arch_sysarch.h"
>
> diff --git a/bsd-user/i386/signal.c b/bsd-user/i386/signal.c
> index 5dd975ce56..db5b774213 100644
> --- a/bsd-user/i386/signal.c
> +++ b/bsd-user/i386/signal.c
> @@ -17,6 +17,8 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include "qemu/osdep.h"
> +
>  #include "qemu.h"
>
>  /*
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index be6105385e..0ceecfb6df 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -17,7 +17,6 @@
>  #ifndef QEMU_H
>  #define QEMU_H
>
> -#include "qemu/osdep.h"
>  #include "cpu.h"
>  #include "qemu/units.h"
>  #include "exec/cpu_ldst.h"
> diff --git a/bsd-user/x86_64/signal.c b/bsd-user/x86_64/signal.c
> index c3875bc4c6..217f9ceb66 100644
> --- a/bsd-user/x86_64/signal.c
> +++ b/bsd-user/x86_64/signal.c
> @@ -16,6 +16,8 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include "qemu/osdep.h"
> +
>  #include "qemu.h"
>
>  /*
> diff --git a/crypto/rsakey.c b/crypto/rsakey.c
> index cc40e072f0..dcdbd9ec57 100644
> --- a/crypto/rsakey.c
> +++ b/crypto/rsakey.c
> @@ -19,6 +19,7 @@
>   *
>   */
>
> +#include "qemu/osdep.h"
>  #include "rsakey.h"
>
>  void qcrypto_akcipher_rsakey_free(QCryptoAkCipherRSAKey *rsa_key)
> diff --git a/qga/cutils.c b/qga/cutils.c
> index b8e142ef64..c53dd418c7 100644
> --- a/qga/cutils.c
> +++ b/qga/cutils.c
> @@ -2,6 +2,8 @@
>   * This work is licensed under the terms of the GNU GPL, version 2 or
> later.
>   * See the COPYING file in the top-level directory.
>   */
> +
> +#include "qemu/osdep.h"
>  #include "cutils.h"
>
>  #include "qapi/error.h"
> --
> 2.36.1
>
>
>
Daniel P. Berrangé July 4, 2022, 3:46 p.m. UTC | #2
On Mon, Jul 04, 2022 at 09:38:46AM -0600, Warner Losh wrote:
> On Mon, Jul 4, 2022 at 9:28 AM Daniel P. Berrangé <berrange@redhat.com>
> wrote:
> 
> > A few files relied on qemu/osdep.h being included via a common
> > header. Another file didn't need it because it was actually an
> > included file, so ought to have been named .c.inc
> >
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  bsd-user/arm/signal.c                 | 2 ++
> >  bsd-user/arm/target_arch_cpu.c        | 3 +++
> >  bsd-user/{elfcore.c => elfcore.c.inc} | 0
> >  bsd-user/elfload.c                    | 2 +-
> >  bsd-user/freebsd/os-sys.c             | 2 ++
> >  bsd-user/i386/signal.c                | 2 ++
> >  bsd-user/qemu.h                       | 1 -
> >  bsd-user/x86_64/signal.c              | 2 ++
> >  crypto/rsakey.c                       | 1 +
> >  qga/cutils.c                          | 2 ++
> >  10 files changed, 15 insertions(+), 2 deletions(-)
> >  rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)
> >
> 
> The change to bsd-user is fine, though will cause many ripples in the
> upstream
> branch when I merge it. The ripples likely are worth it in the long run,
> and knowing
> they are coming and helps me prepare the tree for the merge.

If you prefer to delay these changes I don't mind. It just means that
it would need a 'bsd-user/.*' exclude rule in the next patch to
temporarily skip this chck for bsd-user code.

> It also reminds me that once I'm done upstreaming, there's likely benefit
> from having
> a common elf loader / core generator as much of this code is copied from
> linux-user
> with the qemu style layered on top....
> 
> Reviewed-by: Warner Losh <imp@bsdimp.com>


With regards,
Daniel
Warner Losh July 4, 2022, 4:08 p.m. UTC | #3
On Mon, Jul 4, 2022, 9:46 AM Daniel P. Berrangé <berrange@redhat.com> wrote:

> On Mon, Jul 04, 2022 at 09:38:46AM -0600, Warner Losh wrote:
> > On Mon, Jul 4, 2022 at 9:28 AM Daniel P. Berrangé <berrange@redhat.com>
> > wrote:
> >
> > > A few files relied on qemu/osdep.h being included via a common
> > > header. Another file didn't need it because it was actually an
> > > included file, so ought to have been named .c.inc
> > >
> > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > > ---
> > >  bsd-user/arm/signal.c                 | 2 ++
> > >  bsd-user/arm/target_arch_cpu.c        | 3 +++
> > >  bsd-user/{elfcore.c => elfcore.c.inc} | 0
> > >  bsd-user/elfload.c                    | 2 +-
> > >  bsd-user/freebsd/os-sys.c             | 2 ++
> > >  bsd-user/i386/signal.c                | 2 ++
> > >  bsd-user/qemu.h                       | 1 -
> > >  bsd-user/x86_64/signal.c              | 2 ++
> > >  crypto/rsakey.c                       | 1 +
> > >  qga/cutils.c                          | 2 ++
> > >  10 files changed, 15 insertions(+), 2 deletions(-)
> > >  rename bsd-user/{elfcore.c => elfcore.c.inc} (100%)
> > >
> >
> > The change to bsd-user is fine, though will cause many ripples in the
> > upstream
> > branch when I merge it. The ripples likely are worth it in the long run,
> > and knowing
> > they are coming and helps me prepare the tree for the merge.
>
> If you prefer to delay these changes I don't mind. It just means that
> it would need a 'bsd-user/.*' exclude rule in the next patch to
> temporarily skip this chck for bsd-user code.
>

No. Go ahead. I know I need to do something when I do the next merge.
And it shouldn't be a big deal to do now, otherwise I'll forget...

Warner


> It also reminds me that once I'm done upstreaming, there's likely benefit
> > from having
> > a common elf loader / core generator as much of this code is copied from
> > linux-user
> > with the qemu style layered on top....
> >
> > Reviewed-by: Warner Losh <imp@bsdimp.com>
>
>
> With regards,
> Daniel
> --
> |: https://berrange.com      -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-
> https://www.instagram.com/dberrange :|
>
>
diff mbox series

Patch

diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c
index 2b1dd745d1..eca20ac4d7 100644
--- a/bsd-user/arm/signal.c
+++ b/bsd-user/arm/signal.c
@@ -17,6 +17,8 @@ 
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
+
 #include "qemu.h"
 
 /*
diff --git a/bsd-user/arm/target_arch_cpu.c b/bsd-user/arm/target_arch_cpu.c
index 02bf9149d5..186cf43fb9 100644
--- a/bsd-user/arm/target_arch_cpu.c
+++ b/bsd-user/arm/target_arch_cpu.c
@@ -16,6 +16,9 @@ 
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+
+#include "qemu/osdep.h"
+
 #include "target_arch.h"
 
 void target_cpu_set_tls(CPUARMState *env, target_ulong newtls)
diff --git a/bsd-user/elfcore.c b/bsd-user/elfcore.c.inc
similarity index 100%
rename from bsd-user/elfcore.c
rename to bsd-user/elfcore.c.inc
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index f8edb22f2a..1717a454dc 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -121,7 +121,7 @@  static void bswap_note(struct elf_note *en) { }
 
 #endif /* ! BSWAP_NEEDED */
 
-#include "elfcore.c"
+#include "elfcore.c.inc"
 
 /*
  * 'copy_elf_strings()' copies argument/envelope strings from user
diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
index 309e27b9d6..1eab1be6f6 100644
--- a/bsd-user/freebsd/os-sys.c
+++ b/bsd-user/freebsd/os-sys.c
@@ -17,6 +17,8 @@ 
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
+
 #include "qemu.h"
 #include "target_arch_sysarch.h"
 
diff --git a/bsd-user/i386/signal.c b/bsd-user/i386/signal.c
index 5dd975ce56..db5b774213 100644
--- a/bsd-user/i386/signal.c
+++ b/bsd-user/i386/signal.c
@@ -17,6 +17,8 @@ 
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
+
 #include "qemu.h"
 
 /*
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index be6105385e..0ceecfb6df 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -17,7 +17,6 @@ 
 #ifndef QEMU_H
 #define QEMU_H
 
-#include "qemu/osdep.h"
 #include "cpu.h"
 #include "qemu/units.h"
 #include "exec/cpu_ldst.h"
diff --git a/bsd-user/x86_64/signal.c b/bsd-user/x86_64/signal.c
index c3875bc4c6..217f9ceb66 100644
--- a/bsd-user/x86_64/signal.c
+++ b/bsd-user/x86_64/signal.c
@@ -16,6 +16,8 @@ 
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
+
 #include "qemu.h"
 
 /*
diff --git a/crypto/rsakey.c b/crypto/rsakey.c
index cc40e072f0..dcdbd9ec57 100644
--- a/crypto/rsakey.c
+++ b/crypto/rsakey.c
@@ -19,6 +19,7 @@ 
  *
  */
 
+#include "qemu/osdep.h"
 #include "rsakey.h"
 
 void qcrypto_akcipher_rsakey_free(QCryptoAkCipherRSAKey *rsa_key)
diff --git a/qga/cutils.c b/qga/cutils.c
index b8e142ef64..c53dd418c7 100644
--- a/qga/cutils.c
+++ b/qga/cutils.c
@@ -2,6 +2,8 @@ 
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+
+#include "qemu/osdep.h"
 #include "cutils.h"
 
 #include "qapi/error.h"