]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapoff: check blkid_probe_lookup_value() return code [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 23 Apr 2025 09:14:09 +0000 (11:14 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 23 Apr 2025 09:14:09 +0000 (11:14 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findmnt.c
misc-utils/lsblk.c
sys-utils/swapoff.c

index 86258dfd319b6421469b40840a4961f9d8b7aa4c..2682de1d7713f5ec9a38e3e9a983b93fda1db405 100644 (file)
@@ -57,6 +57,8 @@
 
 /* column IDs */
 enum {
+       COL_TARGET,     /* Keep it first to make --output-all readable */
+
        COL_ACTION,
        COL_AVAIL,
        COL_FREQ,
@@ -82,7 +84,6 @@ enum {
        COL_SIZE,
        COL_SOURCE,
        COL_SOURCES,
-       COL_TARGET,
        COL_TID,
        COL_UNIQ_ID,
        COL_USED,
index 9f252d079b05fe7838eb8949c2ed193e27a9be22..7daa7f58f9d4f257188e2e7c0dfefc4cd794b24f 100644 (file)
@@ -68,7 +68,9 @@ static int column_id_to_number(int id);
 
 /* column IDs */
 enum {
-       COL_ALIOFF = 0,
+       COL_NAME,       /* Keep it first to make --output-all readable */
+
+       COL_ALIOFF,
        COL_IDLINK,
        COL_ID,
        COL_DALIGN,
@@ -97,7 +99,6 @@ enum {
        COL_MODE,
        COL_MODEL,
        COL_MQ,
-       COL_NAME,
        COL_OPTIO,
        COL_OWNER,
        COL_PARTFLAGS,
index 70422c9e2c57a31118167108e507aa82fc22d466..21c8e1ee8cc18f909965759272821efd14c33fe9 100644 (file)
@@ -81,9 +81,10 @@ static char *resolve_swapfile_tag(const char *name, const char *value)
                pr = get_swap_prober(src);
                if (!pr)
                        continue;
-               blkid_probe_lookup_value(pr, name, &data, NULL);
-               if (data && strcmp(data, value) == 0)
+               if (blkid_probe_lookup_value(pr, name, &data, NULL) == 0
+                   && data && strcmp(data, value) == 0)
                        path = xstrdup(src);
+
                blkid_free_probe(pr);
                if (path)
                        break;