Skip to contentSkip to conversation

Staging: lustre: lnet: selftest: Use list_first_entry

PATCH In review Bhumika Goyal 2 participants 2 messages Mar 6, 2016 – Mar 7, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: lnet: selftest: Use list_first_entry

This patch replaces list_entry with list_first_entry as it makes the code more clear.
Done using coccinelle:

@@
expression e;
@@
(
- list_entry(e->next,
+ list_first_entry(e,
...)
|
- list_entry(e->prev,
+ list_last_entry(e,
...)
)

---
 drivers/staging/lustre/lnet/selftest/rpc.c   | 4 ++--
 drivers/staging/lustre/lnet/selftest/timer.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/selftest/rpc.c +2 -2
index 129fa02..842ee0b 100644
@@ -212,8 +212,8 @@ srpc_service_fini(struct srpc_service *svc)
 				break;
 
 			while (!list_empty(q)) {
-				buf = list_entry(q->next, struct srpc_buffer,
-						 buf_list);
+				buf = list_first_entry(q, struct srpc_buffer,
+						       buf_list);
 				list_del(&buf->buf_list);
 				LIBCFS_FREE(buf, sizeof(*buf));
 			}
drivers/staging/lustre/lnet/selftest/timer.c +1 -1
index f9f37ba..acfa226 100644
@@ -128,7 +128,7 @@ stt_expire_list(struct list_head *slot, time64_t now)
 	struct stt_timer *timer;
 
 	while (!list_empty(slot)) {
-		timer = list_entry(slot->next, struct stt_timer, stt_list);
+		timer = list_first_entry(slot, struct stt_timer, stt_list);
 
 		if (timer->stt_expires > now)
 			break;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Bhumika Goyal

This patch replaces list_entry with list_first_entry as it makes the code more clear.

Shouldn't these be using list_for_each_entry_safe?

julia

Quoted 59 lines

Done using coccinelle:

@@
expression e;
@@
(
- list_entry(e->next,
+ list_first_entry(e,
...)
|
- list_entry(e->prev,
+ list_last_entry(e,
...)
)

---
 drivers/staging/lustre/lnet/selftest/rpc.c   | 4 ++--
 drivers/staging/lustre/lnet/selftest/timer.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lnet/selftest/rpc.c +2 -2
index 129fa02..842ee0b 100644
@@ -212,8 +212,8 @@ srpc_service_fini(struct srpc_service *svc)
 				break;
 
 			while (!list_empty(q)) {
-				buf = list_entry(q->next, struct srpc_buffer,
-						 buf_list);
+				buf = list_first_entry(q, struct srpc_buffer,
+						       buf_list);
 				list_del(&buf->buf_list);
 				LIBCFS_FREE(buf, sizeof(*buf));
 			}
drivers/staging/lustre/lnet/selftest/timer.c +1 -2
index f9f37ba..acfa226 100644
@@ -128,7 +128,7 @@ stt_expire_list(struct list_head *slot, time64_t now)
 	struct stt_timer *timer;
 
 	while (!list_empty(slot)) {
-		timer = list_entry(slot->next, struct stt_timer, stt_list);
+		timer = list_first_entry(slot, struct stt_timer, stt_list);
 
 		if (timer->stt_expires > now)
 			break;
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1457278655-16379-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.