Skip to contentSkip to conversation

qga/channel-posix.c: Explicitly include string.h

PATCH Applied Peter Maydell 4 participants 6 messages Jan 7, 2013 – Jan 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga/channel-posix.c: Explicitly include string.h

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

---
I assume under Linux these are implicitly dragged in via one of the other headers.

 qga/channel-posix.c | 1 +
 1 file changed, 1 insertion(+)
qga/channel-posix.c +1 -0
index d4fd628..ca9e4aa 100644
@@ -4,6 +4,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdlib.h>
+#include <string.h>
 #include "qemu/osdep.h"
 #include "qemu/sockets.h"
 #include "qga/channel.h"
Signature · 1 line
1.7.11.4
#1 lore raw

Am 07.01.2013 18:29, schrieb Peter Maydell:

Quoted 17 lines

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

---
I assume under Linux these are implicitly dragged in via one of the other headers.

  qga/channel-posix.c | 1 +
  1 file changed, 1 insertion(+)
qga/channel-posix.c +0 -0
index d4fd628..ca9e4aa 100644

qga/channel-posix.c line 10

Quoted 7 lines
qga/channel-posix.c +1 -0
@@ -4,6 +4,7 @@
  #include<unistd.h>
  #include<fcntl.h>
  #include<stdlib.h>
+#include<string.h>
  #include "qemu/osdep.h"
  #include "qemu/sockets.h"
  #include "qga/channel.h"

Better: include qemu-common.h first and remove all three standard includes.

- Stefan

#2 lore raw
Quoted 7 lines · Stefan Weil

Am 07.01.2013 18:29, schrieb Peter Maydell:

Quoted 2 lines

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

Better: include qemu-common.h first and remove all three standard includes.

This would be reversing direction from commit 4d4922c33... I took the commit message in that commit to imply that we shouldn't be including qemu-common.h for standalone executables like qga.

-- PMM

#3 lore raw
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Stefan Weil

Am 07.01.2013 18:29, schrieb Peter Maydell:

Quoted 2 lines

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

Quoted 7 lines
Quoted 2 lines

Better: include qemu-common.h first and remove all three standard includes.

This would be reversing direction from commit 4d4922c33... I took the commit message in that commit to imply that we shouldn't be including qemu-common.h for standalone executables like qga.

Including qemu-common.h from .c files is OK, although I wouldn't do that in this specific case (I would include string.h instead).

The problem with qemu-common.h is when it is included by header files, because qemu-common.h includes lots of other headers, easily leading to circular header dependencies.

Signature · 1 line
Eduardo
Reviewed-by
#4 lore raw
Quoted 18 lines · Peter Maydell
Quoted 6 lines · Stefan Weil
Quoted 4 lines

Am 07.01.2013 18:29, schrieb Peter Maydell:

Quoted 2 lines

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

Quoted 7 lines
Quoted 2 lines

Better: include qemu-common.h first and remove all three standard includes.

This would be reversing direction from commit 4d4922c33... I took the commit message in that commit to imply that we shouldn't be including qemu-common.h for standalone executables like qga.

Including qemu-common.h from .c files is OK, although I wouldn't do that in this specific case (I would include string.h instead).

Quoted 7 lines

The problem with qemu-common.h is when it is included by header files, because qemu-common.h includes lots of other headers, easily leading to circular header dependencies.

--
Eduardo

I just noticed that on my Linux host qemu-common.h is no longer included indirectly (it was with earlier revisions of QEMU).

Therefore the patch is ok.

#5 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

Explicitly include string.h to avoid warnings under MacOS X/clang about implicit declarations of strerror() and strlen().

---
I assume under Linux these are implicitly dragged in via one of the other headers.

 qga/channel-posix.c | 1 +
 1 file changed, 1 insertion(+)

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

Stefan