* [PATCH] lib/sysfs: make sysfs_partno_to_devno better readable
@ 2012-08-14 7:01 Bernhard Voelker
2012-08-14 16:23 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Voelker @ 2012-08-14 7:01 UTC (permalink / raw)
To: util-linux; +Cc: Bernhard Voelker
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
lib/sysfs.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index b468e88..7b2c5f7 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);
--
1.7.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-14 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14 7:01 [PATCH] lib/sysfs: make sysfs_partno_to_devno better readable Bernhard Voelker
2012-08-14 16:23 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).