aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-05-14 20:22:23 -0500
committerRob Landley <rob@landley.net>2013-05-14 20:22:23 -0500
commit00474ef9d3fceffe45758122a1c3db53c84a2370 (patch)
treee165ff7b64ebaf33ec0d784ba80ae20bf2397cbe
parentbd7a7fe6cddf790c66841c1fd636f51967060433 (diff)
downloadtoybox-00474ef9d3fceffe45758122a1c3db53c84a2370.tar.gz
Silence warning and comment a subtle bit.
-rw-r--r--lib/getmountlist.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/getmountlist.c b/lib/getmountlist.c
index dbf0b27c..28a84063 100644
--- a/lib/getmountlist.c
+++ b/lib/getmountlist.c
@@ -18,7 +18,11 @@ struct mtab_list *xgetmountlist(void)
if (!(fp = setmntent("/proc/mounts", "r"))) perror_exit("bad /proc/mounts");
- for (mtlist = 0; me = getmntent(fp); mtlist = mt) {
+ // The "test" part of the loop is done before the first time through and
+ // again after each "increment", so putting the actual load there avoids
+ // duplicating it. If the load was NULL, the loop stops.
+
+ for (mtlist = 0; (me = getmntent(fp)); mtlist = mt) {
mt = xzalloc(sizeof(struct mtab_list) + strlen(me->mnt_fsname) +
strlen(me->mnt_dir) + strlen(me->mnt_type) + 3);
mt->next = mtlist;