linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <Julia.Lawall@inria.fr>
To: Solarflare linux maintainers <linux-net-drivers@solarflare.com>
Cc: kernel-janitors@vger.kernel.org,
	Edward Cree <ecree@solarflare.com>,
	Martin Habets <mhabets@solarflare.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] sfc: drop unnecessary list_empty
Date: Sun, 26 Jul 2020 12:58:27 +0200	[thread overview]
Message-ID: <1595761112-11003-3-git-send-email-Julia.Lawall@inria.fr> (raw)
In-Reply-To: <1595761112-11003-1-git-send-email-Julia.Lawall@inria.fr>

list_for_each_safe is able to handle an empty list.
The only effect of avoiding the loop is not initializing the
index variable.
Drop list_empty tests in cases where these variables are not
used.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

<smpl>
@@
expression x,e;
iterator name list_for_each_safe;
statement S;
identifier i,j;
@@

-if (!(list_empty(x))) {
   list_for_each_safe(i,j,x) S
- }
 ... when != i
     when != j
(
  i = e;
|
? j = e;
)
</smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 drivers/net/ethernet/sfc/ptp.c |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 393b7cb..bea4725 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -1154,17 +1154,15 @@ static void efx_ptp_drop_time_expired_events(struct efx_nic *efx)
 
 	/* Drop time-expired events */
 	spin_lock_bh(&ptp->evt_lock);
-	if (!list_empty(&ptp->evt_list)) {
-		list_for_each_safe(cursor, next, &ptp->evt_list) {
-			struct efx_ptp_event_rx *evt;
-
-			evt = list_entry(cursor, struct efx_ptp_event_rx,
-					 link);
-			if (time_after(jiffies, evt->expiry)) {
-				list_move(&evt->link, &ptp->evt_free_list);
-				netif_warn(efx, hw, efx->net_dev,
-					   "PTP rx event dropped\n");
-			}
+	list_for_each_safe(cursor, next, &ptp->evt_list) {
+		struct efx_ptp_event_rx *evt;
+
+		evt = list_entry(cursor, struct efx_ptp_event_rx,
+				 link);
+		if (time_after(jiffies, evt->expiry)) {
+			list_move(&evt->link, &ptp->evt_free_list);
+			netif_warn(efx, hw, efx->net_dev,
+				   "PTP rx event dropped\n");
 		}
 	}
 	spin_unlock_bh(&ptp->evt_lock);


  parent reply	other threads:[~2020-07-26 11:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26 10:58 [PATCH 0/7] drop unnecessary list_empty Julia Lawall
2020-07-26 10:58 ` [PATCH 1/7] ASoC: Intel: " Julia Lawall
2020-07-26 10:58 ` Julia Lawall [this message]
2020-07-27 12:13   ` [PATCH 2/7] sfc: " Edward Cree
2020-07-27 17:10   ` David Miller
2020-07-26 10:58 ` [PATCH 3/7] [media] cx231xx: " Julia Lawall
2020-07-26 10:58 ` [PATCH 4/7] net/mlx5: " Julia Lawall
2020-07-27 17:10   ` David Miller
2020-07-28  7:53     ` Saeed Mahameed
2020-07-26 10:58 ` [PATCH 5/7] [media] saa7134: " Julia Lawall
2020-07-26 10:58 ` [PATCH 6/7] [media] tm6000: " Julia Lawall
2020-07-26 10:58 ` [PATCH 7/7] ath: " Julia Lawall
2020-08-14 15:05   ` Kalle Valo
2020-07-30 22:28 ` [PATCH 0/7] " Mark Brown

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=1595761112-11003-3-git-send-email-Julia.Lawall@inria.fr \
    --to=julia.lawall@inria.fr \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net-drivers@solarflare.com \
    --cc=mhabets@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).