qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes
@ 2020-03-21 11:46 Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
                   ` (11 more replies)
  0 siblings, 12 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix trivial warnings reported by the Clang static code analyzer.

Philippe Mathieu-Daudé (11):
  block: Remove dead assignment
  blockdev: Remove dead assignment
  hw/i2c/pm_smbus: Remove dead assignment
  hw/input/adb-kbd: Remove dead assignment
  hw/ide/sii3112: Remove dead assignment
  hw/isa/i82378: Remove dead assignment
  hw/gpio/aspeed_gpio: Remove dead assignment
  hw/timer/exynos4210_mct: Remove dead assignments
  hw/timer/stm32f2xx_timer: Remove dead assignment
  hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning
  hw/scsi/esp-pci: Remove dead assignment

 block.c                    | 2 +-
 blockdev.c                 | 2 +-
 hw/gpio/aspeed_gpio.c      | 4 ++--
 hw/i2c/pm_smbus.c          | 1 -
 hw/ide/sii3112.c           | 2 +-
 hw/input/adb-kbd.c         | 1 -
 hw/isa/i82378.c            | 8 ++++----
 hw/scsi/esp-pci.c          | 1 -
 hw/timer/exynos4210_mct.c  | 3 ---
 hw/timer/pxa2xx_timer.c    | 1 +
 hw/timer/stm32f2xx_timer.c | 1 -
 11 files changed, 10 insertions(+), 16 deletions(-)

-- 
2.21.1



^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 01/11] block: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:56   ` Aleksandar Markovic
  2020-03-21 11:58   ` Laurent Vivier
  2020-03-21 11:46 ` [PATCH-for-5.0 02/11] blockdev: " Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

  block.c:3167:5: warning: Value stored to 'ret' is never read
      ret = bdrv_fill_options(&options, filename, &flags, &local_err);
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index a2542c977b..908c109a8c 100644
--- a/block.c
+++ b/block.c
@@ -3164,7 +3164,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
                                     parent->open_flags, parent->options);
     }
 
-    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
+    bdrv_fill_options(&options, filename, &flags, &local_err);
     if (local_err) {
         goto fail;
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 02/11] blockdev: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 03/11] hw/i2c/pm_smbus: " Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      blockdev.o
  blockdev.c:2744:5: warning: Value stored to 'ret' is never read
      ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp);
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 blockdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/blockdev.c b/blockdev.c
index fa8630cb41..6effd5afaa 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2741,7 +2741,7 @@ void qmp_block_resize(bool has_device, const char *device,
     }
 
     bdrv_drained_begin(bs);
-    ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp);
+    blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp);
     bdrv_drained_end(bs);
 
 out:
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 03/11] hw/i2c/pm_smbus: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 02/11] blockdev: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 04/11] hw/input/adb-kbd: " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      hw/i2c/pm_smbus.o
  hw/i2c/pm_smbus.c:187:17: warning: Value stored to 'ret' is never read
                  ret = 0;
                  ^     ~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/i2c/pm_smbus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 36994ff585..4728540c37 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -184,7 +184,6 @@ static void smb_transaction(PMSMBus *s)
                 s->smb_stat |= STS_HOST_BUSY | STS_BYTE_DONE;
                 s->smb_data[0] = s->smb_blkdata;
                 s->smb_index = 0;
-                ret = 0;
             }
             goto out;
         }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 04/11] hw/input/adb-kbd: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 03/11] hw/i2c/pm_smbus: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 12:58   ` BALATON Zoltan
  2020-03-21 11:46 ` [PATCH-for-5.0 05/11] hw/ide/sii3112: " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      hw/input/adb-kbd.o
  hw/input/adb-kbd.c:200:5: warning: Value stored to 'olen' is never read
      olen = 0;
      ^      ~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/input/adb-kbd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
index 0ba8207589..b0565be21b 100644
--- a/hw/input/adb-kbd.c
+++ b/hw/input/adb-kbd.c
@@ -197,7 +197,6 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf)
     int keycode;
     int olen;
 
-    olen = 0;
     if (s->count == 0) {
         return 0;
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 04/11] hw/input/adb-kbd: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 13:04   ` BALATON Zoltan
  2020-03-21 13:39   ` Aleksandar Markovic
  2020-03-21 11:46 ` [PATCH-for-5.0 06/11] hw/isa/i82378: " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  11 siblings, 2 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      hw/ide/sii3112.o
  hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
          val = 0;
          ^     ~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/ide/sii3112.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
index 06605d7af2..36f1905ddb 100644
--- a/hw/ide/sii3112.c
+++ b/hw/ide/sii3112.c
@@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr addr,
         val = (uint32_t)d->regs[1].sien << 16;
         break;
     default:
-        val = 0;
+        break;
     }
     trace_sii3112_read(size, addr, val);
     return val;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 06/11] hw/isa/i82378: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 05/11] hw/ide/sii3112: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: " Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Rename the unique variable assigned as 'pit' which better
represents what it holds, to fix a warning reported by the
Clang static code analyzer:

    CC      hw/isa/i82378.o
  hw/isa/i82378.c:108:5: warning: Value stored to 'isa' is never read
      isa = isa_create_simple(isabus, "i82374");
      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/isa/i82378.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index dcb6b479ea..d9e6c7fa00 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -67,7 +67,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
     I82378State *s = I82378(dev);
     uint8_t *pci_conf;
     ISABus *isabus;
-    ISADevice *isa;
+    ISADevice *pit;
 
     pci_conf = pci->config;
     pci_set_word(pci_conf + PCI_COMMAND,
@@ -99,13 +99,13 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
     isa_bus_irqs(isabus, s->i8259);
 
     /* 1 82C54 (pit) */
-    isa = i8254_pit_init(isabus, 0x40, 0, NULL);
+    pit = i8254_pit_init(isabus, 0x40, 0, NULL);
 
     /* speaker */
-    pcspk_init(isabus, isa);
+    pcspk_init(isabus, pit);
 
     /* 2 82C37 (dma) */
-    isa = isa_create_simple(isabus, "i82374");
+    isa_create_simple(isabus, "i82374");
 }
 
 static void i82378_init(Object *obj)
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 06/11] hw/isa/i82378: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 13:22   ` BALATON Zoltan
  2020-03-21 11:46 ` [PATCH-for-5.0 08/11] hw/timer/exynos4210_mct: Remove dead assignments Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

  hw/gpio/aspeed_gpio.c:717:18: warning: Value stored to 'g_idx' during its initialization is never read
      int set_idx, g_idx = *group_idx;
                   ^~~~~   ~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/gpio/aspeed_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index 41e11ea9b0..cc07ab9866 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -714,11 +714,11 @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data,
 static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx)
 {
     AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s);
-    int set_idx, g_idx = *group_idx;
+    int set_idx;
 
     for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) {
         const GPIOSetProperties *set_props = &agc->props[set_idx];
-        for (g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {
+        for (int g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {
             if (!strncmp(group, set_props->group_label[g_idx], strlen(group))) {
                 *group_idx = g_idx;
                 return set_idx;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 08/11] hw/timer/exynos4210_mct: Remove dead assignments
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: " Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 09/11] hw/timer/stm32f2xx_timer: Remove dead assignment Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warnings reported by Clang static code analyzer:

  hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/timer/exynos4210_mct.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 944120aea5..c0a25e71ec 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -1367,7 +1367,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_TCNTB: case L1_TCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         /*
          * TCNTB is updated to internal register only after CNT expired.
@@ -1396,7 +1395,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_ICNTB: case L1_ICNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
         s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
@@ -1438,7 +1436,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_FRCNTB: case L1_FRCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
 
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 09/11] hw/timer/stm32f2xx_timer: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 08/11] hw/timer/exynos4210_mct: Remove dead assignments Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 10/11] hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      hw/timer/stm32f2xx_timer.o
  hw/timer/stm32f2xx_timer.c:225:9: warning: Value stored to 'value' is never read
          value = timer_val;
          ^       ~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/timer/stm32f2xx_timer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c
index 06ec8a02c2..ba8694dcd3 100644
--- a/hw/timer/stm32f2xx_timer.c
+++ b/hw/timer/stm32f2xx_timer.c
@@ -222,7 +222,6 @@ static void stm32f2xx_timer_write(void *opaque, hwaddr offset,
     case TIM_PSC:
         timer_val = stm32f2xx_ns_to_ticks(s, now) - s->tick_offset;
         s->tim_psc = value & 0xFFFF;
-        value = timer_val;
         break;
     case TIM_CNT:
         timer_val = value;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 10/11] hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 09/11] hw/timer/stm32f2xx_timer: Remove dead assignment Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 11:46 ` [PATCH-for-5.0 11/11] hw/scsi/esp-pci: Remove dead assignment Philippe Mathieu-Daudé
  2020-03-21 12:01 ` [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Aleksandar Markovic
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

pxa2xx_timer_tick4() takes an opaque pointer, then calls
pxa2xx_timer_update4(), so the static analyzer can not
verify that the 'n < 8':

  425 static void pxa2xx_timer_tick4(void *opaque)
  426 {
  427     PXA2xxTimer4 *t = (PXA2xxTimer4 *) opaque;
  428     PXA2xxTimerInfo *i = (PXA2xxTimerInfo *) t->tm.info;
  429
  430     pxa2xx_timer_tick(&t->tm);
  433     if (t->control & (1 << 6))
  434         pxa2xx_timer_update4(i, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), t->tm.num - 4);

  135 static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n)
  136 {
  137     PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
  140     static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 };
  142
  143     if (s->tm4[n].control & (1 << 7))
  144         counter = n;
  145     else
  146         counter = counters[n];

Add an assert() to give the static analyzer a hint, this fixes a
warning reported by Clang static code analyzer:

    CC      hw/timer/pxa2xx_timer.o
  hw/timer/pxa2xx_timer.c:146:17: warning: Assigned value is garbage or undefined
          counter = counters[n];
                  ^ ~~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/timer/pxa2xx_timer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index cd172cc1e9..944c165889 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -140,6 +140,7 @@ static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n)
     static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 };
     int counter;
 
+    assert(n < ARRAY_SIZE(counters));
     if (s->tm4[n].control & (1 << 7))
         counter = n;
     else
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH-for-5.0 11/11] hw/scsi/esp-pci: Remove dead assignment
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 10/11] hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning Philippe Mathieu-Daudé
@ 2020-03-21 11:46 ` Philippe Mathieu-Daudé
  2020-03-21 12:01 ` [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Aleksandar Markovic
  11 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 11:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery,
	Philippe Mathieu-Daudé,
	Laurent Vivier, Max Reitz, Igor Mitsyanko, qemu-ppc,
	Paolo Bonzini

Fix warning reported by Clang static code analyzer:

    CC      hw/scsi/esp-pci.o
  hw/scsi/esp-pci.c:198:9: warning: Value stored to 'size' is never read
          size = 4;
          ^      ~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/scsi/esp-pci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index d5a1f9e017..2e6cc07d4e 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -195,7 +195,6 @@ static void esp_pci_io_write(void *opaque, hwaddr addr,
         val <<= shift;
         val |= current & ~(mask << shift);
         addr &= ~3;
-        size = 4;
     }
 
     if (addr < 0x40) {
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 01/11] block: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
@ 2020-03-21 11:56   ` Aleksandar Markovic
  2020-03-21 15:11     ` BALATON Zoltan
  2020-03-21 11:58   ` Laurent Vivier
  1 sibling, 1 reply; 28+ messages in thread
From: Aleksandar Markovic @ 2020-03-21 11:56 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

12:49 PM Sub, 21.03.2020. Philippe Mathieu-Daudé <philmd@redhat.com> је
написао/ла:
>
> Fix warning reported by Clang static code analyzer:
>
>   block.c:3167:5: warning: Value stored to 'ret' is never read
>       ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reported-by: Clang Static Analyzer

Peter, and others,

Is this allowed use of "Reported-by:" mark?

I did not notice it being used this way before. And was under impression
that all similar tags/marks must be followed by a person, not a tool.

Regards,
Aleksandar

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block.c b/block.c
> index a2542c977b..908c109a8c 100644
> --- a/block.c
> +++ b/block.c
> @@ -3164,7 +3164,7 @@ static BlockDriverState *bdrv_open_inherit(const
char *filename,
>                                      parent->open_flags, parent->options);
>      }
>
> -    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
> +    bdrv_fill_options(&options, filename, &flags, &local_err);
>      if (local_err) {
>          goto fail;
>      }
> --
> 2.21.1
>
>

[-- Attachment #2: Type: text/html, Size: 1833 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 01/11] block: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
  2020-03-21 11:56   ` Aleksandar Markovic
@ 2020-03-21 11:58   ` Laurent Vivier
  2020-03-21 13:08     ` Markus Armbruster
  1 sibling, 1 reply; 28+ messages in thread
From: Laurent Vivier @ 2020-03-21 11:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery, Max Reitz,
	Igor Mitsyanko, qemu-ppc, Paolo Bonzini

Le 21/03/2020 à 12:46, Philippe Mathieu-Daudé a écrit :
> Fix warning reported by Clang static code analyzer:
> 
>   block.c:3167:5: warning: Value stored to 'ret' is never read
>       ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index a2542c977b..908c109a8c 100644
> --- a/block.c
> +++ b/block.c
> @@ -3164,7 +3164,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
>                                      parent->open_flags, parent->options);
>      }
>  
> -    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
> +    bdrv_fill_options(&options, filename, &flags, &local_err);
>      if (local_err) {
>          goto fail;
>      }
> 

I would be sruprised if coverity doesn't warn about an unused return value.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes
  2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2020-03-21 11:46 ` [PATCH-for-5.0 11/11] hw/scsi/esp-pci: Remove dead assignment Philippe Mathieu-Daudé
@ 2020-03-21 12:01 ` Aleksandar Markovic
  2020-03-21 12:20   ` Philippe Mathieu-Daudé
  11 siblings, 1 reply; 28+ messages in thread
From: Aleksandar Markovic @ 2020-03-21 12:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]

12:47 PM Sub, 21.03.2020. Philippe Mathieu-Daudé <philmd@redhat.com> је
написао/ла:
>
> Fix trivial warnings reported by the Clang static code analyzer.
>

Philippe,

It would be useful and customary for this type of fixes to provide here the
environment you used for obtaining the warnings (clang version, configure
parameters, and all needed elenents to repro the warnings).

Regards,
Aleksandar

> Philippe Mathieu-Daudé (11):
>   block: Remove dead assignment
>   blockdev: Remove dead assignment
>   hw/i2c/pm_smbus: Remove dead assignment
>   hw/input/adb-kbd: Remove dead assignment
>   hw/ide/sii3112: Remove dead assignment
>   hw/isa/i82378: Remove dead assignment
>   hw/gpio/aspeed_gpio: Remove dead assignment
>   hw/timer/exynos4210_mct: Remove dead assignments
>   hw/timer/stm32f2xx_timer: Remove dead assignment
>   hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning
>   hw/scsi/esp-pci: Remove dead assignment
>
>  block.c                    | 2 +-
>  blockdev.c                 | 2 +-
>  hw/gpio/aspeed_gpio.c      | 4 ++--
>  hw/i2c/pm_smbus.c          | 1 -
>  hw/ide/sii3112.c           | 2 +-
>  hw/input/adb-kbd.c         | 1 -
>  hw/isa/i82378.c            | 8 ++++----
>  hw/scsi/esp-pci.c          | 1 -
>  hw/timer/exynos4210_mct.c  | 3 ---
>  hw/timer/pxa2xx_timer.c    | 1 +
>  hw/timer/stm32f2xx_timer.c | 1 -
>  11 files changed, 10 insertions(+), 16 deletions(-)
>
> --
> 2.21.1
>
>

[-- Attachment #2: Type: text/html, Size: 1945 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes
  2020-03-21 12:01 ` [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Aleksandar Markovic
@ 2020-03-21 12:20   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 12:20 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

On 3/21/20 1:01 PM, Aleksandar Markovic wrote:
> 12:47 PM Sub, 21.03.2020. Philippe Mathieu-Daudé <philmd@redhat.com 
> <mailto:philmd@redhat.com>> је написао/ла:
>  >
>  > Fix trivial warnings reported by the Clang static code analyzer.
>  >
> 
> Philippe,
> 
> It would be useful and customary for this type of fixes to provide here 
> the environment you used for obtaining the warnings (clang version, 
> configure parameters, and all needed elenents to repro the warnings).

https://clang-analyzer.llvm.org/

$ sudo dnf install clang-analyzer
$ ../configure
$ scan-build make

> 
> Regards,
> Aleksandar
> 
>  > Philippe Mathieu-Daudé (11):
>  >   block: Remove dead assignment
>  >   blockdev: Remove dead assignment
>  >   hw/i2c/pm_smbus: Remove dead assignment
>  >   hw/input/adb-kbd: Remove dead assignment
>  >   hw/ide/sii3112: Remove dead assignment
>  >   hw/isa/i82378: Remove dead assignment
>  >   hw/gpio/aspeed_gpio: Remove dead assignment
>  >   hw/timer/exynos4210_mct: Remove dead assignments
>  >   hw/timer/stm32f2xx_timer: Remove dead assignment
>  >   hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning
>  >   hw/scsi/esp-pci: Remove dead assignment
>  >
>  >  block.c                    | 2 +-
>  >  blockdev.c                 | 2 +-
>  >  hw/gpio/aspeed_gpio.c      | 4 ++--
>  >  hw/i2c/pm_smbus.c          | 1 -
>  >  hw/ide/sii3112.c           | 2 +-
>  >  hw/input/adb-kbd.c         | 1 -
>  >  hw/isa/i82378.c            | 8 ++++----
>  >  hw/scsi/esp-pci.c          | 1 -
>  >  hw/timer/exynos4210_mct.c  | 3 ---
>  >  hw/timer/pxa2xx_timer.c    | 1 +
>  >  hw/timer/stm32f2xx_timer.c | 1 -
>  >  11 files changed, 10 insertions(+), 16 deletions(-)
>  >
>  > --
>  > 2.21.1
>  >
>  >
> 



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 04/11] hw/input/adb-kbd: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 04/11] hw/input/adb-kbd: " Philippe Mathieu-Daudé
@ 2020-03-21 12:58   ` BALATON Zoltan
  0 siblings, 0 replies; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 12:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery, Laurent Vivier,
	Max Reitz, Igor Mitsyanko, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
> Fix warning reported by Clang static code analyzer:
>
>    CC      hw/input/adb-kbd.o
>  hw/input/adb-kbd.c:200:5: warning: Value stored to 'olen' is never read
>      olen = 0;
>      ^      ~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/input/adb-kbd.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
> index 0ba8207589..b0565be21b 100644
> --- a/hw/input/adb-kbd.c
> +++ b/hw/input/adb-kbd.c
> @@ -197,7 +197,6 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf)
>     int keycode;
>     int olen;
>
> -    olen = 0;
>     if (s->count == 0) {
>         return 0;
>     }

Is this variable still needed at all? Looks like it's a remnant after 
a1f4971863 that can now only return 0 or 2 so you could just remove this 
variable and return 2 where now it's assigned as 2 or change return olen 
at the end to return 2 or maybe keep olen and change the return 0 above to 
return olen to silence warning but I think this could be cleaned up.

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 05/11] hw/ide/sii3112: " Philippe Mathieu-Daudé
@ 2020-03-21 13:04   ` BALATON Zoltan
  2020-03-21 13:39   ` Aleksandar Markovic
  1 sibling, 0 replies; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 13:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Mark Cave-Ayland,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery, Laurent Vivier,
	Max Reitz, Igor Mitsyanko, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]

On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
> Fix warning reported by Clang static code analyzer:
>
>    CC      hw/ide/sii3112.o
>  hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>          val = 0;
>          ^     ~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/ide/sii3112.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
> index 06605d7af2..36f1905ddb 100644
> --- a/hw/ide/sii3112.c
> +++ b/hw/ide/sii3112.c
> @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr addr,
>         val = (uint32_t)d->regs[1].sien << 16;
>         break;
>     default:
> -        val = 0;
> +        break;
>     }
>     trace_sii3112_read(size, addr, val);
>     return val;

Value is clearly used in trace and return so don't really get why the 
compiler complains here. Looks like wrong warning to me. It's true however 
that since val is init to 0 at the beginning this assignment is not 
strictily needed and this should work as well, so

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 01/11] block: Remove dead assignment
  2020-03-21 11:58   ` Laurent Vivier
@ 2020-03-21 13:08     ` Markus Armbruster
  0 siblings, 0 replies; 28+ messages in thread
From: Markus Armbruster @ 2020-03-21 13:08 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Hervé Poussineau,
	Joel Stanley, Philippe Mathieu-Daudé,
	Michael Tokarev, Alistair Francis, qemu-arm,
	Cédric Le Goater, John Snow, David Gibson, Kevin Wolf,
	Igor Mitsyanko, Max Reitz, Andrew Jeffery, qemu-ppc,
	Paolo Bonzini

Laurent Vivier <laurent@vivier.eu> writes:

> Le 21/03/2020 à 12:46, Philippe Mathieu-Daudé a écrit :
>> Fix warning reported by Clang static code analyzer:
>> 
>>   block.c:3167:5: warning: Value stored to 'ret' is never read
>>       ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>>       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 
>> Reported-by: Clang Static Analyzer
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  block.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/block.c b/block.c
>> index a2542c977b..908c109a8c 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -3164,7 +3164,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
>>                                      parent->open_flags, parent->options);
>>      }
>>  
>> -    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>> +    bdrv_fill_options(&options, filename, &flags, &local_err);
>>      if (local_err) {
>>          goto fail;
>>      }
>> 
>
> I would be sruprised if coverity doesn't warn about an unused return value.

Coverity recognizes the fact that some return values can be safely
ignored, and reports only ignored return values it sees commonly checked
elsewhere.

This function is used called nowhere else.  Coverity won't complain.

However, I'd prefer

        ret = bdrv_fill_options(&options, filename, &flags, &local_err);
   -    if (local_err) {
   +    if (ret < 0) {
            goto fail;
        }



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: " Philippe Mathieu-Daudé
@ 2020-03-21 13:22   ` BALATON Zoltan
  2020-03-21 14:12     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 13:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Alistair Francis, qemu-arm,
	Cédric Le Goater, John Snow, David Gibson, Kevin Wolf,
	Igor Mitsyanko, Max Reitz, Andrew Jeffery, qemu-ppc,
	Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]

On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
> Fix warning reported by Clang static code analyzer:
>
>  hw/gpio/aspeed_gpio.c:717:18: warning: Value stored to 'g_idx' during its initialization is never read
>      int set_idx, g_idx = *group_idx;
>                   ^~~~~   ~~~~~~~~~~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/gpio/aspeed_gpio.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
> index 41e11ea9b0..cc07ab9866 100644
> --- a/hw/gpio/aspeed_gpio.c
> +++ b/hw/gpio/aspeed_gpio.c
> @@ -714,11 +714,11 @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data,
> static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx)
> {
>     AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s);
> -    int set_idx, g_idx = *group_idx;
> +    int set_idx;
>
>     for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) {
>         const GPIOSetProperties *set_props = &agc->props[set_idx];
> -        for (g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {
> +        for (int g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {

Is declaring variables here allowed by coding style? Shouldn't you only 
remove init value from above?

Regards,
BALATON Zoltan

>             if (!strncmp(group, set_props->group_label[g_idx], strlen(group))) {
>                 *group_idx = g_idx;
>                 return set_idx;
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 11:46 ` [PATCH-for-5.0 05/11] hw/ide/sii3112: " Philippe Mathieu-Daudé
  2020-03-21 13:04   ` BALATON Zoltan
@ 2020-03-21 13:39   ` Aleksandar Markovic
  2020-03-21 14:12     ` BALATON Zoltan
  2020-03-21 14:14     ` Philippe Mathieu-Daudé
  1 sibling, 2 replies; 28+ messages in thread
From: Aleksandar Markovic @ 2020-03-21 13:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:

> Fix warning reported by Clang static code analyzer:
>
>     CC      hw/ide/sii3112.o
>   hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>           val = 0;
>           ^     ~
>
> Reported-by: Clang Static Analyzer
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/ide/sii3112.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
> index 06605d7af2..36f1905ddb 100644
> --- a/hw/ide/sii3112.c
> +++ b/hw/ide/sii3112.c
> @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr
> addr,
>          val = (uint32_t)d->regs[1].sien << 16;
>          break;
>      default:
> -        val = 0;
> +        break;


There is another function in the same file, having a similar switch
statement. There is no warning for that second tunction, since "val" is its
parameter, not a local varioble, like is the case here. This means that the
proposed change introduces inconsistency between two functions, therefore
it is better to remove the initialization of "val" to 0, than to remove
this line in "default" section.

Regards,
Aleksandar



>      }
>      trace_sii3112_read(size, addr, val);
>      return val;
> --
> 2.21.1
>
>
>

[-- Attachment #2: Type: text/html, Size: 1927 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: Remove dead assignment
  2020-03-21 13:22   ` BALATON Zoltan
@ 2020-03-21 14:12     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 14:12 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Alistair Francis, qemu-arm,
	Cédric Le Goater, John Snow, David Gibson, Kevin Wolf,
	Igor Mitsyanko, Max Reitz, Andrew Jeffery, qemu-ppc,
	Paolo Bonzini

On 3/21/20 2:22 PM, BALATON Zoltan wrote:
> On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
>> Fix warning reported by Clang static code analyzer:
>>
>>  hw/gpio/aspeed_gpio.c:717:18: warning: Value stored to 'g_idx' during 
>> its initialization is never read
>>      int set_idx, g_idx = *group_idx;
>>                   ^~~~~   ~~~~~~~~~~
>>
>> Reported-by: Clang Static Analyzer
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> hw/gpio/aspeed_gpio.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
>> index 41e11ea9b0..cc07ab9866 100644
>> --- a/hw/gpio/aspeed_gpio.c
>> +++ b/hw/gpio/aspeed_gpio.c
>> @@ -714,11 +714,11 @@ static void aspeed_gpio_write(void *opaque, 
>> hwaddr offset, uint64_t data,
>> static int get_set_idx(AspeedGPIOState *s, const char *group, int 
>> *group_idx)
>> {
>>     AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s);
>> -    int set_idx, g_idx = *group_idx;
>> +    int set_idx;
>>
>>     for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) {
>>         const GPIOSetProperties *set_props = &agc->props[set_idx];
>> -        for (g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {
>> +        for (int g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) {
> 
> Is declaring variables here allowed by coding style? Shouldn't you only 
> remove init value from above?

You are right, it is not (yet?) allowed by QEMU coding style.

> 
> Regards,
> BALATON Zoltan
> 
>>             if (!strncmp(group, set_props->group_label[g_idx], 
>> strlen(group))) {
>>                 *group_idx = g_idx;
>>                 return set_idx;
>>



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 13:39   ` Aleksandar Markovic
@ 2020-03-21 14:12     ` BALATON Zoltan
  2020-03-21 14:16       ` Philippe Mathieu-Daudé
  2020-03-21 14:14     ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 14:12 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Philippe Mathieu-Daudé,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery, Max Reitz,
	Igor Mitsyanko, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

On Sat, 21 Mar 2020, Aleksandar Markovic wrote:
> On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com>
> wrote:
>
>> Fix warning reported by Clang static code analyzer:
>>
>>     CC      hw/ide/sii3112.o
>>   hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>>           val = 0;
>>           ^     ~
>>
>> Reported-by: Clang Static Analyzer
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  hw/ide/sii3112.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
>> index 06605d7af2..36f1905ddb 100644
>> --- a/hw/ide/sii3112.c
>> +++ b/hw/ide/sii3112.c
>> @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr
>> addr,
>>          val = (uint32_t)d->regs[1].sien << 16;
>>          break;
>>      default:
>> -        val = 0;
>> +        break;
>
>
> There is another function in the same file, having a similar switch
> statement. There is no warning for that second tunction, since "val" is its
> parameter, not a local varioble, like is the case here. This means that the
> proposed change introduces inconsistency between two functions, therefore
> it is better to remove the initialization of "val" to 0, than to remove
> this line in "default" section.

Oh, actually I think the warning was for that statement not for the one 
patched as it makes more sense there where val is assigned in void 
sii3112_reg_write() where it's indeed not used so maybe that was meant to 
be patched instead?

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 13:39   ` Aleksandar Markovic
  2020-03-21 14:12     ` BALATON Zoltan
@ 2020-03-21 14:14     ` Philippe Mathieu-Daudé
  2020-03-21 14:26       ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 14:14 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

On 3/21/20 2:39 PM, Aleksandar Markovic wrote:
> 
> 
> On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com 
> <mailto:philmd@redhat.com>> wrote:
> 
>     Fix warning reported by Clang static code analyzer:
> 
>          CC      hw/ide/sii3112.o
>        hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>                val = 0;
>                ^     ~
> 
>     Reported-by: Clang Static Analyzer
>     Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com
>     <mailto:philmd@redhat.com>>
>     ---
>       hw/ide/sii3112.c | 2 +-
>       1 file changed, 1 insertion(+), 1 deletion(-)
> 
>     diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
>     index 06605d7af2..36f1905ddb 100644
>     --- a/hw/ide/sii3112.c
>     +++ b/hw/ide/sii3112.c
>     @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque,
>     hwaddr addr,
>               val = (uint32_t)d->regs[1].sien << 16;
>               break;
>           default:
>     -        val = 0;
>     +        break;
> 
> 
> There is another function in the same file, having a similar switch 
> statement. There is no warning for that second tunction, since "val" is 
> its parameter, not a local varioble, like is the case here. This means 
> that the proposed change introduces inconsistency between two functions, 
> therefore it is better to remove the initialization of "val" to 0, than 
> to remove this line in "default" section.

No clue why there is no warnings emitted for sii3112_reg_write()...

Do you mind sending a patch?

> 
> Regards,
> Aleksandar
> 
>           }
>           trace_sii3112_read(size, addr, val);
>           return val;
>     -- 
>     2.21.1
> 
> 



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 14:12     ` BALATON Zoltan
@ 2020-03-21 14:16       ` Philippe Mathieu-Daudé
  2020-03-21 14:20         ` BALATON Zoltan
  0 siblings, 1 reply; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 14:16 UTC (permalink / raw)
  To: BALATON Zoltan, Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, qemu-ppc, qemu-block,
	Michael S. Tsirkin, qemu-trivial, Andrew Jeffery,
	Alistair Francis, Michael Tokarev, qemu-devel, Markus Armbruster,
	Igor Mitsyanko, qemu-arm, Hervé Poussineau, Joel Stanley,
	Paolo Bonzini, Kevin Wolf, David Gibson, John Snow, Max Reitz,
	Cédric Le Goater

On 3/21/20 3:12 PM, BALATON Zoltan wrote:
> On Sat, 21 Mar 2020, Aleksandar Markovic wrote:
>> On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com>
>> wrote:
>>
>>> Fix warning reported by Clang static code analyzer:
>>>
>>>     CC      hw/ide/sii3112.o
>>>   hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>>>           val = 0;
>>>           ^     ~
>>>
>>> Reported-by: Clang Static Analyzer
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>>  hw/ide/sii3112.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
>>> index 06605d7af2..36f1905ddb 100644
>>> --- a/hw/ide/sii3112.c
>>> +++ b/hw/ide/sii3112.c
>>> @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, 
>>> hwaddr
>>> addr,
>>>          val = (uint32_t)d->regs[1].sien << 16;
>>>          break;
>>>      default:
>>> -        val = 0;
>>> +        break;
>>
>>
>> There is another function in the same file, having a similar switch
>> statement. There is no warning for that second tunction, since "val" 
>> is its
>> parameter, not a local varioble, like is the case here. This means 
>> that the
>> proposed change introduces inconsistency between two functions, therefore
>> it is better to remove the initialization of "val" to 0, than to remove
>> this line in "default" section.
> 
> Oh, actually I think the warning was for that statement not for the one 
> patched as it makes more sense there where val is assigned in void 
> sii3112_reg_write() where it's indeed not used so maybe that was meant 
> to be patched instead?

Ah, the warning is for hw/ide/sii3112.c:204 but I incorrectly patched 
hw/ide/sii3112.c:128 =)

> 
> Regards,
> BALATON Zoltan



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 14:16       ` Philippe Mathieu-Daudé
@ 2020-03-21 14:20         ` BALATON Zoltan
  0 siblings, 0 replies; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 14:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Aleksandar Markovic,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Max Reitz,
	Andrew Jeffery, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 2155 bytes --]

On Sat, 21 Mar 2020, Philippe Mathieu-Daudé wrote:
> On 3/21/20 3:12 PM, BALATON Zoltan wrote:
>> On Sat, 21 Mar 2020, Aleksandar Markovic wrote:
>>> On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com>
>>> wrote:
>>> 
>>>> Fix warning reported by Clang static code analyzer:
>>>> 
>>>>     CC      hw/ide/sii3112.o
>>>>   hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read
>>>>           val = 0;
>>>>           ^     ~
>>>> 
>>>> Reported-by: Clang Static Analyzer
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>> ---
>>>>  hw/ide/sii3112.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>> 
>>>> diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
>>>> index 06605d7af2..36f1905ddb 100644
>>>> --- a/hw/ide/sii3112.c
>>>> +++ b/hw/ide/sii3112.c
>>>> @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr
>>>> addr,
>>>>          val = (uint32_t)d->regs[1].sien << 16;
>>>>          break;
>>>>      default:
>>>> -        val = 0;
>>>> +        break;
>>> 
>>> 
>>> There is another function in the same file, having a similar switch
>>> statement. There is no warning for that second tunction, since "val" is 
>>> its
>>> parameter, not a local varioble, like is the case here. This means that 
>>> the
>>> proposed change introduces inconsistency between two functions, therefore
>>> it is better to remove the initialization of "val" to 0, than to remove
>>> this line in "default" section.
>> 
>> Oh, actually I think the warning was for that statement not for the one 
>> patched as it makes more sense there where val is assigned in void 
>> sii3112_reg_write() where it's indeed not used so maybe that was meant to 
>> be patched instead?
>
> Ah, the warning is for hw/ide/sii3112.c:204 but I incorrectly patched 
> hw/ide/sii3112.c:128 =)

Now you may patch both to replace val = 0 with break to keep symmetry. My 
Reviewed-by stands (even if apparently not much use). Thanks for 
Aleksandar for spotting it.

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 05/11] hw/ide/sii3112: Remove dead assignment
  2020-03-21 14:14     ` Philippe Mathieu-Daudé
@ 2020-03-21 14:26       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 14:26 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Michael Tokarev,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Igor Mitsyanko, Laurent Vivier,
	Max Reitz, Andrew Jeffery, qemu-ppc, Paolo Bonzini

On 3/21/20 3:14 PM, Philippe Mathieu-Daudé wrote:
> On 3/21/20 2:39 PM, Aleksandar Markovic wrote:
>>
>>
>> On Saturday, March 21, 2020, Philippe Mathieu-Daudé <philmd@redhat.com 
>> <mailto:philmd@redhat.com>> wrote:
>>
>>     Fix warning reported by Clang static code analyzer:
>>
>>          CC      hw/ide/sii3112.o
>>        hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never 
>> read
>>                val = 0;
>>                ^     ~
>>
>>     Reported-by: Clang Static Analyzer
>>     Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com
>>     <mailto:philmd@redhat.com>>
>>     ---
>>       hw/ide/sii3112.c | 2 +-
>>       1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>     diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c
>>     index 06605d7af2..36f1905ddb 100644
>>     --- a/hw/ide/sii3112.c
>>     +++ b/hw/ide/sii3112.c
>>     @@ -125,7 +125,7 @@ static uint64_t sii3112_reg_read(void *opaque,
>>     hwaddr addr,
>>               val = (uint32_t)d->regs[1].sien << 16;
>>               break;
>>           default:
>>     -        val = 0;
>>     +        break;
>>
>>
>> There is another function in the same file, having a similar switch 
>> statement. There is no warning for that second tunction, since "val" 
>> is its parameter, not a local varioble, like is the case here. This 
>> means that the proposed change introduces inconsistency between two 
>> functions, therefore it is better to remove the initialization of 
>> "val" to 0, than to remove this line in "default" section.
> 
> No clue why there is no warnings emitted for sii3112_reg_write()...
> 
> Do you mind sending a patch?

Don't worry I'll follow up.

> 
>>
>> Regards,
>> Aleksandar
>>
>>           }
>>           trace_sii3112_read(size, addr, val);
>>           return val;
>>     --     2.21.1
>>
>>



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH-for-5.0 01/11] block: Remove dead assignment
  2020-03-21 11:56   ` Aleksandar Markovic
@ 2020-03-21 15:11     ` BALATON Zoltan
  0 siblings, 0 replies; 28+ messages in thread
From: BALATON Zoltan @ 2020-03-21 15:11 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: Fam Zheng, Peter Maydell, Michael S. Tsirkin, Michael Tokarev,
	qemu-devel, qemu-block, qemu-trivial, Markus Armbruster,
	Hervé Poussineau, Joel Stanley, Philippe Mathieu-Daudé,
	Alistair Francis, qemu-arm, Cédric Le Goater, John Snow,
	David Gibson, Kevin Wolf, Andrew Jeffery, Max Reitz,
	Igor Mitsyanko, qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1545 bytes --]

On Sat, 21 Mar 2020, Aleksandar Markovic wrote:
> 12:49 PM Sub, 21.03.2020. Philippe Mathieu-Daudé <philmd@redhat.com> је
> написао/ла:
>>
>> Fix warning reported by Clang static code analyzer:
>>
>>   block.c:3167:5: warning: Value stored to 'ret' is never read
>>       ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>>       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Reported-by: Clang Static Analyzer
>
> Peter, and others,
>
> Is this allowed use of "Reported-by:" mark?
>
> I did not notice it being used this way before. And was under impression
> that all similar tags/marks must be followed by a person, not a tool.

I think there were previous patches with Reported-by: Euler Robot which 
may be similar to this usage.

Regards,
BALATON Zoltan

>
> Regards,
> Aleksandar
>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  block.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/block.c b/block.c
>> index a2542c977b..908c109a8c 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -3164,7 +3164,7 @@ static BlockDriverState *bdrv_open_inherit(const
> char *filename,
>>                                      parent->open_flags, parent->options);
>>      }
>>
>> -    ret = bdrv_fill_options(&options, filename, &flags, &local_err);
>> +    bdrv_fill_options(&options, filename, &flags, &local_err);
>>      if (local_err) {
>>          goto fail;
>>      }
>> --
>> 2.21.1
>>
>>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2020-03-21 15:12 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-21 11:46 [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 01/11] block: Remove dead assignment Philippe Mathieu-Daudé
2020-03-21 11:56   ` Aleksandar Markovic
2020-03-21 15:11     ` BALATON Zoltan
2020-03-21 11:58   ` Laurent Vivier
2020-03-21 13:08     ` Markus Armbruster
2020-03-21 11:46 ` [PATCH-for-5.0 02/11] blockdev: " Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 03/11] hw/i2c/pm_smbus: " Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 04/11] hw/input/adb-kbd: " Philippe Mathieu-Daudé
2020-03-21 12:58   ` BALATON Zoltan
2020-03-21 11:46 ` [PATCH-for-5.0 05/11] hw/ide/sii3112: " Philippe Mathieu-Daudé
2020-03-21 13:04   ` BALATON Zoltan
2020-03-21 13:39   ` Aleksandar Markovic
2020-03-21 14:12     ` BALATON Zoltan
2020-03-21 14:16       ` Philippe Mathieu-Daudé
2020-03-21 14:20         ` BALATON Zoltan
2020-03-21 14:14     ` Philippe Mathieu-Daudé
2020-03-21 14:26       ` Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 06/11] hw/isa/i82378: " Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 07/11] hw/gpio/aspeed_gpio: " Philippe Mathieu-Daudé
2020-03-21 13:22   ` BALATON Zoltan
2020-03-21 14:12     ` Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 08/11] hw/timer/exynos4210_mct: Remove dead assignments Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 09/11] hw/timer/stm32f2xx_timer: Remove dead assignment Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 10/11] hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning Philippe Mathieu-Daudé
2020-03-21 11:46 ` [PATCH-for-5.0 11/11] hw/scsi/esp-pci: Remove dead assignment Philippe Mathieu-Daudé
2020-03-21 12:01 ` [PATCH-for-5.0 00/11] misc: Trivial static code analyzer fixes Aleksandar Markovic
2020-03-21 12:20   ` Philippe Mathieu-Daudé

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).