From: Julia Lawall Date: Sun, 26 Jul 2020 10:58:30 +0000 (+0200) Subject: saa7134: drop unnecessary list_empty X-Git-Tag: microblaze-v5.11~178^2~423 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=a357a7840702d24a7d55d0f950af35b1be1ee005;p=linux-2.6-microblaze.git saa7134: drop unnecessary list_empty 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/) @@ 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; ) Signed-off-by: Julia Lawall Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index e3ccb464c044..e3eedb1e9632 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -359,14 +359,12 @@ void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q) struct saa7134_buf *tmp; spin_lock_irqsave(&dev->slock, flags); - if (!list_empty(&q->queue)) { - list_for_each_safe(pos, n, &q->queue) { - tmp = list_entry(pos, struct saa7134_buf, entry); - vb2_buffer_done(&tmp->vb2.vb2_buf, - VB2_BUF_STATE_ERROR); - list_del(pos); - tmp = NULL; - } + list_for_each_safe(pos, n, &q->queue) { + tmp = list_entry(pos, struct saa7134_buf, entry); + vb2_buffer_done(&tmp->vb2.vb2_buf, + VB2_BUF_STATE_ERROR); + list_del(pos); + tmp = NULL; } spin_unlock_irqrestore(&dev->slock, flags); saa7134_buffer_timeout(&q->timeout); /* also calls del_timer(&q->timeout) */