tools/namespacize: use unlink_noerr.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:27:05 +0000 (16:57 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:35:47 +0000 (17:05 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tools/namespacize.c

index da2d599986c104d900d2dddc9f623878a6b0d8d6..ae20e3d66c136e83b4675526f9d76c34647d8b41 100644 (file)
@@ -15,6 +15,7 @@
 #include "ccan/tal/path/path.h"
 #include "ccan/tal/grab_file/grab_file.h"
 #include "ccan/err/err.h"
+#include "ccan/noerr/noerr.h"
 #include "tools.h"
 
 static bool verbose = false;
@@ -29,15 +30,6 @@ static int indent = 0;
 #define verbose_indent() (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)
 {
        DIR *d;
@@ -292,7 +284,7 @@ static void write_replacement_file(const char *dir, struct replace **repl)
        for (r = *repl; r; r = r->next) {
                if (write(fd,r->string,strlen(r->string)) != strlen(r->string)
                    || write(fd, "\n", 1) != 1) {
-                       unlink_no_errno(replname);
+                       unlink_noerr(replname);
                        if (errno == 0)
                                errx(1, "Short write to %s: disk full?",
                                     replname);