@matheusbsbs / matheus-bagliano / commits / 4deba8b779
Fork 0

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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 26, 2008 at 11:17 UTC 4deba8b7798aac52e33aa8e1c49a8cdc0940ac36
1 file changed +5 -2
builtin-merge-file.c
+5 -2
@@ -51,8 +51,11 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
51 argc = parse_options(argc, argv, options, merge_file_usage, 0);
52 if (argc != 3)
53 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 + }
59
60 for (i = 0; i < 3; i++) {
61 if (!names[i])