Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1592795 > unrolled thread
| Started by | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| First post | 2017-03-05 18:20 +0100 |
| Last post | 2017-03-05 18:50 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe simran singhal <singhalsimran0@gmail.com> - 2017-03-05 18:20 +0100
Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:50 +0100
Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe Julia Lawall <julia.lawall@lip6.fr> - 2017-03-05 18:50 +0100
Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-05 18:50 +0100
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-05 18:20 +0100 |
| Subject | [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe |
| Message-ID | <thHZ8-3pL-7@gated-at.bofh.it> |
Doubly linked lists which are iterated using list_empty
and list_entry macros have been replaced with list_for_each_entry_safe
macro.
This makes the iteration simpler and more readable.
This patch replaces the while loop containing list_empty and list_entry
with list_for_each_entry_safe.
This was done with Coccinelle.
@@
expression E1;
identifier I1, I2;
type T;
iterator name list_for_each_entry_safe;
@@
T *I1;
+ T *tmp;
...
- while (list_empty(&E1) == 0)
+ list_for_each_entry_safe (I1, tmp, &E1, I2)
{
...when != T *I1;
- I1 = list_entry(E1.next, T, I2);
...
}
Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
index 8ffd000..fe1c0af 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
@@ -98,12 +98,11 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
static void sec_process_ctx_list(void)
{
struct ptlrpc_cli_ctx *ctx;
+ struct ptlrpc_cli_ctx *tmp;
spin_lock(&sec_gc_ctx_list_lock);
- while (!list_empty(&sec_gc_ctx_list)) {
- ctx = list_entry(sec_gc_ctx_list.next,
- struct ptlrpc_cli_ctx, cc_gc_chain);
+ list_for_each_entry_safe(ctx, tmp, &sec_gc_ctx_list, cc_gc_chain) {
list_del_init(&ctx->cc_gc_chain);
spin_unlock(&sec_gc_ctx_list_lock);
--
2.7.4
[toc] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2017-03-05 18:50 +0100 |
| Subject | Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe |
| Message-ID | <thIs9-3HM-3@gated-at.bofh.it> |
| In reply to | #1592795 |
On Sun, 5 Mar 2017, SIMRAN SINGHAL wrote:
> On Sun, Mar 5, 2017 at 11:09 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> > On Sun, 5 Mar 2017, simran singhal wrote:
> >
> >> Doubly linked lists which are iterated using list_empty
> >> and list_entry macros have been replaced with list_for_each_entry_safe
> >> macro.
> >> This makes the iteration simpler and more readable.
> >>
> >> This patch replaces the while loop containing list_empty and list_entry
> >> with list_for_each_entry_safe.
> >>
> >> This was done with Coccinelle.
> >>
> >> @@
> >> expression E1;
> >> identifier I1, I2;
> >> type T;
> >> iterator name list_for_each_entry_safe;
> >> @@
> >>
> >> T *I1;
> >> + T *tmp;
> >> ...
> >> - while (list_empty(&E1) == 0)
> >> + list_for_each_entry_safe (I1, tmp, &E1, I2)
> >> {
> >> ...when != T *I1;
> >> - I1 = list_entry(E1.next, T, I2);
> >> ...
> >> }
> >>
> >> Signed-off-by: simran singhal <singhalsimran0@gmail.com>
> >> ---
> >> drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 5 ++---
> >> 1 file changed, 2 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> >> index 8ffd000..fe1c0af 100644
> >> --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> >> +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> >> @@ -98,12 +98,11 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
> >> static void sec_process_ctx_list(void)
> >> {
> >> struct ptlrpc_cli_ctx *ctx;
> >> + struct ptlrpc_cli_ctx *tmp;
> >
> > Another improvement would be to define both variables at once:
> >
> > T *I1
> > + , *tmp
> > ;
> >
> This is particulary for this patch or for all the patches of this patch-series.
All, I would guess. Unless the line gets too long.
julia
>
> > julia
> >
> >>
> >> spin_lock(&sec_gc_ctx_list_lock);
> >>
> >> - while (!list_empty(&sec_gc_ctx_list)) {
> >> - ctx = list_entry(sec_gc_ctx_list.next,
> >> - struct ptlrpc_cli_ctx, cc_gc_chain);
> >> + list_for_each_entry_safe(ctx, tmp, &sec_gc_ctx_list, cc_gc_chain) {
> >> list_del_init(&ctx->cc_gc_chain);
> >> spin_unlock(&sec_gc_ctx_list_lock);
> >>
> >> --
> >> 2.7.4
> >>
> >> --
> >> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> >> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488733610-22289-3-git-send-email-singhalsimran0%40gmail.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
>
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2017-03-05 18:50 +0100 |
| Subject | Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe |
| Message-ID | <thIs9-3HM-5@gated-at.bofh.it> |
| In reply to | #1592795 |
On Sun, 5 Mar 2017, simran singhal wrote:
> Doubly linked lists which are iterated using list_empty
> and list_entry macros have been replaced with list_for_each_entry_safe
> macro.
> This makes the iteration simpler and more readable.
>
> This patch replaces the while loop containing list_empty and list_entry
> with list_for_each_entry_safe.
>
> This was done with Coccinelle.
>
> @@
> expression E1;
> identifier I1, I2;
> type T;
> iterator name list_for_each_entry_safe;
> @@
>
> T *I1;
> + T *tmp;
> ...
> - while (list_empty(&E1) == 0)
> + list_for_each_entry_safe (I1, tmp, &E1, I2)
> {
> ...when != T *I1;
> - I1 = list_entry(E1.next, T, I2);
> ...
> }
>
> Signed-off-by: simran singhal <singhalsimran0@gmail.com>
> ---
> drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> index 8ffd000..fe1c0af 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
> @@ -98,12 +98,11 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
> static void sec_process_ctx_list(void)
> {
> struct ptlrpc_cli_ctx *ctx;
> + struct ptlrpc_cli_ctx *tmp;
Another improvement would be to define both variables at once:
T *I1
+ , *tmp
;
julia
>
> spin_lock(&sec_gc_ctx_list_lock);
>
> - while (!list_empty(&sec_gc_ctx_list)) {
> - ctx = list_entry(sec_gc_ctx_list.next,
> - struct ptlrpc_cli_ctx, cc_gc_chain);
> + list_for_each_entry_safe(ctx, tmp, &sec_gc_ctx_list, cc_gc_chain) {
> list_del_init(&ctx->cc_gc_chain);
> spin_unlock(&sec_gc_ctx_list_lock);
>
> --
> 2.7.4
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488733610-22289-3-git-send-email-singhalsimran0%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
[toc] | [prev] | [next] | [standalone]
| From | SIMRAN SINGHAL <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-05 18:50 +0100 |
| Subject | Re: [Outreachy kernel] [PATCH 2/5] staging: lustre: ptlrpc: Use list_for_each_entry_safe |
| Message-ID | <thIs9-3HM-7@gated-at.bofh.it> |
| In reply to | #1592809 |
On Sun, Mar 5, 2017 at 11:09 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Sun, 5 Mar 2017, simran singhal wrote:
>
>> Doubly linked lists which are iterated using list_empty
>> and list_entry macros have been replaced with list_for_each_entry_safe
>> macro.
>> This makes the iteration simpler and more readable.
>>
>> This patch replaces the while loop containing list_empty and list_entry
>> with list_for_each_entry_safe.
>>
>> This was done with Coccinelle.
>>
>> @@
>> expression E1;
>> identifier I1, I2;
>> type T;
>> iterator name list_for_each_entry_safe;
>> @@
>>
>> T *I1;
>> + T *tmp;
>> ...
>> - while (list_empty(&E1) == 0)
>> + list_for_each_entry_safe (I1, tmp, &E1, I2)
>> {
>> ...when != T *I1;
>> - I1 = list_entry(E1.next, T, I2);
>> ...
>> }
>>
>> Signed-off-by: simran singhal <singhalsimran0@gmail.com>
>> ---
>> drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
>> index 8ffd000..fe1c0af 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
>> @@ -98,12 +98,11 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
>> static void sec_process_ctx_list(void)
>> {
>> struct ptlrpc_cli_ctx *ctx;
>> + struct ptlrpc_cli_ctx *tmp;
>
> Another improvement would be to define both variables at once:
>
> T *I1
> + , *tmp
> ;
>
This is particulary for this patch or for all the patches of this patch-series.
> julia
>
>>
>> spin_lock(&sec_gc_ctx_list_lock);
>>
>> - while (!list_empty(&sec_gc_ctx_list)) {
>> - ctx = list_entry(sec_gc_ctx_list.next,
>> - struct ptlrpc_cli_ctx, cc_gc_chain);
>> + list_for_each_entry_safe(ctx, tmp, &sec_gc_ctx_list, cc_gc_chain) {
>> list_del_init(&ctx->cc_gc_chain);
>> spin_unlock(&sec_gc_ctx_list_lock);
>>
>> --
>> 2.7.4
>>
>> --
>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488733610-22289-3-git-send-email-singhalsimran0%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web