Commit 93bdadc1 authored by Rusty Russell's avatar Rusty Russell

tools/namespacize: use unlink_noerr.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent d262c52e
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ccan/tal/path/path.h" #include "ccan/tal/path/path.h"
#include "ccan/tal/grab_file/grab_file.h" #include "ccan/tal/grab_file/grab_file.h"
#include "ccan/err/err.h" #include "ccan/err/err.h"
#include "ccan/noerr/noerr.h"
#include "tools.h" #include "tools.h"
static bool verbose = false; static bool verbose = false;
...@@ -29,15 +30,6 @@ static int indent = 0; ...@@ -29,15 +30,6 @@ static int indent = 0;
#define verbose_indent() (indent += 2) #define verbose_indent() (indent += 2)
#define verbose_unindent() (indent -= 2) #define verbose_unindent() (indent -= 2)
static int unlink_no_errno(const char *filename)
{
int ret = 0, serrno = errno;
if (unlink(filename) < 0)
ret = errno;
errno = serrno;
return ret;
}
static char **get_dir(const char *dir) static char **get_dir(const char *dir)
{ {
DIR *d; DIR *d;
...@@ -292,7 +284,7 @@ static void write_replacement_file(const char *dir, struct replace **repl) ...@@ -292,7 +284,7 @@ static void write_replacement_file(const char *dir, struct replace **repl)
for (r = *repl; r; r = r->next) { for (r = *repl; r; r = r->next) {
if (write(fd,r->string,strlen(r->string)) != strlen(r->string) if (write(fd,r->string,strlen(r->string)) != strlen(r->string)
|| write(fd, "\n", 1) != 1) { || write(fd, "\n", 1) != 1) {
unlink_no_errno(replname); unlink_noerr(replname);
if (errno == 0) if (errno == 0)
errx(1, "Short write to %s: disk full?", errx(1, "Short write to %s: disk full?",
replname); replname);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment