diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-20 15:27:31 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-04-23 16:13:39 -0400 |
commit | a95e56e72c196970a8067cd515c658d064813170 (patch) | |
tree | e785c49b5cc7fe877ff5bf78193d11b1cb482540 /fs/lockd/host.c | |
parent | 164f98adbbd50c67177b096a59f55c1a56a45c82 (diff) | |
download | linux-3.10-a95e56e72c196970a8067cd515c658d064813170.tar.gz linux-3.10-a95e56e72c196970a8067cd515c658d064813170.tar.bz2 linux-3.10-a95e56e72c196970a8067cd515c658d064813170.zip |
lockd: clean up __nsm_find()
Use list_for_each_entry(). Also, in keeping with kernel style, make the
normal case (kzalloc succeeds) unindented and handle the abnormal case
with a goto.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/lockd/host.c')
-rw-r--r-- | fs/lockd/host.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 960911c4a11..de0ffb6106c 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -465,7 +465,7 @@ __nsm_find(const struct sockaddr_in *sin, int create) { struct nsm_handle *nsm = NULL; - struct list_head *pos; + struct nsm_handle *pos; if (!sin) return NULL; @@ -480,16 +480,16 @@ __nsm_find(const struct sockaddr_in *sin, } mutex_lock(&nsm_mutex); - list_for_each(pos, &nsm_handles) { - nsm = list_entry(pos, struct nsm_handle, sm_link); + list_for_each_entry(pos, &nsm_handles, sm_link) { if (hostname && nsm_use_hostnames) { - if (strlen(nsm->sm_name) != hostname_len - || memcmp(nsm->sm_name, hostname, hostname_len)) + if (strlen(pos->sm_name) != hostname_len + || memcmp(pos->sm_name, hostname, hostname_len)) continue; - } else if (!nlm_cmp_addr(&nsm->sm_addr, sin)) + } else if (!nlm_cmp_addr(&pos->sm_addr, sin)) continue; - atomic_inc(&nsm->sm_count); + atomic_inc(&pos->sm_count); + nsm = pos; goto out; } @@ -499,15 +499,15 @@ __nsm_find(const struct sockaddr_in *sin, } nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL); - if (nsm != NULL) { - nsm->sm_addr = *sin; - nsm->sm_name = (char *) (nsm + 1); - memcpy(nsm->sm_name, hostname, hostname_len); - nsm->sm_name[hostname_len] = '\0'; - atomic_set(&nsm->sm_count, 1); - - list_add(&nsm->sm_link, &nsm_handles); - } + if (nsm == NULL) + goto out; + nsm->sm_addr = *sin; + nsm->sm_name = (char *) (nsm + 1); + memcpy(nsm->sm_name, hostname, hostname_len); + nsm->sm_name[hostname_len] = '\0'; + atomic_set(&nsm->sm_count, 1); + + list_add(&nsm->sm_link, &nsm_handles); out: mutex_unlock(&nsm_mutex); |