Skip to contentSkip to conversation

selinux: remove a useless return

PATCH In review Amerigo Wang 4 participants 6 messages Dec 3, 2009 – Dec 8, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: remove a useless return

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>

---

security/selinux/ss/mls.c +1 -1
index b5407f1..718823d 100644
@@ -542,7 +542,7 @@ int mls_compute_sid(struct context *scontext,
 		/* Use the process effective MLS attributes. */
 		return mls_context_cpy_low(newcontext, scontext);
 	default:
-		return -EINVAL;
+		/* Fallthrough */
 	}
 	return -EINVAL;
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Amerigo Wang

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Quoted 16 lines

---

security/selinux/ss/mls.c +1 -1
index b5407f1..718823d 100644
@@ -542,7 +542,7 @@ int mls_compute_sid(struct context *scontext,
 		/* Use the process effective MLS attributes. */
 		return mls_context_cpy_low(newcontext, scontext);
 	default:
-		return -EINVAL;
+		/* Fallthrough */
 	}
 	return -EINVAL;
 }
#2 lore raw
In reply to Amerigo Wang
Quoted 14 lines · Amerigo Wang

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>

---

security/selinux/ss/mls.c +0 -0
index b5407f1..718823d 100644

security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 548

Quoted 8 lines
security/selinux/ss/mls.c +1 -1
@@ -542,7 +542,7 @@ int mls_compute_sid(struct context *scontext,
 		/* Use the process effective MLS attributes. */
 		return mls_context_cpy_low(newcontext, scontext);
 	default:
-		return -EINVAL;
+		/* Fallthrough */
 	}
 	return -EINVAL;
 }

I don't think this compiles. GCC doesn't let you end a switch block with a label.

I also have sent the selinux people a patch that didn't compile by mistake. Afterward I wrote this script so hopefully I won't mess up again.

#!/bin/bash -e

files=$(grep +++ /home/dcarpenter/var/mail/postponed-msgs | cut -f 1 | cut -b 5-)
for file in $files ; do

	file=${file/devel\//}
	file=${file/new\//}
	kchecker $file
	if which sparse | grep -q sparse ; then
		kchecker --sparse $file
	fi

done

You will have to change the path names. Hm.... Also you will have to get the kchecker script from the smatch_data/ directory of smatch
(http://repo.or.cz/w/smatch.git).

regards,
dan carpenter

author
#3 lore raw
Quoted 27 lines · Dan Carpenter
Quoted 14 lines · Amerigo Wang

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>

---

security/selinux/ss/mls.c +0 -0
index b5407f1..718823d 100644

security/selinux/ss/mls.c int mls_compute_sid(struct context *scontext, · line 548

Quoted 8 lines
security/selinux/ss/mls.c +1 -1
@@ -542,7 +542,7 @@ int mls_compute_sid(struct context *scontext,
 		/* Use the process effective MLS attributes. */
 		return mls_context_cpy_low(newcontext, scontext);
 	default:
-		return -EINVAL;
+		/* Fallthrough */
 	}
 	return -EINVAL;
 }

I don't think this compiles. GCC doesn't let you end a switch block with a label.

Quoted 3 lines

I also have sent the selinux people a patch that didn't compile by mistake. Afterward I wrote this script so hopefully I won't mess up again.

Oops, sorry for this, my bad.
Thanks for your patch.

Quoted 12 lines

#!/bin/bash -e

files=$(grep +++ /home/dcarpenter/var/mail/postponed-msgs | cut -f 1 | cut -b 5-)
for file in $files ; do

	file=${file/devel\//}
	file=${file/new\//}
	kchecker $file
	if which sparse | grep -q sparse ; then
		kchecker --sparse $file
	fi
Quoted 6 lines

done

You will have to change the path names. Hm.... Also you will have to get the kchecker script from the smatch_data/ directory of smatch
(http://repo.or.cz/w/smatch.git).

Thanks for the info! I will have a try.

#4 lore raw
In reply to Amerigo Wang
Quoted 6 lines · Amerigo Wang

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

with a fixup for the problem reported by Dan Carpenter.

You should not send out patches without testing them, even when following the advice of the person you're sending them to :-)

Signature · 2 lines
James Morris
<[email protected]>
author
#5 lore raw
Quoted 10 lines · James Morris
Quoted 6 lines · Amerigo Wang

The last return is unreachable, remove the 'return' in default, let it fall through.

Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Quoted 7 lines

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

with a fixup for the problem reported by Dan Carpenter.

You should not send out patches without testing them, even when following the advice of the person you're sending them to :-)

Right, will be careful, thank you!