From eeaeb7540b16a43a3c4b0923737c4b573f7d7c01 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 3 Mar 2010 15:01:44 +0100 Subject: [PATCH] libblkid: cleanup usage of empty topology values Signed-off-by: Karel Zak --- shlibs/blkid/src/topology/ioctl.c | 5 +---- shlibs/blkid/src/topology/sysfs.c | 4 ---- shlibs/blkid/src/topology/topology.c | 6 ++++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/shlibs/blkid/src/topology/ioctl.c b/shlibs/blkid/src/topology/ioctl.c index e85ecdf9..50b933c3 100644 --- a/shlibs/blkid/src/topology/ioctl.c +++ b/shlibs/blkid/src/topology/ioctl.c @@ -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: diff --git a/shlibs/blkid/src/topology/sysfs.c b/shlibs/blkid/src/topology/sysfs.c index 25e2b0aa..d04f0a86 100644 --- a/shlibs/blkid/src/topology/sysfs.c +++ b/shlibs/blkid/src/topology/sysfs.c @@ -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); } diff --git a/shlibs/blkid/src/topology/topology.c b/shlibs/blkid/src/topology/topology.c index fa49fd09..1162cb0e 100644 --- a/shlibs/blkid/src/topology/topology.c +++ b/shlibs/blkid/src/topology/topology.c @@ -43,6 +43,10 @@ * @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 = -- 2.39.5