Skip to contentSkip to conversation

ocfs2: fix a static checker warning

PATCH Applied Gang He 3 participants 4 messages May 23, 2017 – May 24, 2017 OCFS2

lore
Share & tools
lore

Gang He

author
#0 lore raw

PATCH v2 1/1 ocfs2: fix a static checker warning

This patch will fix a static code checker warning, which looks like below,
fs/ocfs2/inode.c:179 ocfs2_iget()
warn: passing zero to 'ERR_PTR'

this warning was caused by the
commit d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check"). after apply this patch, the error return value will not be NULL(zero).

---
 fs/ocfs2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +1 -1
index 382401d..1a1e007 100644
@@ -136,7 +136,7 @@ struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
 			 int sysfile_type)
 {
-	int rc = 0;
+	int rc = -ESTALE;
 	struct inode *inode = NULL;
 	struct super_block *sb = osb->sb;
 	struct ocfs2_find_inode_args args;
Signature · 1 line
1.8.5.6
#1 lore raw
Quoted 19 lines · On Tue, 23 May 2017 13:17:14 +0800 Gang He <[email protected]> wrote:

This patch will fix a static code checker warning, which looks like below,
fs/ocfs2/inode.c:179 ocfs2_iget()
warn: passing zero to 'ERR_PTR'

this warning was caused by the
commit d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check"). after apply this patch, the error return value will not be NULL(zero).

---
 fs/ocfs2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +0 -0
index 382401d..1a1e007 100644

fs/ocfs2/inode.c struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno) · line 142

Quoted 8 lines
fs/ocfs2/inode.c +1 -1
@@ -136,7 +136,7 @@ struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
 			 int sysfile_type)
 {
-	int rc = 0;
+	int rc = -ESTALE;
 	struct inode *inode = NULL;
 	struct super_block *sb = osb->sb;
 	struct ocfs2_find_inode_args args;

hm, OK, thanks. The resulting code still looks rather weird. Could someone who works in this area please take a look?

author
#2 lore raw

Hello Andrew,

I am sorry that I did not write which static code checker tool, since I did not get the name from Dan, I think the tool should be like Coverity code checking tool.
Second, set the initial value of local variable rc to -ESTALE from zero, this change will make the code logic is strict consistent with before the commit d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check"), although it is very difficult to meet this problem in the real environment.

Thanks
Gang

Quoted 35 lines
Quoted 1 line
Quoted 1 line

fs/ocfs2/inode.c struct inode *ocfs2_ilookup(struct super_block *sb, u64

Quoted 19 lines · On Tue, 23 May 2017 13:17:14 +0800 Gang He <[email protected]> wrote:

This patch will fix a static code checker warning, which looks like below,
fs/ocfs2/inode.c:179 ocfs2_iget()
warn: passing zero to 'ERR_PTR'

this warning was caused by the
commit d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check"). after apply this patch, the error return value will not be NULL(zero).

---
 fs/ocfs2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +0 -0
index 382401d..1a1e007 100644
@@ -136,7 +136,7 @@ struct inode *ocfs2_ilookup(struct super_block *sb, u64 

blkno)

fs/ocfs2/inode.c struct inode *ocfs2_ilookup(struct super_block *sb, u64 · line 136

Quoted 1 line
fs/ocfs2/inode.c +0 -0
 struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned 

flags,

fs/ocfs2/inode.c struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno) · line 142

Quoted 7 lines
fs/ocfs2/inode.c +1 -1
 			 int sysfile_type)
 {
-	int rc = 0;
+	int rc = -ESTALE;
 	struct inode *inode = NULL;
 	struct super_block *sb = osb->sb;
 	struct ocfs2_find_inode_args args;

hm, OK, thanks. The resulting code still looks rather weird. Could someone who works in this area please take a look?

Reviewed-by on v2 1/1
#3 lore raw
In reply to Gang He
Quoted 10 lines · Gang He

This patch will fix a static code checker warning, which looks like below,
fs/ocfs2/inode.c:179 ocfs2_iget()
warn: passing zero to 'ERR_PTR'

this warning was caused by the
commit d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check"). after apply this patch, the error return value will not be NULL(zero).

Looks good to me.

Quoted 17 lines
---
  fs/ocfs2/inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +1 -1
index 382401d..1a1e007 100644
@@ -136,7 +136,7 @@ struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
  struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
  			 int sysfile_type)
  {
-	int rc = 0;
+	int rc = -ESTALE;
  	struct inode *inode = NULL;
  	struct super_block *sb = osb->sb;
  	struct ocfs2_find_inode_args args;