]> err.no Git - util-linux/commitdiff
libblkid: cleanup usage of empty topology values
authorKarel Zak <kzak@redhat.com>
Wed, 3 Mar 2010 14:01:44 +0000 (15:01 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Mar 2010 14:01:44 +0000 (15:01 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/topology/ioctl.c
shlibs/blkid/src/topology/sysfs.c
shlibs/blkid/src/topology/topology.c

index e85ecdf957822139cc67c3b3f1cd5fbad3c8de65..50b933c3488c8bdf2cf48be8e62e50943472970a 100644 (file)
@@ -41,7 +41,6 @@ static struct topology_val {
 static int probe_ioctl_tp(blkid_probe pr, const struct blkid_idmag *mag)
 {
        int i;
-       int count = 0;
 
        for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
                struct topology_val *val = &topology_vals[i];
@@ -57,11 +56,9 @@ static int probe_ioctl_tp(blkid_probe pr, const struct blkid_idmag *mag)
                        rc = val->set_ulong(pr, (unsigned long) data);
                if (rc)
                        goto err;
-               count++;
        }
 
-       if (count)
-               return 0;
+       return 0;
 nothing:
        return 1;
 err:
index 25e2b0aa047c42b022f8f590ec7e62e046536a3f..d04f0a86ecf1de5507c5eeb53a99329b51ce3636 100644 (file)
@@ -66,8 +66,6 @@ static int probe_sysfs_tp(blkid_probe pr, const struct blkid_idmag *mag)
                        if (blkid_devno_get_u64_attribute(attr_dev,
                                                        val->attr, &data))
                                continue;
-                       if (!data)
-                               continue;
                        rc = val->set_ulong(pr, (unsigned long) data);
 
                } else if (val->set_int) {
@@ -76,8 +74,6 @@ static int probe_sysfs_tp(blkid_probe pr, const struct blkid_idmag *mag)
                        if (blkid_devno_get_s64_attribute(attr_dev,
                                                        val->attr, &data))
                                continue;
-                       if (!data)
-                               continue;
                        rc = val->set_int(pr, (int) data);
                }
 
index fa49fd092e1bad229ced09be7ba9b32ef39dd316..1162cb0ef63979d16c301bee5f7599961de0293d 100644 (file)
  * @ALIGNMENT_OFFSET: indicates how many bytes the beginning o the device is
  *                    offset from the disk's natural alignment.
  *
+ * The NAME=value tags are not defined when the corresponding topology value
+ * is zero. The MINIMUM_IO_SIZE should be always defined if kernel provides
+ * topology information.
+ *
  * Binary interface:
  *
  * blkid_probe_get_tolology()
@@ -214,6 +218,8 @@ static int topology_set_value(blkid_probe pr, const char *name,
 
        if (!chn)
                return -1;
+       if (!data)
+               return 0;       /* ignore zeros */
 
        if (chn->binary) {
                unsigned long *v =