Skip to contentSkip to conversation

selinux: remove an unreachable line

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: remove an unreachable line

This line is unreachable, remove it.

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

---

security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }
 
 #ifdef CONFIG_NETLABEL
#1 lore raw
Quoted 1 line · Amerigo Wang

This line is unreachable, remove it.

[]

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

Quoted 10 lines
security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

author
#2 lore raw
Quoted 16 lines · Joe Perches
Quoted 1 line · Amerigo Wang

This line is unreachable, remove it.

[]

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

Quoted 10 lines
security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

This is totally a personal taste, I think.
Either is OK. James, any comments?

#3 lore raw
Quoted 11 lines · Cong Wang
Quoted 8 lines

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

Quoted 5 lines
security/selinux/ss/mls.c +0 -1
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

This is totally a personal taste, I think.
Either is OK. James, any comments?

Leave the default: there but with a comment /* fall through */ instead of the return.

Signature · 2 lines
James Morris
<[email protected]>
author
#4 lore raw
Quoted 9 lines · James Morris
Quoted 7 lines · Cong Wang
Quoted 7 lines

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

Quoted 5 lines
security/selinux/ss/mls.c +0 -1
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

Quoted 6 lines
Quoted 2 lines

This is totally a personal taste, I think.
Either is OK. James, any comments?

Leave the default: there but with a comment /* fall through */ instead of the return.

Ok, will do, thanks.

#5 lore raw
In reply to Cong Wang
Quoted 18 lines · Cong Wang
Quoted 16 lines · Joe Perches
Quoted 1 line · Amerigo Wang

This line is unreachable, remove it.

[]

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

Quoted 10 lines
security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

Quoted 2 lines

This is totally a personal taste, I think.
Either is OK. James, any comments?

I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.

regards,
dan carpenter

author
#6 lore raw
Quoted 17 lines · Dan Carpenter
Quoted 16 lines · Cong Wang
Quoted 15 lines · Joe Perches
Quoted 1 line · Amerigo Wang

This line is unreachable, remove it.

[]

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

Quoted 10 lines
security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

Quoted 6 lines
Quoted 2 lines

This is totally a personal taste, I think.
Either is OK. James, any comments?

I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.

Hmm, aren't those version of gcc buggy? Here we have return values in all cases of 'switch', it shouldn't complain...

#7 lore raw
Quoted 21 lines · Cong Wang
Quoted 20 lines · Dan Carpenter
Quoted 18 lines · Cong Wang
Quoted 15 lines · Joe Perches
Quoted 1 line · Amerigo Wang

This line is unreachable, remove it.

[]

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

Quoted 10 lines
security/selinux/ss/mls.c +0 -1
index b5407f1..a2f1034 100644
@@ -544,7 +544,6 @@ int mls_compute_sid(struct context *scontext,
 	default:
 		return -EINVAL;
 	}
-	return -EINVAL;
 }

I think it's better to remove the default case.

This is totally a personal taste, I think.
Either is OK. James, any comments?

Quoted 6 lines
Quoted 3 lines

I think the last unreachable return might also stop certain versions of gcc complaining about control reaching the end of a non void function.

Hmm, aren't those version of gcc buggy? Here we have return values in all cases of 'switch', it shouldn't complain...

Various versions of gcc do complain.

It's also a bit counter-expectation to the reader to find no return at the end of a non-void function.

As a reader, you then have to scan the cases to find the default: case which isn't necessarily at the end.

If it is a simple

	default:
		return foo;

I think it less jarring to omit default from the switch statement and use

	return foo;
}

at the function exit.