From f31322a28922d51e8b32e7e9107ed403b8f2e359 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Tue, 14 Aug 2012 09:01:45 +0200 Subject: lib/sysfs: make sysfs_partno_to_devno better readable Signed-off-by: Bernhard Voelker --- lib/sysfs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/sysfs.c') diff --git a/lib/sysfs.c b/lib/sysfs.c index b468e8840..7b2c5f7b1 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -321,8 +321,8 @@ int sysfs_is_partition_dirent(DIR *dir, struct dirent *d, const char *parent_nam } /* - * Copnverts @partno (partition number) to devno of the partition. The @cxt - * handles wholedisk device. + * Converts @partno (partition number) to devno of the partition. + * The @cxt handles wholedisk device. * * Note that this code does not expect any special format of the * partitions devnames. @@ -345,13 +345,15 @@ dev_t sysfs_partno_to_devno(struct sysfs_cxt *cxt, int partno) continue; snprintf(path, sizeof(path), "%s/partition", d->d_name); - if (sysfs_read_int(cxt, path, &n) || n != partno) + if (sysfs_read_int(cxt, path, &n)) continue; - snprintf(path, sizeof(path), "%s/dev", d->d_name); - if (sysfs_scanf(cxt, path, "%d:%d", &maj, &min) == 2) - devno = makedev(maj, min); - break; + if (n == partno) { + snprintf(path, sizeof(path), "%s/dev", d->d_name); + if (sysfs_scanf(cxt, path, "%d:%d", &maj, &min) == 2) + devno = makedev(maj, min); + break; + } } closedir(dir); -- cgit v1.2.3-55-g7522