Whamcloud - gitweb
LU-6142 lnet: use list_first_entry() in lnet/lnet subdirectory.
[fs/lustre-release.git] / lnet / lnet / nidstrings.c
index d732684..2af9d8a 100644 (file)
@@ -277,11 +277,11 @@ failed:
 static void
 free_addrranges(struct list_head *list)
 {
-       while (!list_empty(list)) {
-               struct addrrange *ar;
-
-               ar = list_entry(list->next, struct addrrange, ar_link);
+       struct addrrange *ar;
 
+       while ((ar = list_first_entry_or_null(list,
+                                             struct addrrange,
+                                             ar_link)) != NULL) {
                cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
                list_del(&ar->ar_link);
                CFS_FREE_PTR(ar);
@@ -702,7 +702,7 @@ libcfs_num_match(__u32 addr, struct list_head *numaddr)
        struct cfs_expr_list *el;
 
        LASSERT(!list_empty(numaddr));
-       el = list_entry(numaddr->next, struct cfs_expr_list, el_link);
+       el = list_first_entry(numaddr, struct cfs_expr_list, el_link);
 
        return cfs_expr_list_match(addr, el);
 }