summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-01-01 14:57:08 -0500
committerLennart Poettering <lennart@poettering.net>2015-01-05 03:05:15 +0100
commit9bc5cd6d74d6efc7769d6a25b21e451dae39fe76 (patch)
tree06579414cb168e52206520ceaa66ef43f288ebfa /src/shared/util.c
parent6fc25464bf64b5df2f0efda70bc5c497914108c8 (diff)
util: Fix signedness error in lines(), match implementations
Regression introduced by ed757c0cb03eef50e8d9aeb4682401c3e9486f0b Mirror the implementation of columns(), since the fd_columns() functions returns a negative integer for errors. Also fix columns() to return the unsigned variable instead of the signed intermediary (they're the same, but better to be explicit).
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index dfaf7f7f4..390ad1d83 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3456,7 +3456,7 @@ unsigned columns(void) {
c = 80;
cached_columns = c;
- return c;
+ return cached_columns;
}
int fd_lines(int fd) {
@@ -3473,7 +3473,7 @@ int fd_lines(int fd) {
unsigned lines(void) {
const char *e;
- unsigned l;
+ int l;
if (_likely_(cached_lines > 0))
return cached_lines;
@@ -3481,7 +3481,7 @@ unsigned lines(void) {
l = 0;
e = getenv("LINES");
if (e)
- (void) safe_atou(e, &l);
+ (void) safe_atoi(e, &l);
if (l <= 0)
l = fd_lines(STDOUT_FILENO);