Skip to contentSkip to conversation

Cleanup in fs/devpts/inode.c

TRIVIAL René Scharfe 6 participants 7 messages Mar 29, 2003

lore
Share & tools
lore
#0 lore raw

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é

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
@@ -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;
 }
#1 lore raw

fs/devpts/inode.c line 174

Quoted 9 lines

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! :)

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
-		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.

#2 lore raw
Quoted 12 lines · On Sat, 29 Mar 2003 [email protected] wrote:

fs/devpts/inode.c line 174

Quoted 9 lines

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! :)

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
-		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

Quoted 1 line

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 ...

#4 lore raw
In reply to [email protected]
Quoted 12 lines · On Sat, 2003-03-29 at 19:29, [email protected] wrote:

fs/devpts/inode.c line 174

Quoted 9 lines

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! :)

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
-		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

Quoted 1 line

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

#5 lore raw
In reply to [email protected]
Quoted 12 lines · --On 29 March 2003 18:29 +0000 [email protected] wrote:

fs/devpts/inode.c line 174

Quoted 9 lines

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! :)

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
-		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

Quoted 1 line

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

#6 lore raw
Quoted 12 lines
Quoted 12 lines

fs/devpts/inode.c line 174

Quoted 9 lines

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! :)

fs/devpts/inode.c renamed from fs/devpts/inode.c.orig +2 -3
-		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

Quoted 4 lines
Quoted 1 line

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 :-).

Quoted 3 lines

I think you meant:

  err = IS_ERR(devpts_mnt) ? PTR_ERR(devpts_mnt) : 0;

Yep.

John.