From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Alexander Graf <agraf@suse.de>, Gerd Hoffmann <kraxel@redhat.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RESEND 3/3] qga: fix compiler warnings (clang 5)
Date: Fri, 7 Apr 2017 18:31:24 -0300 [thread overview]
Message-ID: <d3bdae1a-2a7d-57d2-bf3c-80b05130e530@amsat.org> (raw)
In-Reply-To: <149021773050.3910.449421368071627004@loki>
Hi Michael,
On 03/22/2017 06:22 PM, Michael Roth wrote:
> Quoting Philippe Mathieu-Daudé (2017-03-22 15:48:44)
>> static code analyzer complain:
>>
>> qga/commands-posix.c:2127:9: warning: Null pointer passed as an argument to a 'nonnull' parameter
>> closedir(dp);
>> ^~~~~~~~~~~~
>>
>> Reported-by: Clang Static Analyzer
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>> qga/commands-posix.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>> index 73d93eb5ce..8028141534 100644
>> --- a/qga/commands-posix.c
>> +++ b/qga/commands-posix.c
>> @@ -2122,9 +2122,11 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
>> * we think this VM does not support online/offline memory block,
>> * any other solution?
>> */
>> - if (!dp && errno == ENOENT) {
>> - result->response =
>> - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
>> + if (!dp) {
>> + if (errno == ENOENT) {
>> + result->response =
>> + GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
>> + }
>> goto out1;
>> }
>
> I think this should be:
>
> if (!dp) {
> if (errno == ENOENT) {
> result->response =
> GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
> } else {
> result->response =
> GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED;
> }
> goto out1;
> }
>
> otherwise we might set result->error_code while still indicating
> success for the operation. That wasn't handled properly before your
> patch either, it's just more apparent now.
Indeed, I'll resend it in 2 patches It seems easier to me to understand.
>
>> closedir(dp);
>> --
>> 2.11.0
>>
>
>
prev parent reply other threads:[~2017-04-07 21:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 20:48 [Qemu-devel] [PATCH RESEND 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
2017-03-22 20:48 ` [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
2017-03-23 6:49 ` Markus Armbruster
2017-03-23 7:43 ` Gerd Hoffmann
2017-03-23 8:14 ` Marc-André Lureau
2017-03-23 9:51 ` Gerd Hoffmann
2017-03-23 12:41 ` Markus Armbruster
2017-03-23 13:56 ` Gerd Hoffmann
2017-03-23 14:08 ` Markus Armbruster
2017-04-07 21:33 ` Philippe Mathieu-Daudé
2017-03-22 20:48 ` [Qemu-devel] [PATCH RESEND 2/3] device_tree: fix compiler warnings (clang 5) Philippe Mathieu-Daudé
2017-03-22 22:35 ` Marc-André Lureau
2017-03-22 20:48 ` [Qemu-devel] [PATCH RESEND 3/3] qga: " Philippe Mathieu-Daudé
2017-03-22 21:22 ` Michael Roth
2017-04-07 21:31 ` Philippe Mathieu-Daudé [this message]
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=d3bdae1a-2a7d-57d2-bf3c-80b05130e530@amsat.org \
--to=f4bug@amsat.org \
--cc=agraf@suse.de \
--cc=crosthwaite.peter@gmail.com \
--cc=kraxel@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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).