[systemd-devel] [PATCH] sysusers.c: make use of negative_errno()

Daniel Buch boogiewasthere at gmail.com
Tue Nov 4 12:07:32 PST 2014


Nevermind, ignore this. This is of course only where gcc complaints.
Den 04/11/2014 20.53 skrev "Daniel Buch" <boogiewasthere at gmail.com>:

> This is recently added by david. And i like replace return -errno treewide
> if desired?
>
> I suppose its safe and correct to assume every return -errno can be
> replaced?
>
> ---
>  src/sysusers/sysusers.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
> index c133dc5..11624ad 100644
> --- a/src/sysusers/sysusers.c
> +++ b/src/sysusers/sysusers.c
> @@ -143,7 +143,7 @@ static int load_user_database(void) {
>                  errno = 0;
>          }
>          if (!IN_SET(errno, 0, ENOENT))
> -                return -errno;
> +                return negative_errno();
>
>          return 0;
>  }
> @@ -195,7 +195,7 @@ static int load_group_database(void) {
>                  errno = 0;
>          }
>          if (!IN_SET(errno, 0, ENOENT))
> -                return -errno;
> +                return negative_errno();
>
>          return 0;
>  }
> @@ -213,11 +213,11 @@ static int make_backup(const char *target, const
> char *x) {
>                  if (errno == ENOENT) /* No backup necessary... */
>                          return 0;
>
> -                return -errno;
> +                return negative_errno();
>          }
>
>          if (fstat(src, &st) < 0)
> -                return -errno;
> +                return negative_errno();
>
>          r = fopen_temporary_label(target, x, &dst, &temp);
>          if (r < 0)
> @@ -790,7 +790,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
>                  if (p)
>                          return 0;
>                  if (!IN_SET(errno, 0, ENOENT))
> -                        return -errno;
> +                        return negative_errno();
>
>                  errno = 0;
>                  g = getgrgid((gid_t) uid);
> @@ -798,7 +798,7 @@ static int uid_is_ok(uid_t uid, const char *name) {
>                          if (!streq(g->gr_name, name))
>                                  return 0;
>                  } else if (!IN_SET(errno, 0, ENOENT))
> -                        return -errno;
> +                        return negative_errno();
>          }
>
>          return 1;
> @@ -809,7 +809,7 @@ static int root_stat(const char *p, struct stat *st) {
>
>          fix = fix_root(p);
>          if (stat(fix, st) < 0)
> -                return -errno;
> +                return negative_errno();
>
>          return 0;
>  }
> @@ -905,7 +905,7 @@ static int add_user(Item *i) {
>                  }
>                  if (!IN_SET(errno, 0, ENOENT)) {
>                          log_error("Failed to check if user %s already
> exists: %m", i->name);
> -                        return -errno;
> +                        return negative_errno();
>                  }
>
>                  /* And shadow too, just to be sure */
> @@ -917,7 +917,7 @@ static int add_user(Item *i) {
>                  }
>                  if (!IN_SET(errno, 0, ENOENT)) {
>                          log_error("Failed to check if user %s already
> exists in shadow database: %m", i->name);
> -                        return -errno;
> +                        return negative_errno();
>                  }
>          }
>
> @@ -1027,14 +1027,14 @@ static int gid_is_ok(gid_t gid) {
>                  if (g)
>                          return 0;
>                  if (!IN_SET(errno, 0, ENOENT))
> -                        return -errno;
> +                        return negative_errno();
>
>                  errno = 0;
>                  p = getpwuid((uid_t) gid);
>                  if (p)
>                          return 0;
>                  if (!IN_SET(errno, 0, ENOENT))
> -                        return -errno;
> +                        return negative_errno();
>          }
>
>          return 1;
> @@ -1069,7 +1069,7 @@ static int add_group(Item *i) {
>                  }
>                  if (!IN_SET(errno, 0, ENOENT)) {
>                          log_error("Failed to check if group %s already
> exists: %m", i->name);
> -                        return -errno;
> +                        return negative_errno();
>                  }
>          }
>
> --
> 2.1.3
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141104/a0c558ff/attachment.html>


More information about the systemd-devel mailing list