[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH] hw/scsi/megasas:Clean up some redundant code fix Clang warni
From: |
Chenqun (kuhn) |
Subject: |
RE: [PATCH] hw/scsi/megasas:Clean up some redundant code fix Clang warnings |
Date: |
Wed, 11 Mar 2020 06:48:27 +0000 |
>-----Original Message-----
>From: Laurent Vivier [mailto:address@hidden]
>Sent: Tuesday, March 10, 2020 11:01 PM
>To: Chenqun (kuhn) <address@hidden>; qemu-
>address@hidden; address@hidden
>Cc: Fam Zheng <address@hidden>; Hannes Reinecke <address@hidden>;
>Zhanghailiang <address@hidden>; address@hidden;
>Euler Robot <address@hidden>; Paolo Bonzini
><address@hidden>
>Subject: Re: [PATCH] hw/scsi/megasas:Clean up some redundant code fix
>Clang warnings
>
>Le 10/03/2020 à 14:08, Chen Qun a écrit :
>> Here are some redundant statements, we can clean them up.
>> Clang static code analyzer show warning:
>> hw/scsi/megasas.c:1175:32: warning: Value stored to 'max_ld_disks' during
>its initialization is never read
>> uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;
>> ^~~~~~~~~~~~ ~~~~~~~~~~
>> hw/scsi/megasas.c:1183:9: warning: Value stored to 'max_ld_disks' is never
>read
>> max_ld_disks = 0;
>> ^ ~
>
>This has been introduced by:
>
>d97ae3684863 ("megasas: fixup MFI_DCMD_LD_LIST_QUERY")
>
>And modified by:
>
>commit 3f2cd4dd47719497540fb0e0aa0635e127f2838f
>
Yes, this modification makes the first piece of code(the if statement in
megasas.c:1183) look meaningless and resulting in warning.
Maybe we can make this piece code better, although my modification is wrong.
Thanks.
>Author: Hannes Reinecke <address@hidden>
>Date: Wed Oct 29 13:00:07 2014 +0100
>
> megasas: fixup device mapping
>
> Logical drives can only be addressed with the 'target_id' number;
> LUN numbers cannot be selected.
> Physical drives can be selected with both, target and LUN id.
>
> So we should disallow LUN numbers not equal to 0 when in
> RAID mode.
>
> Signed-off-by: Hannes Reinecke <address@hidden>
> Signed-off-by: Paolo Bonzini <address@hidden> ...
>@@ -1143,10 +1152,13 @@ static int
>megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd)
> return MFI_STAT_INVALID_PARAMETER;
> }
> dcmd_size = sizeof(uint32_t) * 2 + 3;
>-
>+ max_ld_disks = cmd->iov_size - dcmd_size;
> if (megasas_is_jbod(s)) {
> max_ld_disks = 0;
> }
>+ if (max_ld_disks > MFI_MAX_LD) {
>+ max_ld_disks = MFI_MAX_LD;
>+ }
> QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
> SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child); ...
>
>
>Thanks,
>Laurent