Skip to contentSkip to conversation

bswap: fix compiler warning

PATCH Superseded Alexey Kardashevskiy 5 participants 12 messages Apr 12, 2013 – Apr 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bswap: fix compiler warning

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                 from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                 from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
 include/qemu/bswap.h |    2 ++
 1 file changed, 2 insertions(+)
include/qemu/bswap.h +2 -0
index d3af35d..d50de0d 100644
@@ -1,6 +1,8 @@
 #ifndef BSWAP_H
 #define BSWAP_H
 
+#include <string.h>
+
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alexey Kardashevskiy

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                 from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                 from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:
Quoted 8 lines

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
 include/qemu/bswap.h |    2 ++
 1 file changed, 2 insertions(+)
#2 lore raw
In reply to Alexey Kardashevskiy

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 25 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                 from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                 from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
 include/qemu/bswap.h |    2 ++
 1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644

include/qemu/bswap.h line 8

Quoted 8 lines
include/qemu/bswap.h +2 -0
@@ -1,6 +1,8 @@
 #ifndef BSWAP_H
 #define BSWAP_H
 
+#include <string.h>
+
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw
Quoted 29 lines · Andreas Färber

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 28 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                  from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                  from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
  include/qemu/bswap.h |    2 ++
  1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644
@@ -1,6 +1,8 @@
  #ifndef BSWAP_H
  #define BSWAP_H
 
Quoted 8 lines

include/qemu/bswap.h line 8

Quoted 5 lines
include/qemu/bswap.h +2 -0
+#include <string.h>
+
  #include "config-host.h"
  #include <inttypes.h>
  #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

I have no idea :)
I just tried to do cross compilation and hit this one. And it is not the only problem, I hit another one but this is against gcc or libc, have not discovered it yet.

Signature · 1 line
Alexey
#4 lore raw
In reply to Andreas Färber
Quoted 29 lines · Andreas Färber

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 28 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                 from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                 from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
 include/qemu/bswap.h |    2 ++
 1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644
@@ -1,6 +1,8 @@
 #ifndef BSWAP_H
 #define BSWAP_H
 
Quoted 8 lines

include/qemu/bswap.h line 8

Quoted 5 lines
include/qemu/bswap.h +2 -0
+#include <string.h>
+
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

Yeah, it probably shouldn't go above the config header. Otherwise it's the right thing.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw

Am 12.04.2013 18:47, schrieb David Gibson:

Quoted 37 lines · Andreas Färber
Quoted 29 lines

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 28 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                 from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                 from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
 include/qemu/bswap.h |    2 ++
 1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644
@@ -1,6 +1,8 @@
 #ifndef BSWAP_H
 #define BSWAP_H
 
Quoted 7 lines

include/qemu/bswap.h line 8

Quoted 5 lines
include/qemu/bswap.h +2 -0
+#include <string.h>
+
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

Quoted 2 lines

Yeah, it probably shouldn't go above the config header. Otherwise it's the right thing.

If string.h went directly after limits.h, we'd even preserve the alphabetic order of the system headers :-)

#6 lore raw
Quoted 38 lines · Stefan Weil

Am 12.04.2013 18:47, schrieb David Gibson:

Quoted 37 lines · Andreas Färber
Quoted 36 lines

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 25 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64), the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,

                  from /home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
                  from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:

/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning: incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
  include/qemu/bswap.h |    2 ++
  1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644

include/qemu/bswap.h line 8

Quoted 8 lines
include/qemu/bswap.h +2 -0
@@ -1,6 +1,8 @@
  #ifndef BSWAP_H
  #define BSWAP_H
 
+#include <string.h>
+
  #include "config-host.h"
  #include <inttypes.h>
  #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

Quoted 5 lines
Quoted 2 lines

Yeah, it probably shouldn't go above the config header. Otherwise it's the right thing.

If string.h went directly after limits.h, we'd even preserve the alphabetic order of the system headers :-)

Ah. Misunderstood the original question :) Do I need to repost it?

Signature · 1 line
Alexey
#7 lore raw

Am 12.04.2013 22:23, schrieb Alexey Kardashevskiy:

Quoted 46 lines · Stefan Weil
Quoted 45 lines

Am 12.04.2013 18:47, schrieb David Gibson:

Quoted 44 lines · Andreas Färber
Quoted 43 lines

Am 12.04.2013 03:41, schrieb Alexey Kardashevskiy:

Quoted 32 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to
include it in some configuration such as cross compiling for powerpc64
on x86_64 machine (gcc 4.6.3 from ftp.kernel.org, headers/libs from FC18/ppc64),
the example warning is below.

The patch explicitly includes string.h.

CC ppc64-softmmu/hw/virtio/virtio.o
In file included from /home/alexey/qemu/include/libfdt_env.h:22:0,
from
/home/alexey/qemu/../lib4qemu/usr/include/libfdt.h:54,
from /home/alexey/qemu/hw/nvram/spapr_nvram.c:25:
/home/alexey/qemu/include/qemu/bswap.h: In function 'lduw_p':
/home/alexey/qemu/include/qemu/bswap.h:244:5: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] /home/alexey/qemu/include/qemu/bswap.h:244:5: warning:
incompatible implicit declaration of built-in function 'memcpy' [enabled by default]

---
  include/qemu/bswap.h |    2 ++
  1 file changed, 2 insertions(+)
include/qemu/bswap.h +0 -0
index d3af35d..d50de0d 100644

include/qemu/bswap.h line 8

Quoted 8 lines
include/qemu/bswap.h +2 -0
@@ -1,6 +1,8 @@
  #ifndef BSWAP_H
  #define BSWAP_H
 
+#include <string.h>
+
  #include "config-host.h"
  #include <inttypes.h>
  #include <limits.h>

Including string.h is certainly the right thing to do, but why do you single it out first?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yeah, it probably shouldn't go above the config header. Otherwise it's the right thing.

If string.h went directly after limits.h, we'd even preserve the alphabetic order of the system headers :-)

Ah. Misunderstood the original question :) Do I need to repost it?

Yes, please - I think that would be good. You can also cc your patch to [email protected], so it will be committed as a trivial patch.

#8 lore raw

PATCH v2 1/1 bswap: fix compiler warning

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine.

The patch explicitly includes string.h.

v2:
* #include statement moved to the right place

---
 include/qemu/bswap.h |    1 +
 1 file changed, 1 insertion(+)
include/qemu/bswap.h +1 -0
index d3af35d..14a5f65 100644
@@ -4,6 +4,7 @@
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>
+#include <string.h>
 #include "fpu/softfloat.h"
 
 #ifdef CONFIG_MACHINE_BSWAP_H
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#9 lore raw
Quoted 11 lines · Alexey Kardashevskiy

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine.

The patch explicitly includes string.h.

v2:
* #include statement moved to the right place

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on v2 1/1
#10 lore raw
In reply to Alexey Kardashevskiy

Am 15.04.2013 03:47, schrieb Alexey Kardashevskiy:

Quoted 20 lines

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine.

The patch explicitly includes string.h.

v2:
* #include statement moved to the right place

---
 include/qemu/bswap.h |    1 +
 1 file changed, 1 insertion(+)
include/qemu/bswap.h +0 -0
index d3af35d..14a5f65 100644

include/qemu/bswap.h line 10

Quoted 7 lines
include/qemu/bswap.h +1 -0
@@ -4,6 +4,7 @@
 #include "config-host.h"
 #include <inttypes.h>
 #include <limits.h>
+#include <string.h>
 #include "fpu/softfloat.h"
 
 #ifdef CONFIG_MACHINE_BSWAP_H

Thanks,

Normally the change log does not go into the commit message but I'm sure Stefan can fix that. :)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#11 lore raw
In reply to Alexey Kardashevskiy
Quoted 6 lines · Alexey Kardashevskiy

The bswap functions use memcpy but the bswap.h header itself does not seem to include it in some configuration such as cross compiling for powerpc64 on x86_64 machine.

The patch explicitly includes string.h.

Quoted 8 lines

v2:
* #include statement moved to the right place

---
 include/qemu/bswap.h |    1 +
 1 file changed, 1 insertion(+)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan