diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/loopdev.c | 2 | ||||
-rw-r--r-- | lib/path.c | 5 | ||||
-rw-r--r-- | lib/ttyutils.c | 16 |
3 files changed, 12 insertions, 11 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c index 26ab402fa..ac46f5312 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -127,7 +127,7 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device) return 0; } -inline int loopcxt_has_device(struct loopdev_cxt *lc) +int loopcxt_has_device(struct loopdev_cxt *lc) { return lc && *lc->device; } diff --git a/lib/path.c b/lib/path.c index f7fd19592..8dce1da40 100644 --- a/lib/path.c +++ b/lib/path.c @@ -610,9 +610,10 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char /* Remove tailing newline (usual in sysfs) */ if (rc > 0 && *(buf + rc - 1) == '\n') - --rc; + buf[--rc] = '\0'; + else + buf[rc - 1] = '\0'; - buf[rc] = '\0'; return rc; } diff --git a/lib/ttyutils.c b/lib/ttyutils.c index 166e49e11..8649f435a 100644 --- a/lib/ttyutils.c +++ b/lib/ttyutils.c @@ -47,16 +47,16 @@ int get_terminal_dimension(int *cols, int *lines) l = t_win.ts_lines; } #endif - - if (cols && c <= 0) - c = get_env_int("COLUMNS"); - if (lines && l <= 0) - l = get_env_int("LINES"); - - if (cols) + if (cols) { + if (c <= 0) + c = get_env_int("COLUMNS"); *cols = c; - if (lines) + } + if (lines) { + if (l <= 0) + l = get_env_int("LINES"); *lines = l; + } return 0; } |