diff mbox

[5/6] qcow2-refcount: remove dead assignment

Message ID 1263380087-31821-6-git-send-email-amit.shah@redhat.com
State New
Headers show

Commit Message

Amit Shah Jan. 13, 2010, 10:54 a.m. UTC
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(-)

Comments

Paolo Bonzini Jan. 13, 2010, 11:46 a.m. UTC | #1
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
Amit Shah Jan. 13, 2010, 11:51 a.m. UTC | #2
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
diff mbox

Patch

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