Kill all users of ERRNO_TO_ERROR() in util.c and util.h.
authorAndre Noll <maan@systemlinux.org>
Thu, 11 Jun 2009 21:06:04 +0000 (23:06 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 11 Jun 2009 21:06:04 +0000 (23:06 +0200)
errlist
util.c
util.h

diff --git a/errlist b/errlist
index e4435df162cfd63a6eb25ed26c87126e031290e5..728e3f8b6837396821221dd9b2a5882e03848498 100644 (file)
--- a/errlist
+++ b/errlist
@@ -36,3 +36,10 @@ NOMEM                                "cannot allocate memory"
 NOTDIR                         "not a directory"
 STAT                           "stat error"
 UNLINK                         "failed to unlink file"
+WRITE                          "write error"
+OPEN                           "failed to open file"
+TRUNCATE                       "could not truncate file"
+MKDIR                          "failed to create directory"
+RENAME                         "could not rename file"
+MUNMAP                         "munmap error"
+FSTAT                          "fstat error"
diff --git a/util.c b/util.c
index 7bf74b0b2dc099c066e8e0dd96d93a47cb01fbd5..79b49445d7c602601e4b18e00ee99450dd5bc2c9 100644 (file)
--- a/util.c
+++ b/util.c
@@ -40,7 +40,7 @@ static ssize_t __write(int fd, const void *buf, size_t size)
                ret = write(fd, buf, size);
                if ((ret < 0) && (errno == EAGAIN || errno == EINTR))
                        continue;
-               return ret >= 0? ret : -ERRNO_TO_ERROR(errno);
+               return ret >= 0? ret : -E_OSL_WRITE;
        }
 }
 
@@ -89,7 +89,7 @@ int osl_open(const char *path, int flags, mode_t mode)
 
        if (ret >= 0)
                return ret;
-       return -ERRNO_TO_ERROR(errno);
+       return -E_OSL_OPEN;
 }
 
 /**
@@ -153,7 +153,7 @@ int mmap_full_file(const char *path, int open_mode, void **map,
                return ret;
        fd = ret;
        if (fstat(fd, &file_status) < 0) {
-               ret = -ERRNO_TO_ERROR(errno);
+               ret = -E_OSL_FSTAT;
                goto out;
        }
        *size = file_status.st_size;
@@ -194,7 +194,7 @@ int osl_munmap(void *start, size_t length)
        err = errno;
        ERROR_LOG("munmap (%p/%zu) failed: %s\n", start, length,
                strerror(err));
-       return -ERRNO_TO_ERROR(err);
+       return -E_OSL_MUNMAP;
 }
 
 /**
@@ -267,6 +267,6 @@ int truncate_file(const char *path, off_t size)
        if (statbuf.st_size < size)
                return ret;
        if (truncate(path, statbuf.st_size - size) < 0)
-               return -ERRNO_TO_ERROR(errno);
+               return -E_OSL_TRUNCATE;
        return 1;
 }
diff --git a/util.h b/util.h
index 2e3c66fcf0214e5bb2b098d02cfce5758e5500e4..53221c99e6ac7b9fc68cda57ef60b08b4bd28206 100644 (file)
--- a/util.h
+++ b/util.h
@@ -26,7 +26,7 @@ static inline int osl_mkdir(const char *path, mode_t mode)
 {
        if (!mkdir(path, mode))
                return 1;
-       return -ERRNO_TO_ERROR(errno);
+       return -E_OSL_MKDIR;
 }
 
 /**
@@ -42,7 +42,7 @@ static inline int osl_mkdir(const char *path, mode_t mode)
 _static_inline_ int osl_rename(const char *old_path, const char *new_path)
 {
        if (rename(old_path, new_path) < 0)
-               return -ERRNO_TO_ERROR(errno);
+               return -E_OSL_RENAME;
        return 1;
 }
 
@@ -50,5 +50,5 @@ _static_inline_ int osl_stat(const char *path, struct stat *buf)
 {
        if (stat(path, buf) >= 0)
                return 1;
-       return -ERRNO_TO_ERROR(errno);
+       return -E_OSL_STAT;
 }