Skip to contentSkip to conversation

kernel/res_counter.c: move BUG() to the default choice of switch at res_counter_member()

PATCH In review Jeff Liu 2 participants 2 messages Jan 25, 2013 Memory management

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/1 kernel/res_counter.c: move BUG() to the default choice of switch at res_counter_member()

It's quite obvious that the return statement after BUG() is invalid, we had better 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 · 7 lines
1.7.9.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 7 lines · Jeff Liu
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,

This doesn't work for CONFIG_BUG=n, you still need a return value. I think the original version was better.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>