Message ID | 20210316035655.2835-5-bvanassche@acm.org |
---|---|
State | New |
Headers | show |
Series | qla2xxx patches for kernel v5.12 and v5.13 | expand |
On Mon, Mar 15, 2021 at 08:56:52PM -0700, Bart Van Assche wrote: > This patch suppresses the following sparse warning: [...] > diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c > index 0677295957bc..5683126e0cbc 100644 > --- a/drivers/scsi/qla2xxx/qla_nx.c > +++ b/drivers/scsi/qla2xxx/qla_nx.c > @@ -1095,7 +1095,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) > int i ; > struct crb_addr_pair *buf; > unsigned long off; > - unsigned offset, n; > + unsigned offset, n = 0; > struct qla_hw_data *ha = vha->hw; > > struct crb_addr_pair { I think sparse is not able to see that n is initialized before it is used. /* Read the signature value from the flash. * Offset 0: Contain signature (0xcafecafe) * Offset 4: Offset and number of addr/value pairs * that present in CRB initialize sequence */ n = 0; if (qla82xx_rom_fast_read(ha, 0, &n) != 0 || n != 0xcafecafeUL || qla82xx_rom_fast_read(ha, 4, &n) != 0) { ql_log(ql_log_fatal, vha, 0x006e, "Error Reading crb_init area: n: %08x.\n", n); return -1; } I suppose this n = 0 should be dropped if n is initialized at the beginning of the function.
On 3/16/21 1:36 AM, Daniel Wagner wrote: > On Mon, Mar 15, 2021 at 08:56:52PM -0700, Bart Van Assche wrote: >> diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c >> index 0677295957bc..5683126e0cbc 100644 >> --- a/drivers/scsi/qla2xxx/qla_nx.c >> +++ b/drivers/scsi/qla2xxx/qla_nx.c >> @@ -1095,7 +1095,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) >> int i ; >> struct crb_addr_pair *buf; >> unsigned long off; >> - unsigned offset, n; >> + unsigned offset, n = 0; >> struct qla_hw_data *ha = vha->hw; >> >> struct crb_addr_pair { > > I think sparse is not able to see that n is initialized > before it is used. > > /* Read the signature value from the flash. > * Offset 0: Contain signature (0xcafecafe) > * Offset 4: Offset and number of addr/value pairs > * that present in CRB initialize sequence > */ > n = 0; > if (qla82xx_rom_fast_read(ha, 0, &n) != 0 || n != 0xcafecafeUL || > qla82xx_rom_fast_read(ha, 4, &n) != 0) { > ql_log(ql_log_fatal, vha, 0x006e, > "Error Reading crb_init area: n: %08x.\n", n); > return -1; > } > > I suppose this n = 0 should be dropped if n is initialized at the > beginning of the function. > . Right, the variable 'n' is already being initialized. The patch that added that initialization code went in after I came up with the above patch. I will drop this patch. Thanks, Bart.
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 0677295957bc..5683126e0cbc 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -1095,7 +1095,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) int i ; struct crb_addr_pair *buf; unsigned long off; - unsigned offset, n; + unsigned offset, n = 0; struct qla_hw_data *ha = vha->hw; struct crb_addr_pair {
This patch suppresses the following sparse warning: qla_nx.c:1218: qla82xx_pinit_from_rom() error: uninitialized symbol 'n'. Cc: Quinn Tran <qutran@marvell.com> Cc: Mike Christie <michael.christie@oracle.com> Cc: Himanshu Madhani <himanshu.madhani@oracle.com> Cc: Daniel Wagner <dwagner@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/qla2xxx/qla_nx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)