Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[patch] proc: cleanup: remove unused assignments

0 views
Skip to first unread message

Dan Carpenter

unread,
Mar 6, 2010, 6:20:02 AM3/6/10
to
I removed 3 unused assignments. The first two get reset on the first
statement of their functions. For "err" in root.c we don't return an
error and we don't use the variable again.

Signed-off-by: Dan Carpenter <err...@gmail.com>

diff --git a/fs/proc/base.c b/fs/proc/base.c
index a731084..875d636 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2434,7 +2434,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
const struct pid_entry *p = ptr;
struct inode *inode;
struct proc_inode *ei;
- struct dentry *error = ERR_PTR(-EINVAL);
+ struct dentry *error;

/* Allocate the inode */
error = ERR_PTR(-ENOMEM);
@@ -2784,7 +2784,7 @@ out:

struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
{
- struct dentry *result = ERR_PTR(-ENOENT);
+ struct dentry *result;
struct task_struct *task;
unsigned tgid;
struct pid_namespace *ns;
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 757c069..4258384 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -110,7 +110,6 @@ void __init proc_root_init(void)
if (err)
return;
proc_mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
- err = PTR_ERR(proc_mnt);
if (IS_ERR(proc_mnt)) {
unregister_filesystem(&proc_fs_type);
return;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Oleg Nesterov

unread,
Mar 7, 2010, 3:00:03 PM3/7/10
to
On 03/06, Dan Carpenter wrote:
>
> I removed 3 unused assignments. The first two get reset on the first
> statement of their functions. For "err" in root.c we don't return an
> error and we don't use the variable again.

Looks like the obviously nice cleanup to me.

Serge E. Hallyn

unread,
Mar 7, 2010, 11:20:02 PM3/7/10
to
Quoting Oleg Nesterov (ol...@redhat.com):
> On 03/06, Dan Carpenter wrote:
> >
> > I removed 3 unused assignments. The first two get reset on the first
> > statement of their functions. For "err" in root.c we don't return an
> > error and we don't use the variable again.
>
> Looks like the obviously nice cleanup to me.

Yup. Particularly the last one might confuse someone...

Acked-by: Serge Hallyn <se...@us.ibm.com>

KOSAKI Motohiro

unread,
Mar 8, 2010, 10:30:02 PM3/8/10
to
> I removed 3 unused assignments. The first two get reset on the first
> statement of their functions. For "err" in root.c we don't return an
> error and we don't use the variable again.
>
> Signed-off-by: Dan Carpenter <err...@gmail.com>

Looks good.
Reviewed-by: KOSAKI Motohiro <kosaki....@jp.fujitsu.com>

Helight.Xu

unread,
Mar 11, 2010, 5:20:02 AM3/11/10
to
Dan Carpenter wrote:
> I removed 3 unused assignments. The first two get reset on the first
> statement of their functions. For "err" in root.c we don't return an
> error and we don't use the variable again.
>
> Signed-off-by: Dan Carpenter <err...@gmail.com>
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index a731084..875d636 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2434,7 +2434,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
> const struct pid_entry *p = ptr;
> struct inode *inode;
> struct proc_inode *ei;
> - struct dentry *error = ERR_PTR(-EINVAL);
> + struct dentry *error;
>
> /* Allocate the inode */
> error = ERR_PTR(-ENOMEM);
>
why not do it like this:

@@ -2434,7 +2434,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
const struct pid_entry *p = ptr;
struct inode *inode;
struct proc_inode *ei;
- struct dentry *error = ERR_PTR(-EINVAL);

+ struct dentry *error = ERR_PTR(-ENOMEM);



/* Allocate the inode */

- error = ERR_PTR(-ENOMEM);

> @@ -2784,7 +2784,7 @@ out:
>
> struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
> {
> - struct dentry *result = ERR_PTR(-ENOENT);
> + struct dentry *result;
> struct task_struct *task;
> unsigned tgid;
> struct pid_namespace *ns;
> diff --git a/fs/proc/root.c b/fs/proc/root.c
> index 757c069..4258384 100644
> --- a/fs/proc/root.c
> +++ b/fs/proc/root.c
> @@ -110,7 +110,6 @@ void __init proc_root_init(void)
> if (err)
> return;
> proc_mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
> - err = PTR_ERR(proc_mnt);
> if (IS_ERR(proc_mnt)) {
> unregister_filesystem(&proc_fs_type);
> return;
>
>


--
Zhenwen Xu - Seven Helight
Home Page: http://zhwen.org

Dan Carpenter

unread,
Mar 11, 2010, 5:50:01 AM3/11/10
to

It's a personal preference. If anyone read the code in initializers, I
wouldn't have had had anything to clean up in the first place. ;)

regards,
dan carpenter

0 new messages