Skip to content

Commit c72da1a

Browse files
avargitster
authored andcommitted
fsck.c: call parse_msg_type() early in fsck_set_msg_type()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 30cf618 commit c72da1a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fsck.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ void fsck_set_msg_type(struct fsck_options *options,
201201
const char *msg_id_str, const char *msg_type_str)
202202
{
203203
int msg_id = parse_msg_id(msg_id_str);
204-
enum fsck_msg_type msg_type;
204+
enum fsck_msg_type msg_type = parse_msg_type(msg_type_str);
205205

206206
if (msg_id < 0)
207207
die("Unhandled message id: %s", msg_id_str);
208-
msg_type = parse_msg_type(msg_type_str);
209208

210209
if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL)
211210
die("Cannot demote %s to %s", msg_id_str, msg_type_str);

0 commit comments

Comments
 (0)