Skip to content

Commit 4deba8b

Browse files
René Scharfegitster
authored andcommitted
merge-file: handle freopen() failure
Report the error if redirection of stderr to /dev/null failed. This silences a compiler warning about ignoring the return value of freopen() on Ubuntu 8.10. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6720e95 commit 4deba8b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builtin-merge-file.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
5151
argc = parse_options(argc, argv, options, merge_file_usage, 0);
5252
if (argc != 3)
5353
usage_with_options(merge_file_usage, options);
54-
if (quiet)
55-
freopen("/dev/null", "w", stderr);
54+
if (quiet) {
55+
if (!freopen("/dev/null", "w", stderr))
56+
return error("failed to redirect stderr to /dev/null: "
57+
"%s\n", strerror(errno));
58+
}
5659

5760
for (i = 0; i < 3; i++) {
5861
if (!names[i])

0 commit comments

Comments
 (0)