[systemd-commits] 2 commits - src/path.c src/util.c

Michal Schmidt michich at kemper.freedesktop.org
Sat Dec 3 14:13:34 PST 2011


 src/path.c |    4 ++--
 src/util.c |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 768147d13d0877a4c3e5f6f986c3064de62ff4f1
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Sat Dec 3 01:36:05 2011 +0100

    path: use %m instead of strerror(errno)
    
    and strerror(-errno) was just wrong.

diff --git a/src/path.c b/src/path.c
index f15c921..142fd2d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -556,7 +556,7 @@ static void path_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
         }
 
         if (ioctl(fd, FIONREAD, &l) < 0) {
-                log_error("FIONREAD failed: %s", strerror(errno));
+                log_error("FIONREAD failed: %m");
                 goto fail;
         }
 
@@ -568,7 +568,7 @@ static void path_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
         }
 
         if ((k = read(fd, buf, l)) < 0) {
-                log_error("Failed to read inotify event: %s", strerror(-errno));
+                log_error("Failed to read inotify event: %m");
                 goto fail;
         }
 

commit 35d50f55f346c71fd5e957d35ebcae1c50b1f9ce
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Sat Dec 3 00:41:34 2011 +0100

    util: fix error checking after fgets()
    
    fgets() does not set errno on EOF.

diff --git a/src/util.c b/src/util.c
index e93e6f6..da71e4d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -516,7 +516,7 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
                 return -errno;
 
         if (!(fgets(line, sizeof(line), f))) {
-                r = -errno;
+                r = feof(f) ? -EIO : -errno;
                 fclose(f);
                 return r;
         }
@@ -561,7 +561,7 @@ int get_starttime_of_pid(pid_t pid, unsigned long long *st) {
                 return -errno;
 
         if (!(fgets(line, sizeof(line), f))) {
-                r = -errno;
+                r = feof(f) ? -EIO : -errno;
                 fclose(f);
                 return r;
         }
@@ -708,7 +708,7 @@ int read_one_line_file(const char *fn, char **line) {
                 return -errno;
 
         if (!(fgets(t, sizeof(t), f))) {
-                r = -errno;
+                r = feof(f) ? -EIO : -errno;
                 goto finish;
         }
 
@@ -3266,7 +3266,7 @@ int get_ctty_devnr(pid_t pid, dev_t *d) {
                 return -errno;
 
         if (!fgets(line, sizeof(line), f)) {
-                k = -errno;
+                k = feof(f) ? -EIO : -errno;
                 fclose(f);
                 return k;
         }



More information about the systemd-commits mailing list