3 easy-to-fix clang warnings, 1 error code fixed
v2 cover 3 easy-to-fix clang warnings, 1 error code fixed
This patchset fixes three easy-to-fix unrelated clang warnings, so it was probably better to send them separately the first time.
v2:
- hw/usb/dev-smartcard-reader.c: The first patch was treating NULL and 0 as errors but those values are legal in some cases, i.e. no (virtual) smartcard inserted into the card reader (Gerd Hoffmann's review).
- device_tree.c: Added Marc-André Lureau's Reviewed-by.
- qga/commands-posix.c: Added a commit to improve failed operation, as suggested by Michael Roth.
Philippe Mathieu-Daudé (4):
usb-ccid: make ccid_write_data_block() cope with null buffers
device_tree: fix compiler warnings (clang 5)
qga: fix compiler warnings (clang 5)
qga: improve error handling in transfer_memory_block
device_tree.c | 1 + hw/usb/dev-smartcard-reader.c | 5 ++++- qga/commands-posix.c | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/4 usb-ccid: make ccid_write_data_block() cope with null buffers
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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~--- hw/usb/dev-smartcard-reader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/usb/dev-smartcard-reader.c +4 -1
@@ -813,7 +813,10 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,if (p->b.bError) {DPRINTF (s,D_VERBOSE ,"error %d\n" , p->b.bError); } -memcpy (p->abData, data, len); +if (len) { +g_assert_nonnull (data); +memcpy (p->abData, data, len); + }ccid_reset_error_status (s);usb_wakeup (s->bulk,0 ); }
Signature · 1 line
2.11.0
PATCH v2 2/4 device_tree: fix compiler warnings (clang 5)
In reply to Philippe Mathieu-Daudé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) {
^~~~~~~~~~--- device_tree.c | 1 + 1 file changed, 1 insertion(+)
device_tree.c +1 -0
@@ -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 ) {
Signature · 1 line
2.11.0
PATCH v2 3/4 qga: fix compiler warnings (clang 5)
In reply to Philippe Mathieu-Daudéstatic code analyzer complain:
qga/commands-posix.c:2127:9: warning: Null pointer passed as an argument to a 'nonnull' parameter
closedir(dp);
^~~~~~~~~~~~--- qga/commands-posix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
qga/commands-posix.c +5 -3
@@ -2124,9 +2124,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);
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v2 3/4] qga: fix compiler warnings (clang 5)
Quoting Philippe Mathieu-Daudé (2017-04-07 17:20:15)
Quoted 9 lines
static code analyzer complain:
qga/commands-posix.c:2127:9: warning: Null pointer passed as an argument to a 'nonnull' parameterclosedir(dp); ^~~~~~~~~~~~Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Marc-André Lureau <[email protected]>
Quoted 26 lines
--- qga/commands-posix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)qga/commands-posix.c +5
-3@@ -2124,9 +2124,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);Signature · 1 line
2.11.0
PATCH v2 4/4 qga: improve error handling in transfer_memory_block
In reply to Philippe Mathieu-Daudé---
Michael should I use Signed-off-by instead of the Suggested-by (since it is your code)?
qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)
qga/commands-posix.c +3 -0
@@ -2128,6 +2128,9 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,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; }
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v2 4/4] qga: improve error handling in transfer_memory_block
Quoting Philippe Mathieu-Daudé (2017-04-07 17:20:16)
Quoted 2 lines
Suggested-by Michael Roth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 4 lines
---
Michael should I use Signed-off-by instead of the Suggested-by (since it is your code)?
I suppose it could go either way depending on the circumstances (assuming you've asked for / obtained their SoB obviously), but speaking for myself here I don't think it's necessary.
Quoted 21 lines
qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)qga/commands-posix.c +3
-0@@ -2128,6 +2128,9 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,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; }Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v2 4/4] qga: improve error handling in transfer_memory_block
Quoted 6 lines · Michael Roth
Quoting Philippe Mathieu-Daudé (2017-04-07 17:20:16)
Quoted 2 lines
Suggested-by Michael Roth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Michael Roth <[email protected]>
Quoted 9 lines
Quoted 4 lines
---
Michael should I use Signed-off-by instead of the Suggested-by (since it is your code)?
I suppose it could go either way depending on the circumstances (assuming you've asked for / obtained their SoB obviously), but speaking for myself here I don't think it's necessary.
Ok! I allowed myself to add your "Suggested-by" after reading Linux's process/submitting-patches.rst doc, assuming no need to ask for it since you answered in public ML. I'll diligently ask next time!
Quoted 22 lines
Quoted 21 lines
qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)qga/commands-posix.c +3
-1@@ -2128,6 +2128,9 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,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; } --2.11.0
Re: [Qemu-devel] [PATCH v2 4/4] qga: improve error handling in transfer_memory_block
In reply to Michael Rothping?
Quoted 37 lines · Michael Roth
Quoting Philippe Mathieu-Daudé (2017-04-07 17:20:16)
Quoted 2 lines
Suggested-by Michael Roth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Michael Roth <[email protected]>Quoted 4 lines
---
Michael should I use Signed-off-by instead of the Suggested-by (since it is your code)?
I suppose it could go either way depending on the circumstances (assuming you've asked for / obtained their SoB obviously), but speaking for myself here I don't think it's necessary.
Quoted 21 lines
qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+)qga/commands-posix.c +3
-1@@ -2128,6 +2128,9 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,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; } --2.11.0
Michael Tokarev
AppliedQuoted 11 lines · Philippe Mathieu-Daudé
This patchset fixes three easy-to-fix unrelated clang warnings, so it was probably better to send them separately the first time.
v2:
-hw/usb/dev-smartcard-reader.c: The first patch was treating NULL and 0 as errors but those values are legal in some cases, i.e. no (virtual) smartcard inserted into the card reader (Gerd Hoffmann's review).
-device_tree.c: Added Marc-André Lureau's Reviewed-by.
-qga/commands-posix.c: Added a commit to improve failed operation, as suggested by Michael Roth.
Quoted 5 lines
Philippe Mathieu-Daudé (4):
usb-ccid: makeccid_write_data_block()cope with null buffers
device_tree: fix compiler warnings (clang 5)
qga: fix compiler warnings (clang 5)
qga: improve error handling intransfer_memory_block
Applied to -trivial, thanks!
/mjt