diff options
author | Rob Landley <rob@landley.net> | 2013-05-14 20:22:23 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-05-14 20:22:23 -0500 |
commit | 00474ef9d3fceffe45758122a1c3db53c84a2370 (patch) | |
tree | e165ff7b64ebaf33ec0d784ba80ae20bf2397cbe /lib/getmountlist.c | |
parent | bd7a7fe6cddf790c66841c1fd636f51967060433 (diff) | |
download | toybox-00474ef9d3fceffe45758122a1c3db53c84a2370.tar.gz |
Silence warning and comment a subtle bit.
Diffstat (limited to 'lib/getmountlist.c')
-rw-r--r-- | lib/getmountlist.c | 6 |
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; |