Mercurial > hg > toybox
changeset 901:c44dff160d65
Silence warning and comment a subtle bit.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 14 May 2013 20:22:23 -0500 |
parents | edd8e6fd418d |
children | 36993c59a3d3 |
files | lib/getmountlist.c |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/getmountlist.c Tue May 14 17:42:11 2013 -0500 +++ b/lib/getmountlist.c Tue May 14 20:22:23 2013 -0500 @@ -18,7 +18,11 @@ 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;