easy-to-fix clang warnings
cover easy-to-fix clang warnings
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(-)
Signature · 1 line
2.11.0
PATCH 1/3 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/usb/dev-smartcard-reader.c +7 -1
@@ -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 ; }
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers
Quoted 10 lines · Philippe Mathieu-Daudé
static code analyzer complain:
hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an argument to a 'nonnull' parametermemcpy(p->abData, data, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 26 lines
--- hw/usb/dev-smartcard-reader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/usb/dev-smartcard-reader.c +7
-1@@ -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; }
Quoted 5 lines
--
2.11.0--
Marc-André Lureau
PATCH 2/3 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 3/3 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
@@ -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);
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH 3/3] qga: fix compiler warnings (clang 5)
Quoted 10 lines · Philippe Mathieu-Daudé
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]>
Quoted 25 lines
--- qga/commands-posix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)qga/commands-posix.c +5
-3@@ -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);
Quoted 5 lines
--
2.11.0--
Marc-André Lureau
Quoted 11 lines · Philippe Mathieu-Daudé
This patchset fixes three easy-to-fix clang warnings.
Philippe Mathieu-Daudé (3):
usb-ccid: makeccid_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(-)