Re: [PATCH 7/8] qla2xxx: klocwork - correct the index of array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/18/23 00:58, Nilesh Javali wrote:
+	port_dstate_str_sz = sizeof(port_dstate_str)/sizeof(char *);

Please use ARRAY_SIZE() instead of open-coding it.

@@ -121,7 +123,8 @@ qla2x00_set_fcport_disc_state(fc_port_t *fcport, int state)
  		    old_val, (old_val << shiftbits) | state)) {
  			ql_dbg(ql_dbg_disc, fcport->vha, 0x2134,
  			    "FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n",
-			    fcport->port_name, port_dstate_str[old_val & mask],
+			    fcport->port_name, ((old_val & mask) < port_dstate_str_sz) ?
+				    port_dstate_str[old_val & mask] : "Unknown",
  			    port_dstate_str[state], fcport->d_id.b24);

Please do not introduce more parentheses than necessary. The outer parentheses can be removed from the ((old_val & mask) < port_dstate_str_sz) expression without reducing readability.

Thanks,

Bart.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux