Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 460cdbc8 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Trond Myklebust
Browse files

nfs: replace while loop by for loops in nfs_follow_referral



Whoever wrote this had a bizarre allergy to for loops.

Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4ada29d5
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -116,24 +116,22 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
{
{
	struct vfsmount *mnt = ERR_PTR(-ENOENT);
	struct vfsmount *mnt = ERR_PTR(-ENOENT);
	char *mnt_path;
	char *mnt_path;
	unsigned int s = 0;
	unsigned int s;


	mnt_path = nfs4_pathname_string(&location->rootpath, page2, PAGE_SIZE);
	mnt_path = nfs4_pathname_string(&location->rootpath, page2, PAGE_SIZE);
	if (IS_ERR(mnt_path))
	if (IS_ERR(mnt_path))
		return mnt;
		return mnt;
	mountdata->mnt_path = mnt_path;
	mountdata->mnt_path = mnt_path;


	while (s < location->nservers) {
	for (s = 0; s < location->nservers; s++) {
		struct sockaddr_in addr = {
		struct sockaddr_in addr = {
			.sin_family	= AF_INET,
			.sin_family	= AF_INET,
			.sin_port	= htons(NFS_PORT),
			.sin_port	= htons(NFS_PORT),
		};
		};


		if (location->servers[s].len <= 0 ||
		if (location->servers[s].len <= 0 ||
		    valid_ipaddr4(location->servers[s].data) < 0) {
		    valid_ipaddr4(location->servers[s].data) < 0)
			s++;
			continue;
			continue;
		}


		mountdata->hostname = location->servers[s].data;
		mountdata->hostname = location->servers[s].data;
		addr.sin_addr.s_addr = in_aton(mountdata->hostname),
		addr.sin_addr.s_addr = in_aton(mountdata->hostname),
@@ -147,7 +145,6 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
		mnt = vfs_kern_mount(&nfs4_referral_fs_type, 0, page, mountdata);
		mnt = vfs_kern_mount(&nfs4_referral_fs_type, 0, page, mountdata);
		if (!IS_ERR(mnt))
		if (!IS_ERR(mnt))
			break;
			break;
		s++;
	}
	}
	return mnt;
	return mnt;
}
}
@@ -193,20 +190,16 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
		goto out;
		goto out;
	}
	}


	loc = 0;
	for (loc = 0; loc < locations->nlocations; loc++) {
	while (loc < locations->nlocations) {
		const struct nfs4_fs_location *location = &locations->locations[loc];
		const struct nfs4_fs_location *location = &locations->locations[loc];


		if (location == NULL || location->nservers <= 0 ||
		if (location == NULL || location->nservers <= 0 ||
		    location->rootpath.ncomponents == 0) {
		    location->rootpath.ncomponents == 0)
			loc++;
			continue;
			continue;
		}


		mnt = try_location(&mountdata, page, page2, location);
		mnt = try_location(&mountdata, page, page2, location);
		if (!IS_ERR(mnt))
		if (!IS_ERR(mnt))
			break;
			break;
		loc++;
	}
	}


out:
out: