Simplify some 'fprintf(stderr); return -1;' by using 'return error()'
Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Jun 8, 2009 at 22:34 UTC
4e2715fb9878235cb696f765695eef38078b0b7a
1 file changed
+6
-10
builtin-help.c
+6
-10
@@ -80,10 +80,9 @@ static int check_emacsclient_version(void)
80
ec_process.argv = argv_ec;
81
ec_process.err = -1;
82
ec_process.stdout_to_stderr = 1;
83
- if (start_command(&ec_process)) {
84
- fprintf(stderr, "Failed to start emacsclient.\n");
85
- return -1;
86
- }
83
+ if (start_command(&ec_process))
84
+ return error("Failed to start emacsclient.");
85
+
86
strbuf_read(&buffer, ec_process.err, 20);
87
close(ec_process.err);
88
@@ -94,20 +93,17 @@ static int check_emacsclient_version(void)
93
finish_command(&ec_process);
94
95
if (prefixcmp(buffer.buf, "emacsclient")) {
97
- fprintf(stderr, "Failed to parse emacsclient version.\n");
96
strbuf_release(&buffer);
99
- return -1;
97
+ return error("Failed to parse emacsclient version.");
98
}
99
100
strbuf_remove(&buffer, 0, strlen("emacsclient"));
101
version = atoi(buffer.buf);
102
103
if (version < 22) {
106
- fprintf(stderr,
107
- "emacsclient version '%d' too old (< 22).\n",
108
- version);
104
strbuf_release(&buffer);
110
- return -1;
105
+ return error("emacsclient version '%d' too old (< 22).",
106
+ version);
107
}
108
109
strbuf_release(&buffer);