* [TRIVIAL] Cleanup in fs/devpts/inode.c
@ 2003-03-29 18:26 René Scharfe
2003-03-29 18:29 ` john
0 siblings, 1 reply; 7+ messages in thread
From: René Scharfe @ 2003-03-29 18:26 UTC (permalink / raw)
To: linux-kernel; +Cc: trivial
Hi,
this patch un-complicates a small piece of code of the dev/pts
filesystem and decreases the size of the object code by 8 bytes
for my build. Yay! :)
René
--- linux-2.5.66/fs/devpts/inode.c.orig 2003-01-17 13:54:26.000000000 +0100
+++ linux-2.5.66/fs/devpts/inode.c 2003-03-22 14:09:40.000000000 +0100
@@ -170,9 +170,8 @@
int err = register_filesystem(&devpts_fs_type);
if (!err) {
devpts_mnt = kern_mount(&devpts_fs_type);
- err = PTR_ERR(devpts_mnt);
- if (!IS_ERR(devpts_mnt))
- err = 0;
+ if (IS_ERR(devpts_mnt))
+ err = PTR_ERR(devpts_mnt);
}
return err;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 18:26 [TRIVIAL] Cleanup in fs/devpts/inode.c René Scharfe
@ 2003-03-29 18:29 ` john
2003-03-29 18:36 ` Robert P. J. Day
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: john @ 2003-03-29 18:29 UTC (permalink / raw)
To: René Scharfe; +Cc: linux-kernel, trivial
> this patch un-complicates a small piece of code of the dev/pts
> filesystem and decreases the size of the object code by 8 bytes
> for my build. Yay! :)
> - err = PTR_ERR(devpts_mnt);
> - if (!IS_ERR(devpts_mnt))
> - err = 0;
> + if (IS_ERR(devpts_mnt))
> + err = PTR_ERR(devpts_mnt);
Why not use
err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
?
John.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 18:29 ` john
@ 2003-03-29 18:36 ` Robert P. J. Day
2003-03-29 19:12 ` Robert Love
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Robert P. J. Day @ 2003-03-29 18:36 UTC (permalink / raw)
To: john; +Cc: René Scharfe, linux-kernel, trivial
On Sat, 29 Mar 2003 john@grabjohn.com wrote:
> > this patch un-complicates a small piece of code of the dev/pts
> > filesystem and decreases the size of the object code by 8 bytes
> > for my build. Yay! :)
>
> > - err = PTR_ERR(devpts_mnt);
> > - if (!IS_ERR(devpts_mnt))
> > - err = 0;
> > + if (IS_ERR(devpts_mnt))
> > + err = PTR_ERR(devpts_mnt);
>
> Why not use
>
> err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
without my handy-dandy C reference book here, don't you have
that backwards?
and is there some value to using "err = 0" internally rather
than just "0"?
rday
p.s. risking major embarrassment if i didn't remember my
C programming ...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 18:29 ` john
2003-03-29 18:36 ` Robert P. J. Day
@ 2003-03-29 19:12 ` Robert Love
2003-03-29 20:00 ` Felipe Alfaro Solana
2003-03-29 20:14 ` Alex Bligh - linux-kernel
3 siblings, 0 replies; 7+ messages in thread
From: Robert Love @ 2003-03-29 19:12 UTC (permalink / raw)
To: john; +Cc: René Scharfe, linux-kernel, trivial
On Sat, 2003-03-29 at 13:29, john@grabjohn.com wrote:
> Why not use
>
> err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
>
> ?
The point of his cleanup is that you already know err is zero (look
again).
You also got it backward.
Robert Love
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 18:29 ` john
2003-03-29 18:36 ` Robert P. J. Day
2003-03-29 19:12 ` Robert Love
@ 2003-03-29 20:00 ` Felipe Alfaro Solana
2003-03-29 20:14 ` Alex Bligh - linux-kernel
3 siblings, 0 replies; 7+ messages in thread
From: Felipe Alfaro Solana @ 2003-03-29 20:00 UTC (permalink / raw)
To: john; +Cc: René Scharfe, LKML, trivial
On Sat, 2003-03-29 at 19:29, john@grabjohn.com wrote:
> > this patch un-complicates a small piece of code of the dev/pts
> > filesystem and decreases the size of the object code by 8 bytes
> > for my build. Yay! :)
>
> > - err = PTR_ERR(devpts_mnt);
> > - if (!IS_ERR(devpts_mnt))
> > - err = 0;
> > + if (IS_ERR(devpts_mnt))
> > + err = PTR_ERR(devpts_mnt);
>
> Why not use
>
> err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
Ugg! That's really ugly! ;-)
________________________________________________________________________
Felipe Alfaro Solana
Linux Registered User #287198
http://counter.li.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 18:29 ` john
` (2 preceding siblings ...)
2003-03-29 20:00 ` Felipe Alfaro Solana
@ 2003-03-29 20:14 ` Alex Bligh - linux-kernel
2003-03-29 21:39 ` john
3 siblings, 1 reply; 7+ messages in thread
From: Alex Bligh - linux-kernel @ 2003-03-29 20:14 UTC (permalink / raw)
To: john, René Scharfe; +Cc: linux-kernel, trivial, Alex Bligh - linux-kernel
--On 29 March 2003 18:29 +0000 john@grabjohn.com wrote:
>> this patch un-complicates a small piece of code of the dev/pts
>> filesystem and decreases the size of the object code by 8 bytes
>> for my build. Yay! :)
>
>> - err = PTR_ERR(devpts_mnt);
>> - if (!IS_ERR(devpts_mnt))
>> - err = 0;
>> + if (IS_ERR(devpts_mnt))
>> + err = PTR_ERR(devpts_mnt);
>
> Why not use
>
> err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
Perhaps because it inverts the logic, and has a superfluous
assignment causing a warning? :-) I think you meant:
err = IS_ERR(devpts_mnt) ? PTR_ERR(devpts_mnt) : 0;
--
Alex Bligh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [TRIVIAL] Cleanup in fs/devpts/inode.c
2003-03-29 20:14 ` Alex Bligh - linux-kernel
@ 2003-03-29 21:39 ` john
0 siblings, 0 replies; 7+ messages in thread
From: john @ 2003-03-29 21:39 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-kernel, trivial
> >> this patch un-complicates a small piece of code of the dev/pts
> >> filesystem and decreases the size of the object code by 8 bytes
> >> for my build. Yay! :)
> >
> >> - err = PTR_ERR(devpts_mnt);
> >> - if (!IS_ERR(devpts_mnt))
> >> - err = 0;
> >> + if (IS_ERR(devpts_mnt))
> >> + err = PTR_ERR(devpts_mnt);
> >
> > Why not use
> >
> > err = (IS_ERR(devpts_mnt) ? err = 0 : PTR_ERR(devpts_mnt));
>
> Perhaps because it inverts the logic, and has a superfluous
> assignment causing a warning? :-)
Good point :-).
> I think you meant:
>
> err = IS_ERR(devpts_mnt) ? PTR_ERR(devpts_mnt) : 0;
Yep.
John.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-03-29 21:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-29 18:26 [TRIVIAL] Cleanup in fs/devpts/inode.c René Scharfe
2003-03-29 18:29 ` john
2003-03-29 18:36 ` Robert P. J. Day
2003-03-29 19:12 ` Robert Love
2003-03-29 20:00 ` Felipe Alfaro Solana
2003-03-29 20:14 ` Alex Bligh - linux-kernel
2003-03-29 21:39 ` john
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®