From 00474ef9d3fceffe45758122a1c3db53c84a2370 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 14 May 2013 20:22:23 -0500 Subject: Silence warning and comment a subtle bit. --- lib/getmountlist.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/getmountlist.c') 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; -- cgit v1.2.3