Skip to contentSkip to conversation

kernel/res_counter.c: remove useless return statement at res_counter_member()

PATCH RESEND In review Jeff Liu 2 participants 3 messages Feb 2, 2013 – Feb 16, 2013

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH RESEND 1/1 kernel/res_counter.c: remove useless return statement at res_counter_member()

The return statement after BUG() is invalid, move BUG() to the default choice of the switch.

---
 kernel/res_counter.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/res_counter.c +2 -3
index ff55247..748a3bc 100644
@@ -135,10 +135,9 @@ res_counter_member(struct res_counter *counter, int member)
 		return &counter->failcnt;
 	case RES_SOFT_LIMIT:
 		return &counter->soft_limit;
+	default:
+		BUG();
 	};
-
-	BUG();
-	return NULL;
 }
 
 ssize_t res_counter_read(struct res_counter *counter, int member,
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 14 lines · On Sat, 02 Feb 2013 13:04:52 +0800 Jeff Liu <[email protected]> wrote:

The return statement after BUG() is invalid, move BUG() to the default choice of the switch.

---
 kernel/res_counter.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/res_counter.c +0 -0
index ff55247..748a3bc 100644
@@ -135,10 +135,9 @@ res_counter_member(struct res_counter *counter, int member)
 		return &counter->failcnt;
 	case RES_SOFT_LIMIT:

kernel/res_counter.c res_counter_member(struct res_counter *counter, int member) · line 143

Quoted 10 lines
kernel/res_counter.c +2 -3
 		return &counter->soft_limit;
+	default:
+		BUG();
 	};
-
-	BUG();
-	return NULL;
 }
 
 ssize_t res_counter_read(struct res_counter *counter, int member,

I expect it was done that way to avoid a hey-theres-no-return-statement warning when CONFIG_BUG=n.

author
#2 lore raw

Hi Andrew and David,

Quoted 26 lines · Andrew Morton
Quoted 23 lines · On Sat, 02 Feb 2013 13:04:52 +0800 Jeff Liu <[email protected]> wrote:

The return statement after BUG() is invalid, move BUG() to the default choice of the switch.

---
 kernel/res_counter.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/res_counter.c +2 -3
index ff55247..748a3bc 100644
@@ -135,10 +135,9 @@ res_counter_member(struct res_counter *counter, int member)
 		return &counter->failcnt;
 	case RES_SOFT_LIMIT:
 		return &counter->soft_limit;
+	default:
+		BUG();
 	};
-
-	BUG();
-	return NULL;
 }
 
Quoted 5 lines

kernel/res_counter.c res_counter_member(struct res_counter *counter, int member) · line 143

Quoted 1 line
kernel/res_counter.c +0 -0
 ssize_t res_counter_read(struct res_counter *counter, int member,

I expect it was done that way to avoid a hey-theres-no-return-statement warning when CONFIG_BUG=n.

Sorry for my late response, I just got back from vacation. So it's better to keep it as it is.

Thanks,
-Jeff