From 6df0d905e1a2cb127af844642ebf25ebb96b7323 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 16 Sep 2009 13:49:10 -0600 Subject: [PATCH] canonicalize: simplify errno handling This file originally forked from glibc, but has had so many other changes that it does not need to maintain glibc macros. * lib/canonicalize.c (__set_errno): Delete macro, and use direct assignment. Signed-off-by: Eric Blake --- ChangeLog | 4 ++++ lib/canonicalize.c | 25 +++++++++---------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bfc445d7..33507bb9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-09-17 Eric Blake + canonicalize: simplify errno handling + * lib/canonicalize.c (__set_errno): Delete macro, and use direct + assignment. + canonicalize, canonicalize-lgpl: update module dependencies * modules/canonicalize (Depends-on): Add extensions, lstat, pathmax, stdlib. diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 523e08204..c0a814d4c 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -32,19 +32,14 @@ #include #include +#include "areadlink.h" #include "file-set.h" #include "filenamecat.h" #include "hash-triple.h" +#include "pathmax.h" #include "xalloc.h" #include "xgetcwd.h" -#ifndef __set_errno -# define __set_errno(Val) errno = (Val) -#endif - -#include "pathmax.h" -#include "areadlink.h" - #if !(HAVE_CANONICALIZE_FILE_NAME || GNULIB_CANONICALIZE_LGPL) /* Return the canonical absolute name of file NAME. A canonical name does not contain any `.', `..' components nor any repeated file name @@ -62,13 +57,13 @@ canonicalize_file_name (const char *name) if (name == NULL) { - __set_errno (EINVAL); + errno = EINVAL; return NULL; } if (name[0] == '\0') { - __set_errno (ENOENT); + errno = ENOENT; return NULL; } @@ -160,13 +155,13 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (name == NULL) { - __set_errno (EINVAL); + errno = EINVAL; return NULL; } if (name[0] == '\0') { - __set_errno (ENOENT); + errno = ENOENT; return NULL; } @@ -262,11 +257,10 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) the same symlink,NAME pair twice does indicate a loop. */ if (seen_triple (&ht, name, &st)) { - __set_errno (ELOOP); if (can_mode == CAN_MISSING) continue; - else - goto error; + errno = ELOOP; + goto error; } buf = areadlink_with_size (rname, st.st_size); @@ -274,8 +268,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) { if (can_mode == CAN_MISSING && errno != ENOMEM) continue; - else - goto error; + goto error; } n = strlen (buf); -- 2.11.0