All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 10/14] hppfs: check for IS_ERR() instead of != NULL
@ 2010-09-05 18:32 ` Kulikov Vasiliy
  0 siblings, 0 replies; 4+ messages in thread
From: Kulikov Vasiliy @ 2010-09-05 18:32 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Vasiliy Kulikov, Jeff Dike, Al Viro, Christoph Hellwig,
	user-mode-linux-devel, user-mode-linux-user, linux-kernel

From: Vasiliy Kulikov <segooon@gmail.com>

Function get_inode may return ERR_PTR(...). Check for it.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 Compile tested.

 fs/hppfs/hppfs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 7b02772..e7d6535 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -173,7 +173,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
 
 	err = -ENOMEM;
 	inode = get_inode(ino->i_sb, proc_dentry);
-	if (!inode)
+	if (IS_ERR_OR_NULL(inode))
 		goto out_dput;
 
  	d_add(dentry, inode);
@@ -730,7 +730,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
 
 	err = -ENOMEM;
 	root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
-	if (!root_inode)
+	if (IS_ERR_OR_NULL(root_inode))
 		goto out_mntput;
 
 	sb->s_root = d_alloc_root(root_inode);
-- 
1.7.0.4


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

* [PATCH 10/14] hppfs: check for IS_ERR() instead of != NULL
@ 2010-09-05 18:32 ` Kulikov Vasiliy
  0 siblings, 0 replies; 4+ messages in thread
From: Kulikov Vasiliy @ 2010-09-05 18:32 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Vasiliy Kulikov, Jeff Dike, Al Viro, Christoph Hellwig,
	user-mode-linux-devel, user-mode-linux-user, linux-kernel

From: Vasiliy Kulikov <segooon@gmail.com>

Function get_inode may return ERR_PTR(...). Check for it.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 Compile tested.

 fs/hppfs/hppfs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 7b02772..e7d6535 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -173,7 +173,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
 
 	err = -ENOMEM;
 	inode = get_inode(ino->i_sb, proc_dentry);
-	if (!inode)
+	if (IS_ERR_OR_NULL(inode))
 		goto out_dput;
 
  	d_add(dentry, inode);
@@ -730,7 +730,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
 
 	err = -ENOMEM;
 	root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
-	if (!root_inode)
+	if (IS_ERR_OR_NULL(root_inode))
 		goto out_mntput;
 
 	sb->s_root = d_alloc_root(root_inode);
-- 
1.7.0.4


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

* Re: [PATCH 10/14] hppfs: check for IS_ERR() instead of != NULL
  2010-09-05 18:32 ` Kulikov Vasiliy
@ 2010-09-08 20:11   ` Andrew Morton
  -1 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2010-09-08 20:11 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Jeff Dike, Al Viro, Christoph Hellwig,
	user-mode-linux-devel, user-mode-linux-user, linux-kernel

On Sun,  5 Sep 2010 22:32:56 +0400
Kulikov Vasiliy <segooon@gmail.com> wrote:

> From: Vasiliy Kulikov <segooon@gmail.com>
> 
> Function get_inode may return ERR_PTR(...). Check for it.
> 
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
>  Compile tested.
> 
>  fs/hppfs/hppfs.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
> index 7b02772..e7d6535 100644
> --- a/fs/hppfs/hppfs.c
> +++ b/fs/hppfs/hppfs.c
> @@ -173,7 +173,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
>  
>  	err = -ENOMEM;
>  	inode = get_inode(ino->i_sb, proc_dentry);
> -	if (!inode)
> +	if (IS_ERR_OR_NULL(inode))
>  		goto out_dput;
>  
>   	d_add(dentry, inode);
> @@ -730,7 +730,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
>  
>  	err = -ENOMEM;
>  	root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
> -	if (!root_inode)
> +	if (IS_ERR_OR_NULL(root_inode))
>  		goto out_mntput;
>  
>  	sb->s_root = d_alloc_root(root_inode);

This fix is rather half-and-half.

If we're going to *assume* that an IS_ERR_OR_NULL return from
get_inode() means ENOMEM then there was no point in returning an errno
from get_inode()!  So we can just do this:

--- a/fs/hppfs/hppfs.c~a
+++ a/fs/hppfs/hppfs.c
@@ -683,7 +683,7 @@ static struct inode *get_inode(struct su
 	struct inode *inode = new_inode(sb);
 
 	if (!inode)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	if (S_ISDIR(dentry->d_inode->i_mode)) {
 		inode->i_op = &hppfs_dir_iops;
_


If, however, we want to be able to return other error codes from
get_inode() (which is generally a good idea) then we should change the
callers of get_inode() to use PTR_ERR() and to propagate the error code
upwards.


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

* Re: [PATCH 10/14] hppfs: check for IS_ERR() instead of != NULL
@ 2010-09-08 20:11   ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2010-09-08 20:11 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Jeff Dike, Al Viro, Christoph Hellwig,
	user-mode-linux-devel, user-mode-linux-user, linux-kernel

On Sun,  5 Sep 2010 22:32:56 +0400
Kulikov Vasiliy <segooon@gmail.com> wrote:

> From: Vasiliy Kulikov <segooon@gmail.com>
> 
> Function get_inode may return ERR_PTR(...). Check for it.
> 
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
>  Compile tested.
> 
>  fs/hppfs/hppfs.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
> index 7b02772..e7d6535 100644
> --- a/fs/hppfs/hppfs.c
> +++ b/fs/hppfs/hppfs.c
> @@ -173,7 +173,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
>  
>  	err = -ENOMEM;
>  	inode = get_inode(ino->i_sb, proc_dentry);
> -	if (!inode)
> +	if (IS_ERR_OR_NULL(inode))
>  		goto out_dput;
>  
>   	d_add(dentry, inode);
> @@ -730,7 +730,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
>  
>  	err = -ENOMEM;
>  	root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
> -	if (!root_inode)
> +	if (IS_ERR_OR_NULL(root_inode))
>  		goto out_mntput;
>  
>  	sb->s_root = d_alloc_root(root_inode);

This fix is rather half-and-half.

If we're going to *assume* that an IS_ERR_OR_NULL return from
get_inode() means ENOMEM then there was no point in returning an errno
from get_inode()!  So we can just do this:

--- a/fs/hppfs/hppfs.c~a
+++ a/fs/hppfs/hppfs.c
@@ -683,7 +683,7 @@ static struct inode *get_inode(struct su
 	struct inode *inode = new_inode(sb);
 
 	if (!inode)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	if (S_ISDIR(dentry->d_inode->i_mode)) {
 		inode->i_op = &hppfs_dir_iops;
_


If, however, we want to be able to return other error codes from
get_inode() (which is generally a good idea) then we should change the
callers of get_inode() to use PTR_ERR() and to propagate the error code
upwards.


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

end of thread, other threads:[~2010-09-08 20:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-05 18:32 [PATCH 10/14] hppfs: check for IS_ERR() instead of != NULL Kulikov Vasiliy
2010-09-05 18:32 ` Kulikov Vasiliy
2010-09-08 20:11 ` Andrew Morton
2010-09-08 20:11   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.