mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Srishti Sharma <srishtishar@gmail.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of
Date: Sat, 30 Sep 2017 10:31:16 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1709301028250.2511@hadrien> (raw)
In-Reply-To: <778fb00439b44bd4a9e1ef06b1d619f9e4f5525f.1506755266.git.srishtishar@gmail.com>



On Sat, 30 Sep 2017, Srishti Sharma wrote:

> For variables of type struct list_head* use list_entry to access
> current list element instead of using container_of. Done by the
> following semantic patch by coccinelle.
>
> @r@
> struct list_head* l;
> @@
>
> -container_of
> +list_entry
>   (l,...)
>
> Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
> ---
>  drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index be2f46e..29e9ee9 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -1401,7 +1401,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
>  	plist = phead->next;
>
>  	while (phead != plist) {
> -		pxmitframe = container_of(plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(plist, struct xmit_frame, list);
>
>  		plist = plist->next;

It looks to me like this loop could be rewritten using
list_for_each_entry_safe.  The entry is because you only do something
interesting with the entry and the safe is because the elements of the
list are deleted along the way.  Perhaps the others canbe changed this way
too.

julia



>
> @@ -1432,7 +1432,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	if (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> @@ -1473,7 +1473,7 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi
>  		sta_plist = sta_phead->next;
>
>  		while (sta_phead != sta_plist) {
> -			ptxservq = container_of(sta_plist, struct tx_servq, tx_pending);
> +			ptxservq = list_entry(sta_plist, struct tx_servq, tx_pending);
>
>  			pframe_queue = &ptxservq->sta_pending;
>
> @@ -1811,7 +1811,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc
>  	plist = phead->next;
>
>  	while (phead != plist) {
> -		pxmitframe = container_of(plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(plist, struct xmit_frame, list);
>
>  		plist = plist->next;
>
> @@ -1878,7 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	while (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> @@ -1959,7 +1959,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  		xmitframe_plist = xmitframe_phead->next;
>
>  		while (xmitframe_phead != xmitframe_plist) {
> -			pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +			pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  			xmitframe_plist = xmitframe_plist->next;
>
> @@ -2006,7 +2006,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst
>  	xmitframe_plist = xmitframe_phead->next;
>
>  	while (xmitframe_phead != xmitframe_plist) {
> -		pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
> +		pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list);
>
>  		xmitframe_plist = xmitframe_plist->next;
>
> --
> 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/778fb00439b44bd4a9e1ef06b1d619f9e4f5525f.1506755266.git.srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

  reply	other threads:[~2017-09-30  8:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  7:19 [PATCH 0/6] Replace container_of with list_entry Srishti Sharma
2017-09-30  7:19 ` [PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of Srishti Sharma
2017-09-30  7:19 ` [PATCH 2/6] " Srishti Sharma
2017-09-30  7:20 ` [PATCH 3/6] " Srishti Sharma
2017-09-30  7:20 ` [PATCH 4/6] " Srishti Sharma
2017-09-30  7:20 ` [PATCH 5/6] " Srishti Sharma
2017-09-30  7:21 ` [PATCH 6/6] " Srishti Sharma
2017-09-30  8:31   ` Julia Lawall [this message]
2017-09-30 11:11 ` [PATCH 0/6] Replace container_of with list_entry Tobin C. Harding
2017-10-03 16:14 ` Greg KH
2017-10-03 16:30   ` 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=alpine.DEB.2.20.1709301028250.2511@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=srishtishar@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®