diff mbox series

[v2] scsi: libfc: Fix passing zero to 'PTR_ERR' warning

Message ID 20200819020546.59172-1-yuehaibing@huawei.com (mailing list archive)
State Superseded
Headers show
Series [v2] scsi: libfc: Fix passing zero to 'PTR_ERR' warning | expand

Commit Message

Yue Haibing Aug. 19, 2020, 2:05 a.m. UTC
drivers/scsi/libfc/fc_disc.c:304
 fc_disc_error() warn: passing zero to 'PTR_ERR'

fp maybe NULL in fc_disc_error(), use IS_ERR to handle this.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: use IS_ERR in fc_disc_error()
---
 drivers/scsi/libfc/fc_disc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin K. Petersen Aug. 21, 2020, 2:21 a.m. UTC | #1
YueHaibing,

> diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
> index d8cbc9c0e766..574e842cefed 100644
> --- a/drivers/scsi/libfc/fc_disc.c
> +++ b/drivers/scsi/libfc/fc_disc.c
> @@ -302,7 +302,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
>  	unsigned long delay = 0;
>  
>  	FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
> -		    PTR_ERR(fp), disc->retry_count,
> +		    IS_ERR(fp) ? PTR_ERR(fp) : 0, disc->retry_count,
>  		    FC_DISC_RETRY_LIMIT);
>  
>  	if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {

Why not PTR_ERR_OR_ZERO()?
Yue Haibing Aug. 21, 2020, 11:03 a.m. UTC | #2
On 2020/8/21 10:21, Martin K. Petersen wrote:
> 
> YueHaibing,
> 
>> diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
>> index d8cbc9c0e766..574e842cefed 100644
>> --- a/drivers/scsi/libfc/fc_disc.c
>> +++ b/drivers/scsi/libfc/fc_disc.c
>> @@ -302,7 +302,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
>>  	unsigned long delay = 0;
>>  
>>  	FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
>> -		    PTR_ERR(fp), disc->retry_count,
>> +		    IS_ERR(fp) ? PTR_ERR(fp) : 0, disc->retry_count,
>>  		    FC_DISC_RETRY_LIMIT);
>>  
>>  	if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {
> 
> Why not PTR_ERR_OR_ZERO()?

Thanks, will respin.
>
diff mbox series

Patch

diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index d8cbc9c0e766..574e842cefed 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -302,7 +302,7 @@  static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
 	unsigned long delay = 0;
 
 	FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
-		    PTR_ERR(fp), disc->retry_count,
+		    IS_ERR(fp) ? PTR_ERR(fp) : 0, disc->retry_count,
 		    FC_DISC_RETRY_LIMIT);
 
 	if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {