write_file: use xopen
This simplifies the code a tiny bit, and provides consistent error messages with other users of xopen(). While we're here, let's also switch to using O_WRONLY. We know we're only going to open/write/close the file, so there's no point in asking for O_RDWR. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 8, 2016 at 05:10 UTC
ee861e0f78367ff0e94feeb42f721ef83ceec251
1 file changed
+1
-3
wrapper.c
+1
-3
@@ -644,9 +644,7 @@ void write_file(const char *path, const char *fmt, ...)
644
{
645
va_list params;
646
struct strbuf sb = STRBUF_INIT;
647
- int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
648
- if (fd < 0)
649
- die_errno(_("could not open %s for writing"), path);
647
+ int fd = xopen(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
648
649
va_start(params, fmt);
650
strbuf_vaddf(&sb, fmt, params);