2005-03-22 22:55:31

by Jesper Juhl

[permalink] [raw]
Subject: [PATCH] devfs: remove a redundant NULL pointer check prior to kfree()


Remove a redundant NULL pointer check prior to kfree(). kfree() has no
problem with NULL pointers.


Signed-off-by: Jesper Juhl <[email protected]>

--- linux-2.6.12-rc1-mm1-orig/fs/devfs/base.c 2005-03-02 08:37:49.000000000 +0100
+++ linux-2.6.12-rc1-mm1/fs/devfs/base.c 2005-03-22 23:51:23.000000000 +0100
@@ -2738,10 +2738,8 @@ static int devfsd_close(struct inode *in
entry = fs_info->devfsd_first_event;
fs_info->devfsd_first_event = NULL;
fs_info->devfsd_last_event = NULL;
- if (fs_info->devfsd_info) {
- kfree(fs_info->devfsd_info);
- fs_info->devfsd_info = NULL;
- }
+ kfree(fs_info->devfsd_info);
+ fs_info->devfsd_info = NULL;
spin_unlock(&fs_info->devfsd_buffer_lock);
fs_info->devfsd_pgrp = 0;
fs_info->devfsd_task = NULL;



2005-03-23 09:04:28

by Denis Vlasenko

[permalink] [raw]
Subject: Re: [PATCH] devfs: remove a redundant NULL pointer check prior to kfree()

On Wednesday 23 March 2005 00:55, Jesper Juhl wrote:
>
> Remove a redundant NULL pointer check prior to kfree(). kfree() has no
> problem with NULL pointers.
>
>
> Signed-off-by: Jesper Juhl <[email protected]>
>
> --- linux-2.6.12-rc1-mm1-orig/fs/devfs/base.c 2005-03-02 08:37:49.000000000 +0100
> +++ linux-2.6.12-rc1-mm1/fs/devfs/base.c 2005-03-22 23:51:23.000000000 +0100
> @@ -2738,10 +2738,8 @@ static int devfsd_close(struct inode *in
> entry = fs_info->devfsd_first_event;
> fs_info->devfsd_first_event = NULL;
> fs_info->devfsd_last_event = NULL;
> - if (fs_info->devfsd_info) {
> - kfree(fs_info->devfsd_info);
> - fs_info->devfsd_info = NULL;
> - }
> + kfree(fs_info->devfsd_info);
> + fs_info->devfsd_info = NULL;
> spin_unlock(&fs_info->devfsd_buffer_lock);
> fs_info->devfsd_pgrp = 0;
> fs_info->devfsd_task = NULL;

IIRC devfs is deprecated and has less than a year to live.
--
vda

2005-03-23 09:24:07

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH] devfs: remove a redundant NULL pointer check prior to kfree()

>IIRC devfs is deprecated and has less than a year to live.

What are we waiting for, then?


Jan Engelhardt
--

2005-03-23 21:49:31

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] devfs: remove a redundant NULL pointer check prior to kfree()

On Wed, 23 Mar 2005, Denis Vlasenko wrote:

> On Wednesday 23 March 2005 00:55, Jesper Juhl wrote:
> >
> > Remove a redundant NULL pointer check prior to kfree(). kfree() has no
> > problem with NULL pointers.
> >
> >
> > Signed-off-by: Jesper Juhl <[email protected]>
> >
> > --- linux-2.6.12-rc1-mm1-orig/fs/devfs/base.c 2005-03-02 08:37:49.000000000 +0100
> > +++ linux-2.6.12-rc1-mm1/fs/devfs/base.c 2005-03-22 23:51:23.000000000 +0100
> > @@ -2738,10 +2738,8 @@ static int devfsd_close(struct inode *in
> > entry = fs_info->devfsd_first_event;
> > fs_info->devfsd_first_event = NULL;
> > fs_info->devfsd_last_event = NULL;
> > - if (fs_info->devfsd_info) {
> > - kfree(fs_info->devfsd_info);
> > - fs_info->devfsd_info = NULL;
> > - }
> > + kfree(fs_info->devfsd_info);
> > + fs_info->devfsd_info = NULL;
> > spin_unlock(&fs_info->devfsd_buffer_lock);
> > fs_info->devfsd_pgrp = 0;
> > fs_info->devfsd_task = NULL;
>
> IIRC devfs is deprecated and has less than a year to live.

Yes, it's going to go away soon, but it /is/ still in the kernel.
As I see it, as long as something is in the kernel there's no reason to
not keep improving it if someone is willing to do the work. And since the
patch is already done why not use it?
For every kernel that has devfs build in this patch will save a few bytes
of kernel memory, and why not give people that tiny bennefit?


--
Jesper Juhl