@matheusbsbs / matheus-bagliano / commits / 60e199c4d5
Fork 0

Revert "run-command: prettify -D_FORTIFY_SOURCE workaround"

This reverts commit ebec842773932e6f853acac70c80f84209b5f83e, which somehow mistakenly thought that any non-zero return from write(2) is an error.

Junio C Hamano committed Apr 18, 2011 at 14:14 UTC 60e199c4d577514ed810b4ed0b6072fb3dbab903
1 file changed +6 -11
run-command.c
+6 -11
@@ -67,26 +67,21 @@ static int child_notifier = -1;
67
68 static void notify_parent(void)
69 {
70 - /*
71 - * execvp failed. If possible, we'd like to let start_command
72 - * know, so failures like ENOENT can be handled right away; but
73 - * otherwise, finish_command will still report the error.
74 - */
75 - if (write(child_notifier, "", 1))
76 - ; /* yes, dear gcc -D_FORTIFY_SOURCE, there was an error. */
70 + ssize_t unused;
71 + unused = write(child_notifier, "", 1);
72 }
73
74 static NORETURN void die_child(const char *err, va_list params)
75 {
76 char msg[4096];
77 + ssize_t unused;
78 int len = vsnprintf(msg, sizeof(msg), err, params);
79 if (len > sizeof(msg))
80 len = sizeof(msg);
81
86 - if (write(child_err, "fatal: ", 7) ||
87 - write(child_err, msg, len) ||
88 - write(child_err, "\n", 1))
89 - ; /* yes, gcc -D_FORTIFY_SOURCE, we know there was an error. */
82 + unused = write(child_err, "fatal: ", 7);
83 + unused = write(child_err, msg, len);
84 + unused = write(child_err, "\n", 1);
85 exit(128);
86 }
87 #endif