linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] loop: fix passing zero to 'PTR_ERR' warning
@ 2020-06-24  8:48 Ding Xiang
  2020-06-29 20:54 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Ding Xiang @ 2020-06-24  8:48 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel

Fix a static code checker warning:
    drivers/block/loop.c:798 loop_attr_backing_file_show()
    warn: passing zero to 'PTR_ERR'

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 475e1a7..bcada87 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -795,7 +795,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
 	spin_unlock_irq(&lo->lo_lock);
 
 	if (IS_ERR_OR_NULL(p))
-		ret = PTR_ERR(p);
+		ret = PTR_ERR_OR_ZERO(p);
 	else {
 		ret = strlen(p);
 		memmove(buf, p, ret);
-- 
2.7.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] loop: Fix passing zero to 'PTR_ERR' warning
@ 2020-11-12 14:52 YueHaibing
  0 siblings, 0 replies; 3+ messages in thread
From: YueHaibing @ 2020-11-12 14:52 UTC (permalink / raw)
  To: axboe, maco; +Cc: linux-block, linux-kernel, YueHaibing

Fix smatch warning:

drivers/block/loop.c:799 loop_attr_backing_file_show() warn: passing zero to 'PTR_ERR'

file_path() never returns 0, so use IS_ERR instead of
IS_ERR_OR_NULL to fix this.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 83701c2ae3ca..65d392307c6a 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -795,7 +795,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
 		p = file_path(lo->lo_backing_file, buf, PAGE_SIZE - 1);
 	spin_unlock_irq(&lo->lo_lock);
 
-	if (IS_ERR_OR_NULL(p))
+	if (IS_ERR(p))
 		ret = PTR_ERR(p);
 	else {
 		ret = strlen(p);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-12 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24  8:48 [PATCH] loop: fix passing zero to 'PTR_ERR' warning Ding Xiang
2020-06-29 20:54 ` Al Viro
2020-11-12 14:52 [PATCH] loop: Fix " YueHaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).