Skip to content

Commit 13b0812

Browse files
stefanbellergitster
authored andcommitted
mailsplit.c: remove dead code
This was found by coverity. (Id: 290001) The variable 'output' is assigned to a value after all gotos to the corrupt label. Remove the goto by moving the errorhandling code to the condition, which detects the error. Signed-off-by: Stefan Beller <[email protected]> Helped-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e6aaa39 commit 13b0812

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

builtin/mailsplit.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ static int keep_cr;
5353
*/
5454
static int split_one(FILE *mbox, const char *name, int allow_bare)
5555
{
56-
FILE *output = NULL;
56+
FILE *output;
5757
int fd;
5858
int status = 0;
5959
int is_bare = !is_from_line(buf.buf, buf.len);
6060

61-
if (is_bare && !allow_bare)
62-
goto corrupt;
63-
61+
if (is_bare && !allow_bare) {
62+
unlink(name);
63+
fprintf(stderr, "corrupt mailbox\n");
64+
exit(1);
65+
}
6466
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
6567
if (fd < 0)
6668
die_errno("cannot open output file '%s'", name);
@@ -91,13 +93,6 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
9193
}
9294
fclose(output);
9395
return status;
94-
95-
corrupt:
96-
if (output)
97-
fclose(output);
98-
unlink(name);
99-
fprintf(stderr, "corrupt mailbox\n");
100-
exit(1);
10196
}
10297

10398
static int populate_maildir_list(struct string_list *list, const char *path)

0 commit comments

Comments
 (0)