aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2008-02-20 15:27:31 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-04-23 16:13:39 -0400
commita95e56e72c196970a8067cd515c658d064813170 (patch)
treee785c49b5cc7fe877ff5bf78193d11b1cb482540 /fs
parent164f98adbbd50c67177b096a59f55c1a56a45c82 (diff)
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')
-rw-r--r--fs/lockd/host.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 960911c4a11c..de0ffb6106c4 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -465,7 +465,7 @@ __nsm_find(const struct sockaddr_in *sin,
465 int create) 465 int create)
466{ 466{
467 struct nsm_handle *nsm = NULL; 467 struct nsm_handle *nsm = NULL;
468 struct list_head *pos; 468 struct nsm_handle *pos;
469 469
470 if (!sin) 470 if (!sin)
471 return NULL; 471 return NULL;
@@ -480,16 +480,16 @@ __nsm_find(const struct sockaddr_in *sin,
480 } 480 }
481 481
482 mutex_lock(&nsm_mutex); 482 mutex_lock(&nsm_mutex);
483 list_for_each(pos, &nsm_handles) { 483 list_for_each_entry(pos, &nsm_handles, sm_link) {
484 nsm = list_entry(pos, struct nsm_handle, sm_link);
485 484
486 if (hostname && nsm_use_hostnames) { 485 if (hostname && nsm_use_hostnames) {
487 if (strlen(nsm->sm_name) != hostname_len 486 if (strlen(pos->sm_name) != hostname_len
488 || memcmp(nsm->sm_name, hostname, hostname_len)) 487 || memcmp(pos->sm_name, hostname, hostname_len))
489 continue; 488 continue;
490 } else if (!nlm_cmp_addr(&nsm->sm_addr, sin)) 489 } else if (!nlm_cmp_addr(&pos->sm_addr, sin))
491 continue; 490 continue;
492 atomic_inc(&nsm->sm_count); 491 atomic_inc(&pos->sm_count);
492 nsm = pos;
493 goto out; 493 goto out;
494 } 494 }
495 495
@@ -499,15 +499,15 @@ __nsm_find(const struct sockaddr_in *sin,
499 } 499 }
500 500
501 nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL); 501 nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
502 if (nsm != NULL) { 502 if (nsm == NULL)
503 nsm->sm_addr = *sin; 503 goto out;
504 nsm->sm_name = (char *) (nsm + 1); 504 nsm->sm_addr = *sin;
505 memcpy(nsm->sm_name, hostname, hostname_len); 505 nsm->sm_name = (char *) (nsm + 1);
506 nsm->sm_name[hostname_len] = '\0'; 506 memcpy(nsm->sm_name, hostname, hostname_len);
507 atomic_set(&nsm->sm_count, 1); 507 nsm->sm_name[hostname_len] = '\0';
508 508 atomic_set(&nsm->sm_count, 1);
509 list_add(&nsm->sm_link, &nsm_handles); 509
510 } 510 list_add(&nsm->sm_link, &nsm_handles);
511 511
512out: 512out:
513 mutex_unlock(&nsm_mutex); 513 mutex_unlock(&nsm_mutex);