diff mbox

Fix compilation warning due to missing header for sigaction

Message ID 1306981290-17308-1-git-send-email-cerbere@gmail.com
State New
Headers show

Commit Message

Alexandre Raymond June 2, 2011, 2:21 a.m. UTC
Fix the following warning by including signal.h directly in qemu-common.h
----8<----
iohandler.c: In function ‘qemu_init_child_watch’:
iohandler.c:172: warning: implicit declaration of function ‘sigaction’
iohandler.c:172: warning: nested extern declaration of ‘sigaction’
----8<----

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 qemu-common.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Andreas Färber June 2, 2011, 10:13 a.m. UTC | #1
Am 02.06.2011 um 04:21 schrieb Alexandre Raymond:

> Fix the following warning by including signal.h directly in qemu- 
> common.h
> ----8<----
> iohandler.c: In function ‘qemu_init_child_watch’:
> iohandler.c:172: warning: implicit declaration of function ‘sigaction’
> iohandler.c:172: warning: nested extern declaration of ‘sigaction’
> ----8<----
>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>

Tested-by: Andreas Färber <andreas.faerber@web.de>

Why in qemu-common.h and not in iohandler.c though?
If we put it into qemu-common.h, you should remove other inclusions of  
signal.h.

Andreas

> ---
> qemu-common.h |    1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-common.h b/qemu-common.h
> index b851b20..39fabc9 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -39,6 +39,7 @@ typedef struct Monitor Monitor;
> #include <sys/stat.h>
> #include <sys/time.h>
> #include <assert.h>
> +#include <signal.h>
>
> #ifdef _WIN32
> #include "qemu-os-win32.h"
> -- 
> 1.7.5
>
>
Alexandre Raymond June 2, 2011, 1:27 p.m. UTC | #2
On Thu, Jun 2, 2011 at 6:13 AM, Andreas Färber <andreas.faerber@web.de> wrote:
> Am 02.06.2011 um 04:21 schrieb Alexandre Raymond:
>
>> Fix the following warning by including signal.h directly in qemu-common.h
>> ----8<----
>> iohandler.c: In function ‘qemu_init_child_watch’:
>> iohandler.c:172: warning: implicit declaration of function ‘sigaction’
>> iohandler.c:172: warning: nested extern declaration of ‘sigaction’
>> ----8<----
>>
>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>
> Tested-by: Andreas Färber <andreas.faerber@web.de>
>
> Why in qemu-common.h and not in iohandler.c though?
> If we put it into qemu-common.h, you should remove other inclusions of
> signal.h.

Well, I was simply following Anthony's advice from "[PATCH] #include
cleanlines" : "The idea behind qemu-common.h is to avoid direct
includes to help with portability."

Alexandre
Stefan Hajnoczi June 2, 2011, 10:44 p.m. UTC | #3
On Thu, Jun 2, 2011 at 3:21 AM, Alexandre Raymond <cerbere@gmail.com> wrote:
> Fix the following warning by including signal.h directly in qemu-common.h
> ----8<----
> iohandler.c: In function ‘qemu_init_child_watch’:
> iohandler.c:172: warning: implicit declaration of function ‘sigaction’
> iohandler.c:172: warning: nested extern declaration of ‘sigaction’
> ----8<----
>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
>  qemu-common.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Stefan
Alexandre Raymond June 2, 2011, 10:55 p.m. UTC | #4
Thanks Stefan,

Should I send a follow-up patch to remove signal.h wherever
qemu-common.h is already included?

Alexandre

On Thu, Jun 2, 2011 at 6:44 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Thu, Jun 2, 2011 at 3:21 AM, Alexandre Raymond <cerbere@gmail.com> wrote:
>> Fix the following warning by including signal.h directly in qemu-common.h
>> ----8<----
>> iohandler.c: In function ‘qemu_init_child_watch’:
>> iohandler.c:172: warning: implicit declaration of function ‘sigaction’
>> iohandler.c:172: warning: nested extern declaration of ‘sigaction’
>> ----8<----
>>
>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>> ---
>>  qemu-common.h |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> Thanks, applied to the trivial patches tree:
> http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches
>
> Stefan
>
Stefan Hajnoczi June 2, 2011, 11:04 p.m. UTC | #5
On Thu, Jun 2, 2011 at 11:55 PM, Alexandre Raymond <cerbere@gmail.com> wrote:
> Should I send a follow-up patch to remove signal.h wherever
> qemu-common.h is already included?

Yes, please.

I didn't know that qemu-common.h pulls in system headers so users
don't need to, I always figured .c files should include what they use.
 But if we use this approach we might as well update the codebase.

Stefan
diff mbox

Patch

diff --git a/qemu-common.h b/qemu-common.h
index b851b20..39fabc9 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -39,6 +39,7 @@  typedef struct Monitor Monitor;
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <assert.h>
+#include <signal.h>
 
 #ifdef _WIN32
 #include "qemu-os-win32.h"