]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: make lookup() use more consistent [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 28 May 2019 09:58:51 +0000 (11:58 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 28 May 2019 09:58:51 +0000 (11:58 +0200)
We usually check lookup() return value. Let's do it in this case too.
It seems static analyzers will be happy with consistent code.

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu.c

index f64d81836d20cf281a70e026e32efc8efa40851d..48b3764585b74f0fa4c0e0698e8c5dcffc83e688 100644 (file)
@@ -626,8 +626,10 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
                read_physical_info_powerpc(desc);
 
        if ((fp = ul_path_fopen(desc->procfs, "r", "sysinfo"))) {
-               while (fgets(buf, sizeof(buf), fp) != NULL && !desc->machinetype)
-                       lookup(buf, "Type", &desc->machinetype);
+               while (fgets(buf, sizeof(buf), fp) != NULL) {
+                       if (lookup(buf, "Type", &desc->machinetype))
+                               break;
+               }
                fclose(fp);
        }