]> git.ozlabs.org Git - ccan/blobdiff - ccan/string/string.c
commiting changes for test case of grab_file
[ccan] / ccan / string / string.c
index 9182ac0650fb7b9c94ba72aa12872ca7f44310d0..6e473af36cf3862580e6c1f706d46861e99dc874 100644 (file)
@@ -10,6 +10,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
+#include "noerr/noerr.h"
 
 char **strsplit(const void *ctx, const char *string, const char *delims,
                 unsigned int *nump)
 
 char **strsplit(const void *ctx, const char *string, const char *delims,
                 unsigned int *nump)
@@ -47,15 +48,6 @@ char *strjoin(const void *ctx, char *strings[], const char *delim)
        return ret;
 }
 
        return ret;
 }
 
-static int close_no_errno(int fd)
-{
-       int ret = 0, serrno = errno;
-       if (close(fd) < 0)
-               ret = errno;
-       errno = serrno;
-       return ret;
-}
-
 void *grab_fd(const void *ctx, int fd)
 {
        int ret;
 void *grab_fd(const void *ctx, int fd)
 {
        int ret;
@@ -91,6 +83,6 @@ void *grab_file(const void *ctx, const char *filename)
                return NULL;
 
        buffer = grab_fd(ctx, fd);
                return NULL;
 
        buffer = grab_fd(ctx, fd);
-       close_no_errno(fd);
+       close_noerr(fd);
        return buffer;
 }
        return buffer;
 }