Thread (159 messages) 159 messages, 9 authors, 2021-03-28
STALE1931d
Revisions (4)
  1. v1 [diff vs current]
  2. v3 [diff vs current]
  3. v4 current
  4. v6 [diff vs current]

[PATCH v5 10/19] fsck.c: call parse_msg_type() early in fsck_set_msg_type()

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-03-17 18:21:56
Subsystem: the rest · Maintainer: Linus Torvalds

There's no reason to defer the calling of parse_msg_type() until after
we've checked if the "id < 0". This is not a hot codepath, and
parse_msg_type() itself may die on invalid input.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 fsck.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fsck.c b/fsck.c
index e1e942821d..341c482fed 100644
--- a/fsck.c
+++ b/fsck.c
@@ -201,11 +201,10 @@ void fsck_set_msg_type(struct fsck_options *options,
 		       const char *msg_id_str, const char *msg_type_str)
 {
 	int msg_id = parse_msg_id(msg_id_str);
-	enum fsck_msg_type msg_type;
+	enum fsck_msg_type msg_type = parse_msg_type(msg_type_str);
 
 	if (msg_id < 0)
 		die("Unhandled message id: %s", msg_id_str);
-	msg_type = parse_msg_type(msg_type_str);
 
 	if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL)
 		die("Cannot demote %s to %s", msg_id_str, msg_type_str);
-- 
2.31.0.260.g719c683c1d
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help