mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 18:27:04 +03:00
util: Fix signedness error in lines(), match implementations
Regression introduced by ed757c0cb0
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).
This commit is contained in:
parent
6fc25464bf
commit
9bc5cd6d74
@ -3456,7 +3456,7 @@ unsigned columns(void) {
|
|||||||
c = 80;
|
c = 80;
|
||||||
|
|
||||||
cached_columns = c;
|
cached_columns = c;
|
||||||
return c;
|
return cached_columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd_lines(int fd) {
|
int fd_lines(int fd) {
|
||||||
@ -3473,7 +3473,7 @@ int fd_lines(int fd) {
|
|||||||
|
|
||||||
unsigned lines(void) {
|
unsigned lines(void) {
|
||||||
const char *e;
|
const char *e;
|
||||||
unsigned l;
|
int l;
|
||||||
|
|
||||||
if (_likely_(cached_lines > 0))
|
if (_likely_(cached_lines > 0))
|
||||||
return cached_lines;
|
return cached_lines;
|
||||||
@ -3481,7 +3481,7 @@ unsigned lines(void) {
|
|||||||
l = 0;
|
l = 0;
|
||||||
e = getenv("LINES");
|
e = getenv("LINES");
|
||||||
if (e)
|
if (e)
|
||||||
(void) safe_atou(e, &l);
|
(void) safe_atoi(e, &l);
|
||||||
|
|
||||||
if (l <= 0)
|
if (l <= 0)
|
||||||
l = fd_lines(STDOUT_FILENO);
|
l = fd_lines(STDOUT_FILENO);
|
||||||
|
Loading…
Reference in New Issue
Block a user