Thread (3 messages) read the whole thread 3 messages, 2 authors, 2022-03-20

Re: [PATCH] cw1200: remove an unneeded NULL check on list iterator

From: Jakob Koschel <hidden>
Date: 2022-03-20 00:47:35
Also in: linux-wireless, lkml

quoted hunk ↗ jump to hunk
On 19. Mar 2022, at 07:38, Xiaomeng Tong [off-list ref] wrote:

The list iterator 'item' is always non-NULL so it doesn't need to be
checked. Thus just remove the unnecessary NULL check. Also remove the
unnecessary initializer because the list iterator is always initialized.

Signed-off-by: Xiaomeng Tong <redacted>
---
drivers/net/wireless/st/cw1200/queue.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/st/cw1200/queue.c b/drivers/net/wireless/st/cw1200/queue.c
index 12952b1c29df..05392598e273 100644
--- a/drivers/net/wireless/st/cw1200/queue.c
+++ b/drivers/net/wireless/st/cw1200/queue.c
@@ -90,7 +90,7 @@ static void __cw1200_queue_gc(struct cw1200_queue *queue,
			      bool unlock)
{
	struct cw1200_queue_stats *stats = queue->stats;
-	struct cw1200_queue_item *item = NULL, *tmp;
+	struct cw1200_queue_item *item, *tmp;
	bool wakeup_stats = false;

	list_for_each_entry_safe(item, tmp, &queue->queue, head) {
@@ -117,7 +117,7 @@ static void __cw1200_queue_gc(struct cw1200_queue *queue,
			queue->overfull = false;
			if (unlock)
				__cw1200_queue_unlock(queue);
-		} else if (item) {
+		} else {
I don't think this is fixing anything here. You are basically just removing
a check that was always true.

I'm pretty sure that this check is here to check if either the list is empty or no
element was found. If I'm not wrong, some time ago, lists where not circular but
actually pointed to NULL (or the head was NULL) so this check made sense but doesn't
anymore.

The appropriate fix would be only setting 'item' when a break is hit and keep
the original check.
			unsigned long tmo = item->queue_timestamp + queue->ttl;
			mod_timer(&queue->gc, tmo);
			cw1200_pm_stay_awake(&stats->priv->pm_state,
-- 
2.17.1
I've made those changes already and I'm in the process of upstreaming them in an organized
way, so maybe it would make sense to synchronize, so we don't post duplicate patches.

        Jakob
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help