Skip to content

Commit e35d65a

Browse files
avargitster
authored andcommitted
fsck.c: refactor fsck_msg_type() to limit scope of "int msg_type"
Refactor "if options->msg_type" and other code added in 0282f4d (fsck: offer a function to demote fsck errors to warnings, 2015-06-22) to reduce the scope of the "int msg_type" variable. This is in preparation for changing its type in a subsequent commit, only using it in the "!options->msg_type" scope makes that change This also brings the code in line with the fsck_set_msg_type() function (also added in 0282f4d), which does a similar check for "!options->msg_type". Another minor benefit is getting rid of the style violation of not having braces for the body of the "if". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35af754 commit e35d65a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

fsck.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,17 @@ void list_config_fsck_msg_ids(struct string_list *list, const char *prefix)
167167
static int fsck_msg_type(enum fsck_msg_id msg_id,
168168
struct fsck_options *options)
169169
{
170-
int msg_type;
171-
172170
assert(msg_id >= 0 && msg_id < FSCK_MSG_MAX);
173171

174-
if (options->msg_type)
175-
msg_type = options->msg_type[msg_id];
176-
else {
177-
msg_type = msg_id_info[msg_id].msg_type;
172+
if (!options->msg_type) {
173+
int msg_type = msg_id_info[msg_id].msg_type;
174+
178175
if (options->strict && msg_type == FSCK_WARN)
179176
msg_type = FSCK_ERROR;
177+
return msg_type;
180178
}
181179

182-
return msg_type;
180+
return options->msg_type[msg_id];
183181
}
184182

185183
static int parse_msg_type(const char *str)

0 commit comments

Comments
 (0)