fs: dlm: use list_first_entry_or_null
authorAlexander Aring <aahringo@redhat.com>
Thu, 17 Nov 2022 22:11:48 +0000 (17:11 -0500)
committerDavid Teigland <teigland@redhat.com>
Mon, 21 Nov 2022 15:45:49 +0000 (09:45 -0600)
Instead of check on list_empty() we can do the same with
list_first_entry_or_null() and return NULL if the returned value is NULL.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/lowcomms.c

index 3106e7f8734478d5b7c8203895b0d8a176e6c3bd..d3302b10b37e0f3946d33eb5cae3cafa3157cc6c 100644 (file)
@@ -214,15 +214,12 @@ static struct writequeue_entry *con_next_wq(struct connection *con)
 {
        struct writequeue_entry *e;
 
-       if (list_empty(&con->writequeue))
-               return NULL;
-
-       e = list_first_entry(&con->writequeue, struct writequeue_entry,
-                            list);
+       e = list_first_entry_or_null(&con->writequeue, struct writequeue_entry,
+                                    list);
        /* if len is zero nothing is to send, if there are users filling
         * buffers we wait until the users are done so we can send more.
         */
-       if (e->users || e->len == 0)
+       if (!e || e->users || e->len == 0)
                return NULL;
 
        return e;