From d6062e3b4fa041b070e0571f90f6c57faddcd56d Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Fri, 1 Feb 2019 23:25:53 +0200 Subject: basic: change read_one_line_file() to return number of bytes read Change detect_vm_xen_dom0() to match new usage. --- src/basic/fileio.c | 4 +--- src/basic/virt.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/basic/fileio.c b/src/basic/fileio.c index e18b842999..91e0c9ec8b 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -212,7 +212,6 @@ int write_string_filef( int read_one_line_file(const char *fn, char **line) { _cleanup_fclose_ FILE *f = NULL; - int r; assert(fn); assert(line); @@ -223,8 +222,7 @@ int read_one_line_file(const char *fn, char **line) { (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - r = read_line(f, LONG_LINE_MAX, line); - return r < 0 ? r : 0; + return read_line(f, LONG_LINE_MAX, line); } int verify_file(const char *fn, const char *blob, bool accept_extra_nl) { diff --git a/src/basic/virt.c b/src/basic/virt.c index f63f15f6c1..7766d9ca40 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -202,7 +202,7 @@ static int detect_vm_xen_dom0(void) { r = read_one_line_file(PATH_FEATURES, &domcap); if (r < 0 && r != -ENOENT) return r; - if (r == 0) { + if (r >= 0) { unsigned long features; /* Here, we need to use sscanf() instead of safe_atoul() -- cgit v1.2.3