diff --git a/minix/lib/libsffs/read.c b/minix/lib/libsffs/read.c index 58586102b..bb922f9a1 100644 --- a/minix/lib/libsffs/read.c +++ b/minix/lib/libsffs/read.c @@ -98,7 +98,7 @@ ssize_t do_getdents(ino_t ino_nr, struct fsdriver_data *data, size_t bytes, * the "." entry, the second position is for the ".." entry, and the next * position numbers each represent a file in the directory. */ - do { + for (;;) { /* Determine which inode and name to use for this entry. * We have no idea whether the host will give us "." and/or "..", * so generate our own and skip those from the host. @@ -165,7 +165,9 @@ ssize_t do_getdents(ino_t ino_nr, struct fsdriver_data *data, size_t bytes, if (r < 0) return r; - } while (r > 0); + if (r == 0) + break; + } return fsdriver_dentry_finish(&fsdentry); } diff --git a/minix/lib/libvtreefs/file.c b/minix/lib/libvtreefs/file.c index 3d3b2c9fe..2542ebc8e 100644 --- a/minix/lib/libvtreefs/file.c +++ b/minix/lib/libvtreefs/file.c @@ -223,7 +223,7 @@ fs_getdents(ino_t ino_nr, struct fsdriver_data * data, size_t bytes, fsdriver_dentry_init(&fsdentry, data, bytes, buf, bufsize); - do { + for (;;) { /* Determine which inode and name to use for this entry. */ pos = (*posp)++; @@ -287,7 +287,9 @@ fs_getdents(ino_t ino_nr, struct fsdriver_data * data, size_t bytes, IFTODT(child->i_stat.mode)); if (r < 0) return r; - } while (r > 0); + if (r == 0) + break; + } return fsdriver_dentry_finish(&fsdentry); }