Browse Source

tools/namespacize: use unlink_noerr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 10 years ago
parent
commit
93bdadc175
1 changed files with 2 additions and 10 deletions
  1. 2 10
      tools/namespacize.c

+ 2 - 10
tools/namespacize.c

@@ -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;
 #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)
 	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);