[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: |
Laurent Vivier |
Subject: |
Re: [PATCH] hw/scsi/megasas:Clean up some redundant code fix Clang warnings |
Date: |
Tue, 10 Mar 2020 16:01:24 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
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
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