git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] merge-file: handle freopen() failure

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Dec 26, 2008, 10:17 UTC
Message-ID
<1230286624.6728.56.camel@ubuntu.ubuntu-domain>
In-Reply-To
<1230284785.6728.26.camel@ubuntu.ubuntu-domain>
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>
---
 builtin-merge-file.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 9d4e874..96edb97 100644
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
@@ -51,8 +51,11 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, options, merge_file_usage, 0);
 	if (argc != 3)
 		usage_with_options(merge_file_usage, options);
-	if (quiet)
-		freopen("/dev/null", "w", stderr);
+	if (quiet) {
+		if (!freopen("/dev/null", "w", stderr))
+			return error("failed to redirect stderr to /dev/null: "
+				     "%s\n", strerror(errno));
+	}
 
 	for (i = 0; i < 3; i++) {
 		if (!names[i])
Previous: René Scharfe
Message 4 of 4 in “daemon: handle freopen() failure”
  1. 1/3 daemon: handle freopen() failureRené Scharfe, Dec 26, 2008
  2. 2/3 daemon: cleanup: replace loop with ifRené Scharfe, Dec 26, 2008
  3. 3/3 daemon: cleanup: factor out xstrdup_tolower()René Scharfe, Dec 26, 2008
  4. merge-file: handle freopen() failureRené Scharfe, Dec 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.