[systemd-commits] 2 commits - src/fstab-generator src/journal src/libsystemd-bus src/libsystemd-daemon src/locale src/shared src/systemctl src/tmpfiles

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Mar 29 07:15:13 PDT 2013


 src/fstab-generator/fstab-generator.c |    2 +-
 src/journal/journalctl.c              |   15 ++++++++++-----
 src/libsystemd-bus/sd-bus.c           |    2 +-
 src/libsystemd-daemon/sd-daemon.c     |    4 ++--
 src/locale/localectl.c                |    2 +-
 src/shared/calendarspec.c             |    4 ++--
 src/shared/fileio.c                   |    2 +-
 src/shared/socket-util.c              |    2 +-
 src/shared/time-util.c                |    4 ++--
 src/shared/util.c                     |    6 +++---
 src/shared/util.h                     |    2 +-
 src/systemctl/systemctl.c             |    4 ++--
 src/tmpfiles/tmpfiles.c               |    2 +-
 13 files changed, 28 insertions(+), 23 deletions(-)

New commits:
commit 8333c77edf8fd1654cd96f3f6ee0f078dd64b58b
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Mar 28 09:24:15 2013 -0400

    Always use errno > 0 to help gcc
    
    gcc thinks that errno might be negative, and functions could return
    something positive on error (-errno). Should not matter in practice,
    but makes an -O4 build much quieter.

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 4eaa52d..2790fc6 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -69,7 +69,7 @@ static int mount_find_pri(struct mntent *me, int *ret) {
 
         errno = 0;
         r = strtoul(pri, &end, 10);
-        if (errno != 0)
+        if (errno > 0)
                 return -errno;
 
         if (end == pri || (*end != ',' && *end != 0))
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 6acc59e..08a218b 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -507,7 +507,7 @@ static int parse_exec_address(sd_bus *b, const char **p, char **guid) {
 
                         errno = 0;
                         ul = strtoul(*p + 4, (char**) p, 10);
-                        if (errno != 0 || **p != '=' || ul > 256) {
+                        if (errno > 0 || **p != '=' || ul > 256) {
                                 r = -EINVAL;
                                 goto fail;
                         }
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 79d8ca3..b1ff431 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -84,7 +84,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) {
         errno = 0;
         l = strtoul(e, &p, 10);
 
-        if (errno != 0) {
+        if (errno > 0) {
                 r = -errno;
                 goto finish;
         }
@@ -109,7 +109,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) {
         errno = 0;
         l = strtoul(e, &p, 10);
 
-        if (errno != 0) {
+        if (errno > 0) {
                 r = -errno;
                 goto finish;
         }
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 9f996db..fc31289 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -421,7 +421,7 @@ static int add_locales_from_libdir (Set *locales) {
                 errno = 0;
         }
 
-        if (errno != 0) {
+        if (errno > 0) {
                 log_error("Failed to read locale directory: %m");
                 return -errno;
         }
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index cc68077..13f70d8 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -391,7 +391,7 @@ static int prepend_component(const char **p, CalendarComponent **c) {
 
         errno = 0;
         value = strtoul(*p, &e, 10);
-        if (errno != 0)
+        if (errno > 0)
                 return -errno;
         if (e == *p)
                 return -EINVAL;
@@ -400,7 +400,7 @@ static int prepend_component(const char **p, CalendarComponent **c) {
 
         if (*e == '/') {
                 repeat = strtoul(e+1, &ee, 10);
-                if (errno != 0)
+                if (errno > 0)
                         return -errno;
                 if (ee == e+1)
                         return -EINVAL;
diff --git a/src/shared/fileio.c b/src/shared/fileio.c
index 0eca441..1c7d485 100644
--- a/src/shared/fileio.c
+++ b/src/shared/fileio.c
@@ -364,7 +364,7 @@ int write_env_file(const char *fname, char **l) {
         fflush(f);
 
         if (ferror(f)) {
-                if (errno != 0)
+                if (errno > 0)
                         r = -errno;
                 else
                         r = -EIO;
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index f6ddea3..5345788 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -68,7 +68,7 @@ int socket_address_parse(SocketAddress *a, const char *s) {
                 errno = 0;
                 if (inet_pton(AF_INET6, n, &a->sockaddr.in6.sin6_addr) <= 0) {
                         free(n);
-                        return errno != 0 ? -errno : -EINVAL;
+                        return errno > 0 ? -errno : -EINVAL;
                 }
 
                 free(n);
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index e192d5e..0c6deb6 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -547,7 +547,7 @@ int parse_usec(const char *t, usec_t *usec) {
                 errno = 0;
                 l = strtoll(p, &e, 10);
 
-                if (errno != 0)
+                if (errno > 0)
                         return -errno;
 
                 if (l < 0)
@@ -627,7 +627,7 @@ int parse_nsec(const char *t, nsec_t *nsec) {
                 errno = 0;
                 l = strtoll(p, &e, 10);
 
-                if (errno != 0)
+                if (errno > 0)
                         return -errno;
 
                 if (l < 0)
diff --git a/src/shared/util.c b/src/shared/util.c
index 2241b79..7281cc8 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2265,7 +2265,7 @@ int parse_bytes(const char *t, off_t *bytes) {
                 errno = 0;
                 l = strtoll(p, &e, 10);
 
-                if (errno != 0)
+                if (errno > 0)
                         return -errno;
 
                 if (l < 0)
@@ -4191,7 +4191,7 @@ int get_user_creds(
         }
 
         if (!p)
-                return errno != 0 ? -errno : -ESRCH;
+                return errno > 0 ? -errno : -ESRCH;
 
         if (uid)
                 *uid = p->pw_uid;
@@ -4272,7 +4272,7 @@ int get_group_creds(const char **groupname, gid_t *gid) {
         }
 
         if (!g)
-                return errno != 0 ? -errno : -ESRCH;
+                return errno > 0 ? -errno : -ESRCH;
 
         if (gid)
                 *gid = g->gr_gid;
diff --git a/src/shared/util.h b/src/shared/util.h
index aefde5f..485733f 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -595,7 +595,7 @@ int create_tmp_dir(char template[], char** dir_name);
 #define FOREACH_DIRENT(de, d, on_error)                                 \
         for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d))   \
                 if (!de) {                                              \
-                        if (errno != 0) {                               \
+                        if (errno > 0) {                                \
                                 on_error;                               \
                         }                                               \
                         break;                                          \
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index edd136a..f7ae47e 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4629,11 +4629,11 @@ static int parse_time_spec(const char *t, usec_t *_u) {
 
                 errno = 0;
                 hour = strtol(t, &e, 10);
-                if (errno != 0 || *e != ':' || hour < 0 || hour > 23)
+                if (errno > 0 || *e != ':' || hour < 0 || hour > 23)
                         return -EINVAL;
 
                 minute = strtol(e+1, &e, 10);
-                if (errno != 0 || *e != 0 || minute < 0 || minute > 59)
+                if (errno > 0 || *e != 0 || minute < 0 || minute > 59)
                         return -EINVAL;
 
                 n = now(CLOCK_REALTIME);
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 614644a..918702e 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -611,7 +611,7 @@ static int glob_item(Item *i, int (*action)(Item *, const char *)) {
         if ((k = glob(i->path, GLOB_NOSORT|GLOB_BRACE, NULL, &g)) != 0) {
 
                 if (k != GLOB_NOMATCH) {
-                        if (errno != 0)
+                        if (errno > 0)
                                 errno = EIO;
 
                         log_error("glob(%s) failed: %m", i->path);

commit 0db809489fd88a320ae1023ffe36a9965e9a91b2
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Mar 29 10:09:21 2013 -0400

    journalctl: fix --update-catalog with not --root arg
    
    grawity> `journalctl --update-catalog` from latest git prints:
             "Recursive mkdir .: Invalid argument" and
             "Failed to write : Invalid argument"

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 3ae6482..c96d68d 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1032,11 +1032,16 @@ int main(int argc, char *argv[]) {
             arg_action == ACTION_LIST_CATALOG ||
             arg_action == ACTION_DUMP_CATALOG) {
 
-                char _cleanup_free_ *database;
-                database =  strjoin(arg_root, "/", CATALOG_DATABASE, NULL);
-                if (!database) {
-                        r = log_oom();
-                        goto finish;
+                const char* database = CATALOG_DATABASE;
+                char _cleanup_free_ *copy = NULL;
+                if (arg_root) {
+                        copy = strjoin(arg_root, "/", CATALOG_DATABASE, NULL);
+                        if (!database) {
+                                r = log_oom();
+                                goto finish;
+                        }
+                        path_kill_slashes(copy);
+                        database = copy;
                 }
 
                 if (arg_action == ACTION_UPDATE_CATALOG) {



More information about the systemd-commits mailing list