qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] Remove some dead assignments from clang analyzer report
@ 2010-01-13 10:54 Amit Shah
  2010-01-13 10:54 ` [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment Amit Shah
  0 siblings, 1 reply; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

Running the static checker clang-analyzer on the qemu sources, I found
a few dead assignments.

This patchset removes a few of those.

Amit Shah (6):
  vl.c: Remove dead assignment
  virtio: net: remove dead assignment
  x86: translate.c: remove dead assignment
  hw/vga.c: remove dead assignment
  qcow2-refcount: remove dead assignment
  json-parser: remove dead increment

 block/qcow2-refcount.c  |    1 -
 hw/vga.c                |    1 -
 hw/virtio-net.c         |    2 +-
 json-parser.c           |    2 --
 target-i386/translate.c |    2 --
 vl.c                    |    6 +-----
 6 files changed, 2 insertions(+), 12 deletions(-)

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

* [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment
  2010-01-13 10:54 [Qemu-devel] [PATCH 0/6] Remove some dead assignments from clang analyzer report Amit Shah
@ 2010-01-13 10:54 ` Amit Shah
  2010-01-13 10:54   ` [Qemu-devel] [PATCH 2/6] virtio: net: remove " Amit Shah
  2010-01-13 23:27   ` [Qemu-devel] [PATCH 1/6] vl.c: Remove " Anthony Liguori
  0 siblings, 2 replies; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Andre Przywara

clang-analyzer pointed out the value of 'sockets' is never reused.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
CC: Andre Przywara <andre.przywara@amd.com>
---
 vl.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/vl.c b/vl.c
index b048e89..e49e7bd 100644
--- a/vl.c
+++ b/vl.c
@@ -2613,17 +2613,13 @@ static void smp_parse(const char *optarg)
         threads = threads > 0 ? threads : 1;
         if (smp == 0) {
             smp = cores * threads * sockets;
-        } else {
-            sockets = smp / (cores * threads);
         }
     } else {
         if (cores == 0) {
             threads = threads > 0 ? threads : 1;
             cores = smp / (sockets * threads);
         } else {
-            if (sockets == 0) {
-                sockets = smp / (cores * threads);
-            } else {
+            if (sockets) {
                 threads = smp / (cores * sockets);
             }
         }
-- 
1.6.2.5

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

* [Qemu-devel] [PATCH 2/6] virtio: net: remove dead assignment
  2010-01-13 10:54 ` [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment Amit Shah
@ 2010-01-13 10:54   ` Amit Shah
  2010-01-13 10:54     ` [Qemu-devel] [PATCH 3/6] x86: translate.c: " Amit Shah
  2010-01-13 20:51     ` [Qemu-devel] Re: [PATCH 2/6] virtio: net: " Michael S. Tsirkin
  2010-01-13 23:27   ` [Qemu-devel] [PATCH 1/6] vl.c: Remove " Anthony Liguori
  1 sibling, 2 replies; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

clang-analyzer points out value assigned to 'len' is not used.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 02d9180..6e48997 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -532,7 +532,7 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
         int len, total;
         struct iovec sg[VIRTQUEUE_MAX_SIZE];
 
-        len = total = 0;
+        total = 0;
 
         if ((i != 0 && !n->mergeable_rx_bufs) ||
             virtqueue_pop(n->rx_vq, &elem) == 0) {
-- 
1.6.2.5

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

* [Qemu-devel] [PATCH 3/6] x86: translate.c: remove dead assignment
  2010-01-13 10:54   ` [Qemu-devel] [PATCH 2/6] virtio: net: remove " Amit Shah
@ 2010-01-13 10:54     ` Amit Shah
  2010-01-13 10:54       ` [Qemu-devel] [PATCH 4/6] hw/vga.c: " Amit Shah
  2010-01-13 20:51     ` [Qemu-devel] Re: [PATCH 2/6] virtio: net: " Michael S. Tsirkin
  1 sibling, 1 reply; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

clang-analyzer points out a redundant assignment.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 target-i386/translate.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/target-i386/translate.c b/target-i386/translate.c
index 511a4ea..8078112 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -2207,8 +2207,6 @@ static void gen_add_A0_ds_seg(DisasContext *s)
     if (s->override >= 0) {
         override = s->override;
         must_add_seg = 1;
-    } else {
-        override = R_DS;
     }
     if (must_add_seg) {
 #ifdef TARGET_X86_64
-- 
1.6.2.5

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

* [Qemu-devel] [PATCH 4/6] hw/vga.c: remove dead assignment
  2010-01-13 10:54     ` [Qemu-devel] [PATCH 3/6] x86: translate.c: " Amit Shah
@ 2010-01-13 10:54       ` Amit Shah
  2010-01-13 10:54         ` [Qemu-devel] [PATCH 5/6] qcow2-refcount: " Amit Shah
  0 siblings, 1 reply; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

clang-analyzer points out a redundant assignment.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/vga.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/vga.c b/hw/vga.c
index d05f1f9..6a1a059 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1303,7 +1303,6 @@ static void vga_draw_text(VGACommonState *s, int full_update)
     line_offset = s->line_offset;
 
     vga_get_text_resolution(s, &width, &height, &cw, &cheight);
-    x_incr = cw * ((ds_get_bits_per_pixel(s->ds) + 7) >> 3);
     if ((height * width) > CH_ATTR_SIZE) {
         /* better than nothing: exit if transient size is too big */
         return;
-- 
1.6.2.5

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

* [Qemu-devel] [PATCH 5/6] qcow2-refcount: remove dead assignment
  2010-01-13 10:54       ` [Qemu-devel] [PATCH 4/6] hw/vga.c: " Amit Shah
@ 2010-01-13 10:54         ` Amit Shah
  2010-01-13 10:54           ` [Qemu-devel] [PATCH 6/6] json-parser: remove dead increment Amit Shah
  2010-01-13 11:46           ` [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment Paolo Bonzini
  0 siblings, 2 replies; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

clang-analyzer points out a redundant assignment.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 block/qcow2-refcount.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 54b19f8..3a2d44a 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -511,7 +511,6 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
     l2_table = NULL;
     l1_table = NULL;
     l1_size2 = l1_size * sizeof(uint64_t);
-    l1_allocated = 0;
     if (l1_table_offset != s->l1_table_offset) {
         if (l1_size2 != 0) {
             l1_table = qemu_mallocz(align_offset(l1_size2, 512));
-- 
1.6.2.5

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

* [Qemu-devel] [PATCH 6/6] json-parser: remove dead increment
  2010-01-13 10:54         ` [Qemu-devel] [PATCH 5/6] qcow2-refcount: " Amit Shah
@ 2010-01-13 10:54           ` Amit Shah
  2010-01-13 11:46           ` [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment Paolo Bonzini
  1 sibling, 0 replies; 11+ messages in thread
From: Amit Shah @ 2010-01-13 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

clang-analyzer points out a redundant increment.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 json-parser.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/json-parser.c b/json-parser.c
index 7624c0f..e04932f 100644
--- a/json-parser.c
+++ b/json-parser.c
@@ -247,8 +247,6 @@ static QString *qstring_from_escaped_str(JSONParserContext *ctxt, QObject *token
         }
     }
 
-    ptr++;
-
     return str;
 
 out:
-- 
1.6.2.5

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

* [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment
  2010-01-13 10:54         ` [Qemu-devel] [PATCH 5/6] qcow2-refcount: " Amit Shah
  2010-01-13 10:54           ` [Qemu-devel] [PATCH 6/6] json-parser: remove dead increment Amit Shah
@ 2010-01-13 11:46           ` Paolo Bonzini
  2010-01-13 11:51             ` Amit Shah
  1 sibling, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2010-01-13 11:46 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-devel

On 01/13/2010 11:54 AM, Amit Shah wrote:
> clang-analyzer points out a redundant assignment.
>
> Signed-off-by: Amit Shah<amit.shah@redhat.com>
> ---
>   block/qcow2-refcount.c |    1 -
>   1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 54b19f8..3a2d44a 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -511,7 +511,6 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
>       l2_table = NULL;
>       l1_table = NULL;
>       l1_size2 = l1_size * sizeof(uint64_t);
> -    l1_allocated = 0;
>       if (l1_table_offset != s->l1_table_offset) {
>           if (l1_size2 != 0) {
>               l1_table = qemu_mallocz(align_offset(l1_size2, 512));

I'd remove the l1_allocated = 0 assignment in the else branch instead 
(the idea is, assign l1_allocated = 1 right after any qemu_malloc.

Paolo

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

* [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment
  2010-01-13 11:46           ` [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment Paolo Bonzini
@ 2010-01-13 11:51             ` Amit Shah
  0 siblings, 0 replies; 11+ messages in thread
From: Amit Shah @ 2010-01-13 11:51 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On (Wed) Jan 13 2010 [12:46:22], Paolo Bonzini wrote:
> On 01/13/2010 11:54 AM, Amit Shah wrote:
>> clang-analyzer points out a redundant assignment.
>>
>> Signed-off-by: Amit Shah<amit.shah@redhat.com>
>> ---
>>   block/qcow2-refcount.c |    1 -
>>   1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
>> index 54b19f8..3a2d44a 100644
>> --- a/block/qcow2-refcount.c
>> +++ b/block/qcow2-refcount.c
>> @@ -511,7 +511,6 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
>>       l2_table = NULL;
>>       l1_table = NULL;
>>       l1_size2 = l1_size * sizeof(uint64_t);
>> -    l1_allocated = 0;
>>       if (l1_table_offset != s->l1_table_offset) {
>>           if (l1_size2 != 0) {
>>               l1_table = qemu_mallocz(align_offset(l1_size2, 512));
>
> I'd remove the l1_allocated = 0 assignment in the else branch instead  
> (the idea is, assign l1_allocated = 1 right after any qemu_malloc.

I thought about that too, but since the else{} part has some other code,
I decided to go that way.

(Also that if such assignments aren't placed in common code, they'll be
pointed out when someone tries to use them with the default undefined
value.)

		Amit

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

* [Qemu-devel] Re: [PATCH 2/6] virtio: net: remove dead assignment
  2010-01-13 10:54   ` [Qemu-devel] [PATCH 2/6] virtio: net: remove " Amit Shah
  2010-01-13 10:54     ` [Qemu-devel] [PATCH 3/6] x86: translate.c: " Amit Shah
@ 2010-01-13 20:51     ` Michael S. Tsirkin
  1 sibling, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2010-01-13 20:51 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-devel

On Wed, Jan 13, 2010 at 04:24:43PM +0530, Amit Shah wrote:
> clang-analyzer points out value assigned to 'len' is not used.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/virtio-net.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 02d9180..6e48997 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -532,7 +532,7 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
>          int len, total;
>          struct iovec sg[VIRTQUEUE_MAX_SIZE];
>  
> -        len = total = 0;
> +        total = 0;
>  
>          if ((i != 0 && !n->mergeable_rx_bufs) ||
>              virtqueue_pop(n->rx_vq, &elem) == 0) {
> -- 
> 1.6.2.5
> 
> 

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

* Re: [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment
  2010-01-13 10:54 ` [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment Amit Shah
  2010-01-13 10:54   ` [Qemu-devel] [PATCH 2/6] virtio: net: remove " Amit Shah
@ 2010-01-13 23:27   ` Anthony Liguori
  1 sibling, 0 replies; 11+ messages in thread
From: Anthony Liguori @ 2010-01-13 23:27 UTC (permalink / raw)
  To: Amit Shah; +Cc: Andre Przywara, qemu-devel

On 01/13/2010 04:54 AM, Amit Shah wrote:
> clang-analyzer pointed out the value of 'sockets' is never reused.
>
> Signed-off-by: Amit Shah<amit.shah@redhat.com>
> CC: Andre Przywara<andre.przywara@amd.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   vl.c |    6 +-----
>   1 files changed, 1 insertions(+), 5 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index b048e89..e49e7bd 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2613,17 +2613,13 @@ static void smp_parse(const char *optarg)
>           threads = threads>  0 ? threads : 1;
>           if (smp == 0) {
>               smp = cores * threads * sockets;
> -        } else {
> -            sockets = smp / (cores * threads);
>           }
>       } else {
>           if (cores == 0) {
>               threads = threads>  0 ? threads : 1;
>               cores = smp / (sockets * threads);
>           } else {
> -            if (sockets == 0) {
> -                sockets = smp / (cores * threads);
> -            } else {
> +            if (sockets) {
>                   threads = smp / (cores * sockets);
>               }
>           }
>    

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

end of thread, other threads:[~2010-01-13 23:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13 10:54 [Qemu-devel] [PATCH 0/6] Remove some dead assignments from clang analyzer report Amit Shah
2010-01-13 10:54 ` [Qemu-devel] [PATCH 1/6] vl.c: Remove dead assignment Amit Shah
2010-01-13 10:54   ` [Qemu-devel] [PATCH 2/6] virtio: net: remove " Amit Shah
2010-01-13 10:54     ` [Qemu-devel] [PATCH 3/6] x86: translate.c: " Amit Shah
2010-01-13 10:54       ` [Qemu-devel] [PATCH 4/6] hw/vga.c: " Amit Shah
2010-01-13 10:54         ` [Qemu-devel] [PATCH 5/6] qcow2-refcount: " Amit Shah
2010-01-13 10:54           ` [Qemu-devel] [PATCH 6/6] json-parser: remove dead increment Amit Shah
2010-01-13 11:46           ` [Qemu-devel] Re: [PATCH 5/6] qcow2-refcount: remove dead assignment Paolo Bonzini
2010-01-13 11:51             ` Amit Shah
2010-01-13 20:51     ` [Qemu-devel] Re: [PATCH 2/6] virtio: net: " Michael S. Tsirkin
2010-01-13 23:27   ` [Qemu-devel] [PATCH 1/6] vl.c: Remove " Anthony Liguori

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