* [Patch] Dead code in fs/9p/vfs_inode.c
@ 2006-06-28 22:52 Eric Sesterhenn
2006-06-28 22:55 ` [V9fs-developer] " Russ Cox
0 siblings, 1 reply; 11+ messages in thread
From: Eric Sesterhenn @ 2006-06-28 22:52 UTC (permalink / raw)
To: linux-kernel; +Cc: v9fs-developer
hi,
coverity (id #971) found some dead code. In all error
cases ret is NULL, so we can remove the if statement.
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
--- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29 00:50:53.000000000 +0200
+++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29 00:51:11.000000000 +0200
@@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
error:
kfree(fcall);
- if (ret)
- iput(ret);
-
return ERR_PTR(err);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 22:52 [Patch] Dead code in fs/9p/vfs_inode.c Eric Sesterhenn
@ 2006-06-28 22:55 ` Russ Cox
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Russ Cox @ 2006-06-28 22:55 UTC (permalink / raw)
To: Eric Sesterhenn; +Cc: linux-kernel, v9fs-developer
> coverity (id #971) found some dead code. In all error
> cases ret is NULL, so we can remove the if statement.
>
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
>
> --- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29 00:50:53.000000000 +0200
> +++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29 00:51:11.000000000 +0200
> @@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
>
> error:
> kfree(fcall);
> - if (ret)
> - iput(ret);
> -
> return ERR_PTR(err);
> }
What about when someone changes the code and does have ret != NULL here?
This seems like reasonable defensive programming to me.
Is the official LK policy that we can't have code that trips coverity
checks like this?
Russ
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 22:55 ` [V9fs-developer] " Russ Cox
@ 2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
2006-06-28 23:24 ` Russ Cox
2006-06-29 3:58 ` David Leimbach
2006-06-29 5:27 ` Pekka Enberg
2006-06-29 11:01 ` Jan Engelhardt
2 siblings, 2 replies; 11+ messages in thread
From: Eric Sesterhenn / Snakebyte @ 2006-06-28 23:16 UTC (permalink / raw)
To: Russ Cox; +Cc: Eric Sesterhenn, linux-kernel, v9fs-developer
* Russ Cox (rsc@swtch.com) wrote:
> >coverity (id #971) found some dead code. In all error
> >cases ret is NULL, so we can remove the if statement.
> >
> >Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> >
> >--- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29
> >00:50:53.000000000 +0200
> >+++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29
> >00:51:11.000000000 +0200
> >@@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
> >
> > error:
> > kfree(fcall);
> >- if (ret)
> >- iput(ret);
> >-
> > return ERR_PTR(err);
> > }
>
> What about when someone changes the code and does have ret != NULL here?
> This seems like reasonable defensive programming to me.
>
> Is the official LK policy that we can't have code that trips coverity
> checks like this?
If this is whats agreed upon I will no longer send patches for
such bugs, and mark them as ignore in the coverity system.
But I guess it makes also sense to remove unused code, because I
am not sure if gcc can figure out to remove it. In this case
the generated object file is 10 bytes smaller.
Eric
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
@ 2006-06-28 23:24 ` Russ Cox
2006-06-28 23:41 ` Eric Sesterhenn / Snakebyte
2006-06-29 3:58 ` David Leimbach
1 sibling, 1 reply; 11+ messages in thread
From: Russ Cox @ 2006-06-28 23:24 UTC (permalink / raw)
To: Eric Sesterhenn / Snakebyte; +Cc: linux-kernel, v9fs-developer
> If this is whats agreed upon I will no longer send patches for
> such bugs, and mark them as ignore in the coverity system.
> But I guess it makes also sense to remove unused code, because I
> am not sure if gcc can figure out to remove it. In this case
> the generated object file is 10 bytes smaller.
I wasn't necessarily speaking for the group so much as I was interested
in how coverity was being used and what the rules were.
Thanks for the info.
Russ
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 23:24 ` Russ Cox
@ 2006-06-28 23:41 ` Eric Sesterhenn / Snakebyte
0 siblings, 0 replies; 11+ messages in thread
From: Eric Sesterhenn / Snakebyte @ 2006-06-28 23:41 UTC (permalink / raw)
To: Russ Cox; +Cc: Eric Sesterhenn / Snakebyte, linux-kernel, v9fs-developer
* Russ Cox (rsc@swtch.com) wrote:
> >If this is whats agreed upon I will no longer send patches for
> >such bugs, and mark them as ignore in the coverity system.
> >But I guess it makes also sense to remove unused code, because I
> >am not sure if gcc can figure out to remove it. In this case
> >the generated object file is 10 bytes smaller.
>
> I wasn't necessarily speaking for the group so much as I was interested
> in how coverity was being used and what the rules were.
> Thanks for the info.
guess thats depends on the person looking trough the bugs :)
As far as i know, there are no official rules ( except maybe
to never let gregkh see a false positive :), i just try to
take a look at the coverity reports, and fix whatever I can,
in cleanup cases like this it clearly depends on the maintainer,
what he does with the patch. the coverity guys seem to be pretty
nice in giving accounts away, so you might want to take a look
at this stuff yourself. At the moment about half of the inspected
"bugs" have been marked as invalid or false, to shut coverity up
about clearly defensive programming or false analysis, so i guess
the main part is not to make coverity shut up with a patch, since
marking it as invalid is much less hassle.
Eric
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
2006-06-28 23:24 ` Russ Cox
@ 2006-06-29 3:58 ` David Leimbach
1 sibling, 0 replies; 11+ messages in thread
From: David Leimbach @ 2006-06-29 3:58 UTC (permalink / raw)
To: Eric Sesterhenn / Snakebyte; +Cc: Russ Cox, linux-kernel, v9fs-developer
On 6/28/06, Eric Sesterhenn / Snakebyte <snakebyte@gmx.de> wrote:
> * Russ Cox (rsc@swtch.com) wrote:
> > >coverity (id #971) found some dead code. In all error
> > >cases ret is NULL, so we can remove the if statement.
> > >
> > >Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> > >
> > >--- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29
> > >00:50:53.000000000 +0200
> > >+++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29
> > >00:51:11.000000000 +0200
> > >@@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
> > >
> > > error:
> > > kfree(fcall);
> > >- if (ret)
> > >- iput(ret);
> > >-
> > > return ERR_PTR(err);
> > > }
> >
> > What about when someone changes the code and does have ret != NULL here?
> > This seems like reasonable defensive programming to me.
> >
> > Is the official LK policy that we can't have code that trips coverity
> > checks like this?
>
> If this is whats agreed upon I will no longer send patches for
> such bugs, and mark them as ignore in the coverity system.
> But I guess it makes also sense to remove unused code, because I
> am not sure if gcc can figure out to remove it. In this case
> the generated object file is 10 bytes smaller.
>
> Eric
>
I wonder if anyone cares about those 10 bytes more than the fact that
the code that generates them is written in a defensive manner. :-)
I'd be willing to give up 10 bytes to know that if things changed in
the future that check is still there :-)
Seems like a fairly meaningless optimization to me. No offense
intended toward Eric/Snakebyte, just that sometimes things that seem
like they are optimizations and fixes end up not being either.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 22:55 ` [V9fs-developer] " Russ Cox
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
@ 2006-06-29 5:27 ` Pekka Enberg
2006-06-29 11:01 ` Jan Engelhardt
2 siblings, 0 replies; 11+ messages in thread
From: Pekka Enberg @ 2006-06-29 5:27 UTC (permalink / raw)
To: Russ Cox; +Cc: Eric Sesterhenn, linux-kernel, v9fs-developer
On 6/29/06, Russ Cox <rsc@swtch.com> wrote:
> > error:
> > kfree(fcall);
> > - if (ret)
> > - iput(ret);
> > -
> > return ERR_PTR(err);
> > }
>
> What about when someone changes the code and does have ret != NULL here?
> This seems like reasonable defensive programming to me.
Well, you're not supposed to change code without auditing for things
like this anyway. Also, I fail to see why/how you would change
v9fs_inode_from_fid() for that to happen? I'd say kill the check.
Pekka
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-28 22:55 ` [V9fs-developer] " Russ Cox
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
2006-06-29 5:27 ` Pekka Enberg
@ 2006-06-29 11:01 ` Jan Engelhardt
2006-06-29 15:16 ` Latchesar Ionkov
2 siblings, 1 reply; 11+ messages in thread
From: Jan Engelhardt @ 2006-06-29 11:01 UTC (permalink / raw)
To: Russ Cox; +Cc: Eric Sesterhenn, linux-kernel, v9fs-developer
>> --- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29
>> 00:50:53.000000000 +0200
>> +++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29
>> 00:51:11.000000000 +0200
>> @@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
>>
>> error:
>> kfree(fcall);
>> - if (ret)
>> - iput(ret);
>> -
>> return ERR_PTR(err);
>> }
>
> What about when someone changes the code and does have ret != NULL here?
> This seems like reasonable defensive programming to me.
How about a comment:
kfree(fcall);
/* Currently commented out because ret is NULL in any case.
It is here to remind someone should this condition become
false in future. */
/* if(ret != NULL) */
iput(ret);
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-29 11:01 ` Jan Engelhardt
@ 2006-06-29 15:16 ` Latchesar Ionkov
2006-06-30 13:44 ` Jan Engelhardt
0 siblings, 1 reply; 11+ messages in thread
From: Latchesar Ionkov @ 2006-06-29 15:16 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Russ Cox, Eric Sesterhenn, linux-kernel, v9fs-developer
The comment is longer than the 10 bytes we save :)
I like defensive programming, but I am not sure it is required in this
case. The function is 30 lines long and it is going to be pretty hard
to make a mistake when it is modified.
I am for removing the if.
Thanks,
Lucho
On 6/29/06, Jan Engelhardt <jengelh@linux01.gwdg.de> wrote:
> >> --- linux-2.6.17-git11/fs/9p/vfs_inode.c.orig 2006-06-29
> >> 00:50:53.000000000 +0200
> >> +++ linux-2.6.17-git11/fs/9p/vfs_inode.c 2006-06-29
> >> 00:51:11.000000000 +0200
> >> @@ -386,9 +386,6 @@ v9fs_inode_from_fid(struct v9fs_session_
> >>
> >> error:
> >> kfree(fcall);
> >> - if (ret)
> >> - iput(ret);
> >> -
> >> return ERR_PTR(err);
> >> }
> >
> > What about when someone changes the code and does have ret != NULL here?
> > This seems like reasonable defensive programming to me.
>
>
> How about a comment:
>
> kfree(fcall);
>
> /* Currently commented out because ret is NULL in any case.
> It is here to remind someone should this condition become
> false in future. */
> /* if(ret != NULL) */
> iput(ret);
>
>
> Jan Engelhardt
> --
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-29 15:16 ` Latchesar Ionkov
@ 2006-06-30 13:44 ` Jan Engelhardt
2006-06-30 14:12 ` erik quanstrom
0 siblings, 1 reply; 11+ messages in thread
From: Jan Engelhardt @ 2006-06-30 13:44 UTC (permalink / raw)
To: Latchesar Ionkov; +Cc: Russ Cox, Eric Sesterhenn, linux-kernel, v9fs-developer
> The comment is longer than the 10 bytes we save :)
But comments are not compiled into the final binary,
which is what I wanted to point out. So you always
save your 10 bytes in the object file.
Jan Engelhardt
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [V9fs-developer] [Patch] Dead code in fs/9p/vfs_inode.c
2006-06-30 13:44 ` Jan Engelhardt
@ 2006-06-30 14:12 ` erik quanstrom
0 siblings, 0 replies; 11+ messages in thread
From: erik quanstrom @ 2006-06-30 14:12 UTC (permalink / raw)
To: Jan Engelhardt, Latchesar Ionkov
Cc: Eric Sesterhenn, Russ Cox, linux-kernel, v9fs-developer
saving ten bytes once is not a good reason to do much of anything
in an era of multi-megabyte embedded devices.
i think the argument against code written in speculation is that
it confuses what the code does right now, may never be used and
if used, may be used in a situation that masks a real error.
- erik
Jan Engelhardt <jengelh@linux01.gwdg.de> writes
|
|
| > The comment is longer than the 10 bytes we save :)
|
| But comments are not compiled into the final binary,
| which is what I wanted to point out. So you always
| save your 10 bytes in the object file.
|
|
| Jan Engelhardt
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-06-30 14:12 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-28 22:52 [Patch] Dead code in fs/9p/vfs_inode.c Eric Sesterhenn
2006-06-28 22:55 ` [V9fs-developer] " Russ Cox
2006-06-28 23:16 ` Eric Sesterhenn / Snakebyte
2006-06-28 23:24 ` Russ Cox
2006-06-28 23:41 ` Eric Sesterhenn / Snakebyte
2006-06-29 3:58 ` David Leimbach
2006-06-29 5:27 ` Pekka Enberg
2006-06-29 11:01 ` Jan Engelhardt
2006-06-29 15:16 ` Latchesar Ionkov
2006-06-30 13:44 ` Jan Engelhardt
2006-06-30 14:12 ` erik quanstrom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox