]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: change read_one_line_file() to return number of bytes read
authorTopi Miettinen <toiwoton@gmail.com>
Fri, 1 Feb 2019 21:25:53 +0000 (23:25 +0200)
committerTopi Miettinen <toiwoton@gmail.com>
Fri, 1 Feb 2019 22:25:57 +0000 (00:25 +0200)
Change detect_vm_xen_dom0() to match new usage.

src/basic/fileio.c
src/basic/virt.c

index e18b842999d22b51e55484d619c4a4c9d5add5b7..91e0c9ec8bc8acbdae10c22744eb85c952505fad 100644 (file)
@@ -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) {
index f63f15f6c14f81799ecf848588c2a0b4a3dc1c10..7766d9ca40c42fa66e917d856ddd75cb14355356 100644 (file)
@@ -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()