qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction()
Date: Tue, 15 May 2018 16:40:34 -0500	[thread overview]
Message-ID: <df368c37-3258-d2cb-9a4d-942f1b4af743@redhat.com> (raw)
In-Reply-To: <aa1f3380-2a5c-b14b-92c1-2c0f74a07220@amsat.org>

On 05/15/2018 03:53 PM, Philippe Mathieu-Daudé wrote:
> On 05/15/2018 03:27 PM, Peter Maydell wrote:
>> Coverity points out that in the user-only version of cpu_abort() we
>> call sigaction() with a partially initialized struct sigaction
>> (CID 1005351). Correct the omission.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>   exec.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/exec.c b/exec.c
>> index ffa1099547..bd8833fc9d 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -1124,6 +1124,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
>>           struct sigaction act;
> 
> I'd have used the more generic:
> 
>             struct sigaction act = { };

That's a gcc/clang extension (although we have used it before, 
particularly to shut up buggy versions of clang); better is:

struct sigaction act = { 0 };

if that doesn't trigger the clang bug.

> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
>>           sigfillset(&act.sa_mask);
>>           act.sa_handler = SIG_DFL;

The sigfillset() has to be done after initialization, but you could also 
use:

struct sigaction act = {
   .sa_handler = SIG_DFL;
};
sigfillset(&act.sa_mask);

as a way to zero-initialize all other fields.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-05-15 21:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 18:27 [Qemu-devel] [PATCH] exec.c: Initialize sa_flags passed to sigaction() Peter Maydell
2018-05-15 19:24 ` Alex Bennée
2018-05-15 20:53 ` Philippe Mathieu-Daudé
2018-05-15 21:40   ` Eric Blake [this message]
2018-05-16  7:25 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df368c37-3258-d2cb-9a4d-942f1b4af743@redhat.com \
    --to=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).