diff mbox series

qla2xxx: fix misc smatch warns

Message ID 20240705055437.42434-1-njavali@marvell.com
State New
Headers show
Series qla2xxx: fix misc smatch warns | expand

Commit Message

Nilesh Javali July 5, 2024, 5:54 a.m. UTC
Fix always true condition warn reported by kernel test robot,

smatch warnings:
drivers/scsi/qla2xxx/qla_inline.h:645 val_is_in_range() warn: always true condition '(val <= 4294967295) => (0-u32max <= u32max)'

Fix missing error code warn reported by kernel test robot and
other misc warnings,

smatch warnings:
drivers/scsi/qla2xxx/qla_sup.c:3581 qla24xx_get_flash_version() warn: missing error code? 'ret'

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/oe-kbuild-all/202406210538.w875N70K-lkp@intel.com/
Closes: https://lore.kernel.org/all/202406210815.rPDRDMBi-lkp@intel.com/
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_inline.h | 12 +-----------
 drivers/scsi/qla2xxx/qla_sup.c    | 16 ++++++++--------
 2 files changed, 9 insertions(+), 19 deletions(-)

Comments

Himanshu Madhani July 8, 2024, 8:45 p.m. UTC | #1
On 7/4/24 10:54 PM, Nilesh Javali wrote:
> Fix always true condition warn reported by kernel test robot,
> 
> smatch warnings:
> drivers/scsi/qla2xxx/qla_inline.h:645 val_is_in_range() warn: always true condition '(val <= 4294967295) => (0-u32max <= u32max)'
> 
> Fix missing error code warn reported by kernel test robot and
> other misc warnings,
> 
> smatch warnings:
> drivers/scsi/qla2xxx/qla_sup.c:3581 qla24xx_get_flash_version() warn: missing error code? 'ret'
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406210538.w875N70K-lkp@intel.com/
> Closes: https://lore.kernel.org/all/202406210815.rPDRDMBi-lkp@intel.com/
> Signed-off-by: Nilesh Javali <njavali@marvell.com>
> ---
>   drivers/scsi/qla2xxx/qla_inline.h | 12 +-----------
>   drivers/scsi/qla2xxx/qla_sup.c    | 16 ++++++++--------
>   2 files changed, 9 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
> index 30e332806f86..ef4b3cc1cd77 100644
> --- a/drivers/scsi/qla2xxx/qla_inline.h
> +++ b/drivers/scsi/qla2xxx/qla_inline.h
> @@ -634,17 +634,7 @@ static inline int qla_mapq_alloc_qp_cpu_map(struct qla_hw_data *ha)
>   
>   static inline bool val_is_in_range(u32 val, u32 start, u32 end)
>   {
> -	if (start < end) {
> -		if (val >= start && val <= end)
> -			return true;
> -		else
> -			return false;
> -	}
> -
> -	/* @end has wrapped */
> -	if (val >= start  && val <= 0xffffffffu)
> -		return true;
> -	if (val <= end)
> +	if (val >= start && val <= end)
>   		return true;
>   	else
>   		return false;
> diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
> index f0a1c5381075..6d16546e1729 100644
> --- a/drivers/scsi/qla2xxx/qla_sup.c
> +++ b/drivers/scsi/qla2xxx/qla_sup.c
> @@ -3433,7 +3433,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   	struct active_regions active_regions = { };
>   
>   	if (IS_P3P_TYPE(ha))
> -		return ret;
> +		return QLA_SUCCESS;
>   
>   	if (!mbuf)
>   		return QLA_FUNCTION_FAILED;
> @@ -3457,7 +3457,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   		if (ret) {
>   			ql_log(ql_log_info, vha, 0x017d,
>   			    "Unable to read PCI EXP Rom Header(%x).\n", ret);
> -			break;
> +			return QLA_FUNCTION_FAILED;
>   		}
>   
>   		bcode = mbuf + (pcihdr % 4);
> @@ -3465,8 +3465,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   			/* No signature */
>   			ql_log(ql_log_fatal, vha, 0x0059,
>   			    "No matching ROM signature.\n");
> -			ret = QLA_FUNCTION_FAILED;
> -			break;
> +			return QLA_FUNCTION_FAILED;
>   		}
>   
>   		/* Locate PCI data structure. */
> @@ -3476,7 +3475,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   		if (ret) {
>   			ql_log(ql_log_info, vha, 0x018e,
>   			    "Unable to read PCI Data Structure (%x).\n", ret);
> -			break;
> +			return QLA_FUNCTION_FAILED;
>   		}
>   
>   		bcode = mbuf + (pcihdr % 4);
> @@ -3487,8 +3486,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   			ql_log(ql_log_fatal, vha, 0x005a,
>   			    "PCI data struct not found pcir_adr=%x.\n", pcids);
>   			ql_dump_buffer(ql_dbg_init, vha, 0x0059, dcode, 32);
> -			ret = QLA_FUNCTION_FAILED;
> -			break;
> +			return QLA_FUNCTION_FAILED;
>   		}
>   
>   		/* Read version */
> @@ -3544,6 +3542,7 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   	if (ret) {
>   		ql_log(ql_log_info, vha, 0x019e,
>   		    "Unable to read FW version (%x).\n", ret);
> +		return ret;
>   	} else {
>   		if (qla24xx_risc_firmware_invalid(dcode)) {
>   			ql_log(ql_log_warn, vha, 0x005f,
> @@ -3573,12 +3572,13 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
>   	if (ret) {
>   		ql_log(ql_log_info, vha, 0x019f,
>   		    "Unable to read Gold FW version (%x).\n", ret);
> +		return ret;
>   	} else {
>   		if (qla24xx_risc_firmware_invalid(dcode)) {
>   			ql_log(ql_log_warn, vha, 0x0056,
>   			    "Unrecognized golden fw at %#x.\n", faddr);
>   			ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32);
> -			return ret;
> +			return QLA_FUNCTION_FAILED;
>   		}
>   
>   		for (i = 0; i < 4; i++)

Looks Good.

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 30e332806f86..ef4b3cc1cd77 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -634,17 +634,7 @@  static inline int qla_mapq_alloc_qp_cpu_map(struct qla_hw_data *ha)
 
 static inline bool val_is_in_range(u32 val, u32 start, u32 end)
 {
-	if (start < end) {
-		if (val >= start && val <= end)
-			return true;
-		else
-			return false;
-	}
-
-	/* @end has wrapped */
-	if (val >= start  && val <= 0xffffffffu)
-		return true;
-	if (val <= end)
+	if (val >= start && val <= end)
 		return true;
 	else
 		return false;
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index f0a1c5381075..6d16546e1729 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -3433,7 +3433,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 	struct active_regions active_regions = { };
 
 	if (IS_P3P_TYPE(ha))
-		return ret;
+		return QLA_SUCCESS;
 
 	if (!mbuf)
 		return QLA_FUNCTION_FAILED;
@@ -3457,7 +3457,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 		if (ret) {
 			ql_log(ql_log_info, vha, 0x017d,
 			    "Unable to read PCI EXP Rom Header(%x).\n", ret);
-			break;
+			return QLA_FUNCTION_FAILED;
 		}
 
 		bcode = mbuf + (pcihdr % 4);
@@ -3465,8 +3465,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 			/* No signature */
 			ql_log(ql_log_fatal, vha, 0x0059,
 			    "No matching ROM signature.\n");
-			ret = QLA_FUNCTION_FAILED;
-			break;
+			return QLA_FUNCTION_FAILED;
 		}
 
 		/* Locate PCI data structure. */
@@ -3476,7 +3475,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 		if (ret) {
 			ql_log(ql_log_info, vha, 0x018e,
 			    "Unable to read PCI Data Structure (%x).\n", ret);
-			break;
+			return QLA_FUNCTION_FAILED;
 		}
 
 		bcode = mbuf + (pcihdr % 4);
@@ -3487,8 +3486,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 			ql_log(ql_log_fatal, vha, 0x005a,
 			    "PCI data struct not found pcir_adr=%x.\n", pcids);
 			ql_dump_buffer(ql_dbg_init, vha, 0x0059, dcode, 32);
-			ret = QLA_FUNCTION_FAILED;
-			break;
+			return QLA_FUNCTION_FAILED;
 		}
 
 		/* Read version */
@@ -3544,6 +3542,7 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 	if (ret) {
 		ql_log(ql_log_info, vha, 0x019e,
 		    "Unable to read FW version (%x).\n", ret);
+		return ret;
 	} else {
 		if (qla24xx_risc_firmware_invalid(dcode)) {
 			ql_log(ql_log_warn, vha, 0x005f,
@@ -3573,12 +3572,13 @@  qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf)
 	if (ret) {
 		ql_log(ql_log_info, vha, 0x019f,
 		    "Unable to read Gold FW version (%x).\n", ret);
+		return ret;
 	} else {
 		if (qla24xx_risc_firmware_invalid(dcode)) {
 			ql_log(ql_log_warn, vha, 0x0056,
 			    "Unrecognized golden fw at %#x.\n", faddr);
 			ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32);
-			return ret;
+			return QLA_FUNCTION_FAILED;
 		}
 
 		for (i = 0; i < 4; i++)