From e2950383a28766d521a69ec5660b8271f322cbdb Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 11 Jun 2009 23:06:04 +0200 Subject: [PATCH] Kill all users of ERRNO_TO_ERROR() in util.c and util.h. --- errlist | 7 +++++++ util.c | 10 +++++----- util.h | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/errlist b/errlist index e4435df..728e3f8 100644 --- 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 7bf74b0..79b4944 100644 --- 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 2e3c66f..53221c9 100644 --- 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; } -- 2.39.2