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

[PATCH 3/3] Simplify some 'fprintf(stderr); return -1;' by using 'return error()'

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 8, 2009, 20:34 UTC
Message-ID
<7a02f50b758bfc6b9437f20cecea2d4628a5966a.1244492659.git.j6t@kdbg.org>
In-Reply-To
<8f487369337bdb1c9884b8f6e56530d25de85472.1244492659.git.j6t@kdbg.org>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 builtin-help.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/builtin-help.c b/builtin-help.c
index af565fb..6e53b23 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -80,10 +80,9 @@ static int check_emacsclient_version(void)
 	ec_process.argv = argv_ec;
 	ec_process.err = -1;
 	ec_process.stdout_to_stderr = 1;
-	if (start_command(&ec_process)) {
-		fprintf(stderr, "Failed to start emacsclient.\n");
-		return -1;
-	}
+	if (start_command(&ec_process))
+		return error("Failed to start emacsclient.");
+
 	strbuf_read(&buffer, ec_process.err, 20);
 	close(ec_process.err);
 
@@ -94,20 +93,17 @@ static int check_emacsclient_version(void)
 	finish_command(&ec_process);
 
 	if (prefixcmp(buffer.buf, "emacsclient")) {
-		fprintf(stderr, "Failed to parse emacsclient version.\n");
 		strbuf_release(&buffer);
-		return -1;
+		return error("Failed to parse emacsclient version.");
 	}
 
 	strbuf_remove(&buffer, 0, strlen("emacsclient"));
 	version = atoi(buffer.buf);
 
 	if (version < 22) {
-		fprintf(stderr,
-			"emacsclient version '%d' too old (< 22).\n",
-			version);
 		strbuf_release(&buffer);
-		return -1;
+		return error("emacsclient version '%d' too old (< 22).",
+			version);
 	}
 
 	strbuf_release(&buffer);
-- 
1.6.3.17.g1665f
Previous: Johannes Sixt
Message 4 of 4 in “Miscellanous cleanups around start_command/run_command callers”
  1. 0/3 Miscellanous cleanups around start_command/run_command callersJohannes Sixt, Jun 8, 2009
  2. 1/3 Simplify some instances of run_command() by using run_command_v_opt().Johannes Sixt, Jun 8, 2009
  3. 2/3 diff.c: plug a memory leak in an error pathJohannes Sixt, Jun 8, 2009
  4. 3/3 Simplify some 'fprintf(stderr); return -1;' by using 'return error()'Johannes Sixt, Jun 8, 2009

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.