All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srishti Sharma <srishtishar@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	 Linux kernel mailing list <linux-kernel@vger.kernel.org>,
	 outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of
Date: Sat, 30 Sep 2017 11:31:17 +0530	[thread overview]
Message-ID: <CAB3L5oz0BXtxrWKXFPG0MqM7tGFrbjT376Hjz1GM2KHox_DDcQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1709300702330.2511@hadrien>

On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> For variables of the type struct list_head* use list_entry to access
>> the current list element instead of using container_of.
>> Done using the following semantic patch by coccinelle.
>>
>> @r@
>> identifier e;
>> struct list_head* l;
>> @@
>>
>> <... when != l == NULL
>> l;
>> ...>
> I don't see what is the goal of the above code.  The list_head variable is
> not going to be in a statement by itself.  There is also no need to check
> for l being NULL.  If it is NULL, the original code is incorrect too.

Since only those container_of are to replaced with list_entry which
have a variable of type list_head*  , I wanted to check if it occurs
anywhere before
container_of , which it only does in it's declaration , because it
can't be in any
statement by itself . I think it will be better to write .

@r@
identifier e;
struct list_head* l;
@@

<...
container_of(l,...);
...>

e =
-container_of
+list_entry
     (
      ....)

>> (
>> e =
>> -container_of
>> +list_entry
>>      (
>>       ...)
>> )
>
> Here you don't need the outer ( ).  This makes a disjunction with only
> one choice.  Since there is only one choice, you don't need the
> disjunction.

Thanks a lot , for pointing out the errors .

Regards,
Srishti
> julia
>
>> Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> index 22cf362..f9df4ac 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> @@ -152,8 +152,8 @@ u32       _rtw_free_sta_priv(struct       sta_priv *pstapriv)
>>                       while (phead != plist) {
>>                               int i;
>>
>> -                             psta = container_of(plist, struct sta_info,
>> -                                                 hash_list);
>> +                             psta = list_entry(plist, struct sta_info,
>> +                                               hash_list);
>>                               plist = plist->next;
>>
>>                               for (i = 0; i < 16; i++) {
>> @@ -323,7 +323,7 @@ u32       rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
>>               plist = phead->next;
>>
>>               while (!list_empty(phead)) {
>> -                     prframe = container_of(plist, struct recv_frame, list);
>> +                     prframe = list_entry(plist, struct recv_frame, list);
>>
>>                       plist = plist->next;
>>
>> @@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
>>               plist = phead->next;
>>
>>               while (phead != plist) {
>> -                     psta = container_of(plist, struct sta_info, hash_list);
>> +                     psta = list_entry(plist, struct sta_info, hash_list);
>>
>>                       plist = plist->next;
>>
>> @@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
>>       plist = phead->next;
>>
>>       while (phead != plist) {
>> -             psta = container_of(plist, struct sta_info, hash_list);
>> +             psta = list_entry(plist, struct sta_info, hash_list);
>>
>>               if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
>>                       /*  if found the matched address */
>> @@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
>>       phead = get_list_head(pacl_node_q);
>>       plist = phead->next;
>>       while (phead != plist) {
>> -             paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
>> +             paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
>>               plist = plist->next;
>>
>>               if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
>> --
>> 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/1506734581-10932-1-git-send-email-srishtishar%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>


  reply	other threads:[~2017-09-30  6:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  1:23 [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma
2017-09-30  5:05 ` [Outreachy kernel] " Julia Lawall
2017-09-30  6:01   ` Srishti Sharma [this message]
2017-09-30  6:06     ` Julia Lawall
2017-09-30  6:17       ` Srishti Sharma
2017-09-30  6:21         ` Julia Lawall
2017-09-30  6:24           ` Srishti Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAB3L5oz0BXtxrWKXFPG0MqM7tGFrbjT376Hjz1GM2KHox_DDcQ@mail.gmail.com \
    --to=srishtishar@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.