From: Yuriy M. Kaminskiy Date: Sat, 27 Feb 2016 16:14:44 +0000 (+0300) Subject: lsns.c: fix error return X-Git-Tag: v2.28-rc1~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff27b20f3ce74043d512522f28af59050c25541b;p=thirdparty%2Futil-linux.git lsns.c: fix error return If non-negative value returned, errno could be unset (especially 0). Signed-off-by: Karel Zak --- diff --git a/lib/sysfs.c b/lib/sysfs.c index 53aba3af94..9d76148809 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -464,7 +464,7 @@ int sysfs_write_u64(struct sysfs_cxt *cxt, const char *attr, uint64_t num) len = snprintf(buf, sizeof(buf), "%" PRIu64, num); if (len < 0 || (size_t) len + 1 > sizeof(buf)) - rc = -errno; + rc = len < 0 ? -errno : -E2BIG; else rc = write_all(fd, buf, len); diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 71ae3f99e0..83b07f5a88 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -255,7 +255,7 @@ static int read_process(struct lsns *ls, pid_t pid) } rc = fscanf(f, "%d %*s %c %d*[^\n]", &p->pid, &p->state, &p->ppid); if (rc != 3) { - rc = -errno; + rc = rc < 0 ? -errno : -EINVAL; goto done; } rc = 0;