2020-05-06 07:52:37

by Zou Wei

[permalink] [raw]
Subject: [PATCH -next] scsi: qla2xxx: Use PTR_ERR_OR_ZERO() to simplify code

Fixes coccicheck warning:

drivers/scsi/qla2xxx/tcm_qla2xxx.c:1488:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Samuel Zou <[email protected]>
---
drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 1f0a185..7c4157e 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1485,10 +1485,8 @@ static int tcm_qla2xxx_check_initiator_node_acl(
sizeof(struct qla_tgt_cmd),
TARGET_PROT_ALL, port_name,
qlat_sess, tcm_qla2xxx_session_cb);
- if (IS_ERR(se_sess))
- return PTR_ERR(se_sess);

- return 0;
+ return PTR_ERR_OR_ZERO(se_sess);
}

static void tcm_qla2xxx_update_sess(struct fc_port *sess, port_id_t s_id,
--
2.6.2


2020-05-06 23:17:18

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH -next] scsi: qla2xxx: Use PTR_ERR_OR_ZERO() to simplify code

On 2020-05-06 00:54, Samuel Zou wrote:
> Fixes coccicheck warning:
>
> drivers/scsi/qla2xxx/tcm_qla2xxx.c:1488:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Samuel Zou <[email protected]>
> ---
> drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 1f0a185..7c4157e 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -1485,10 +1485,8 @@ static int tcm_qla2xxx_check_initiator_node_acl(
> sizeof(struct qla_tgt_cmd),
> TARGET_PROT_ALL, port_name,
> qlat_sess, tcm_qla2xxx_session_cb);
> - if (IS_ERR(se_sess))
> - return PTR_ERR(se_sess);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(se_sess);
> }

Can the Hulk check that verifies where PTR_ERR_OR_ZERO() can be
introduced be deactivated? I think this patch makes the code less
readable instead of making it more readable.

Thanks,

Bart.