* [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings
@ 2017-03-04 18:55 Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-04 18:55 UTC (permalink / raw)
To: Michael Roth, Peter Crosthwaite, Alexander Graf, Gerd Hoffmann
Cc: Philippe Mathieu-Daudé, qemu-devel
This patchset fixes three easy-to-fix clang warnings.
Philippe Mathieu-Daudé (3):
usb-ccid: make ccid_write_data_block() cope with null buffers
device_tree: fix compiler warnings (clang 5)
qga: fix compiler warnings (clang 5)
device_tree.c | 1 +
hw/usb/dev-smartcard-reader.c | 8 +++++++-
qga/commands-posix.c | 8 +++++---
3 files changed, 13 insertions(+), 4 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
2017-03-04 18:55 [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
@ 2017-03-04 18:55 ` Philippe Mathieu-Daudé
2017-03-05 21:01 ` Marc-André Lureau
2017-03-04 18:55 ` [Qemu-devel] [PATCH 2/3] device_tree: fix compiler warnings (clang 5) Philippe Mathieu-Daudé
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-04 18:55 UTC (permalink / raw)
To: Michael Roth, Peter Crosthwaite, Alexander Graf, Gerd Hoffmann
Cc: Philippe Mathieu-Daudé, qemu-devel
static code analyzer complain:
hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an argument to a 'nonnull' parameter
memcpy(p->abData, data, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/usb/dev-smartcard-reader.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 757b8b3f5a..c38a4e5886 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -799,8 +799,14 @@ static void ccid_write_parameters(USBCCIDState *s, CCID_Header *recv)
static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
const uint8_t *data, uint32_t len)
{
- CCID_DataBlock *p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
+ CCID_DataBlock *p;
+ if (len == 0) {
+ return;
+ }
+ g_assert(data != NULL);
+
+ p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
if (p == NULL) {
return;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/3] device_tree: fix compiler warnings (clang 5)
2017-03-04 18:55 [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
@ 2017-03-04 18:55 ` Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 3/3] qga: " Philippe Mathieu-Daudé
2017-03-05 7:52 ` [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Markus Armbruster
3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-04 18:55 UTC (permalink / raw)
To: Michael Roth, Peter Crosthwaite, Alexander Graf, Gerd Hoffmann
Cc: Philippe Mathieu-Daudé, qemu-devel
static code analyzer complain:
device_tree.c:155:18: warning: Null pointer passed as an argument to a 'nonnull' parameter
while ((de = readdir(d)) != NULL) {
^~~~~~~~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
device_tree.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/device_tree.c b/device_tree.c
index 6e06320830..a24ddff02b 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -148,6 +148,7 @@ static void read_fstree(void *fdt, const char *dirname)
d = opendir(dirname);
if (!d) {
error_setg(&error_fatal, "%s cannot open %s", __func__, dirname);
+ return;
}
while ((de = readdir(d)) != NULL) {
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/3] qga: fix compiler warnings (clang 5)
2017-03-04 18:55 [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 2/3] device_tree: fix compiler warnings (clang 5) Philippe Mathieu-Daudé
@ 2017-03-04 18:55 ` Philippe Mathieu-Daudé
2017-03-05 20:59 ` Marc-André Lureau
2017-03-05 7:52 ` [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Markus Armbruster
3 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-04 18:55 UTC (permalink / raw)
To: Michael Roth, Peter Crosthwaite, Alexander Graf, Gerd Hoffmann
Cc: Philippe Mathieu-Daudé, qemu-devel
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>
---
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 ea37c097cf..9c4ef2d640 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2119,9 +2119,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;
}
closedir(dp);
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings
2017-03-04 18:55 [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2017-03-04 18:55 ` [Qemu-devel] [PATCH 3/3] qga: " Philippe Mathieu-Daudé
@ 2017-03-05 7:52 ` Markus Armbruster
3 siblings, 0 replies; 7+ messages in thread
From: Markus Armbruster @ 2017-03-05 7:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Michael Roth, Peter Crosthwaite, Alexander Graf, Gerd Hoffmann,
qemu-devel, qemu-trivial
Cc: qemu-trivial
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> This patchset fixes three easy-to-fix clang warnings.
>
> Philippe Mathieu-Daudé (3):
> usb-ccid: make ccid_write_data_block() cope with null buffers
> device_tree: fix compiler warnings (clang 5)
> qga: fix compiler warnings (clang 5)
>
> device_tree.c | 1 +
> hw/usb/dev-smartcard-reader.c | 8 +++++++-
> qga/commands-posix.c | 8 +++++---
> 3 files changed, 13 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] qga: fix compiler warnings (clang 5)
2017-03-04 18:55 ` [Qemu-devel] [PATCH 3/3] qga: " Philippe Mathieu-Daudé
@ 2017-03-05 20:59 ` Marc-André Lureau
0 siblings, 0 replies; 7+ messages in thread
From: Marc-André Lureau @ 2017-03-05 20:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Michael Roth, Peter Crosthwaite,
Alexander Graf, Gerd Hoffmann
Cc: qemu-devel
On Sat, Mar 4, 2017 at 10:58 PM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:
> 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 ea37c097cf..9c4ef2d640 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -2119,9 +2119,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;
> }
> closedir(dp);
> --
> 2.11.0
>
>
> --
Marc-André Lureau
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
2017-03-04 18:55 ` [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
@ 2017-03-05 21:01 ` Marc-André Lureau
0 siblings, 0 replies; 7+ messages in thread
From: Marc-André Lureau @ 2017-03-05 21:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Michael Roth, Peter Crosthwaite,
Alexander Graf, Gerd Hoffmann
Cc: qemu-devel
On Sat, Mar 4, 2017 at 10:57 PM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:
> static code analyzer complain:
>
> hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an
> argument to a 'nonnull' parameter
> memcpy(p->abData, data, len);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/usb/dev-smartcard-reader.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
> index 757b8b3f5a..c38a4e5886 100644
> --- a/hw/usb/dev-smartcard-reader.c
> +++ b/hw/usb/dev-smartcard-reader.c
> @@ -799,8 +799,14 @@ static void ccid_write_parameters(USBCCIDState *s,
> CCID_Header *recv)
> static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t
> seq,
> const uint8_t *data, uint32_t len)
> {
> - CCID_DataBlock *p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
> + CCID_DataBlock *p;
>
> + if (len == 0) {
> + return;
> + }
> + g_assert(data != NULL);
> +
> + p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
> if (p == NULL) {
> return;
> }
> --
> 2.11.0
>
>
> --
Marc-André Lureau
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-03-05 21:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-04 18:55 [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers Philippe Mathieu-Daudé
2017-03-05 21:01 ` Marc-André Lureau
2017-03-04 18:55 ` [Qemu-devel] [PATCH 2/3] device_tree: fix compiler warnings (clang 5) Philippe Mathieu-Daudé
2017-03-04 18:55 ` [Qemu-devel] [PATCH 3/3] qga: " Philippe Mathieu-Daudé
2017-03-05 20:59 ` Marc-André Lureau
2017-03-05 7:52 ` [Qemu-devel] [PATCH 0/3] easy-to-fix clang warnings Markus Armbruster
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).