Message ID | 20201102071154.23563-1-yuhaobehappy@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | sound/core/seq: remove dead code | expand |
Hi Yu,
url: https://github.com/0day-ci/linux/commits/Yu-Hao/sound-core-seq-remove-dead-code/20201102-152326
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
compiler: sparc64-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> sound/core/seq/seq_queue.c:545:16: warning: Unused variable: flags [unusedVariable]
unsigned long flags;
^
vim +545 sound/core/seq/seq_queue.c
^1da177e4c3f415 Linus Torvalds 2005-04-16 543 void snd_seq_queue_client_termination(int client)
^1da177e4c3f415 Linus Torvalds 2005-04-16 544 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 @545 unsigned long flags;
^^^^^^^^^^^^^^^^^^^
Unused.
^1da177e4c3f415 Linus Torvalds 2005-04-16 546 int i;
c7e0b5bf9fff1b7 Takashi Iwai 2005-11-17 547 struct snd_seq_queue *q;
^1da177e4c3f415 Linus Torvalds 2005-04-16 548
^1da177e4c3f415 Linus Torvalds 2005-04-16 549 for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 550 if ((q = queueptr(i)) == NULL)
^1da177e4c3f415 Linus Torvalds 2005-04-16 551 continue;
^1da177e4c3f415 Linus Torvalds 2005-04-16 552 queuefree(q);
^1da177e4c3f415 Linus Torvalds 2005-04-16 553 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 554 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Mon, 02 Nov 2020 08:11:54 +0100, Yu Hao wrote: > > The function snd_seq_queue_client_termination() is only called from > function seq_free_client1(). The seq_free_client1() calls function > snd_seq_queue_client_leave(), which deletes all objects whose owner > equals to client->number in global array queue_list, before the function > snd_seq_queue_client_termination(), which checks whether there are > any objects in global array queue_list whose owner equals to > client->number, with the same argument client->number. So > the checking code in function snd_seq_queue_client_termination() is > dead code. Remove those dead code. > > Signed-off-by: Yu Hao <yuhaobehappy@gmail.com> Actually the whole function snd_seq_queue_client_termination() can be removed. It's a quite old code and I don't remember clearly, but I guess the intention was to call this before the actual queue deletion. OTOH, it doesn't make any sense to change that order any longer, as the snd_seq_queue_client_leave() already takes similar procedure anyway, so let's rather wipe off the useless function. Could you resubmit with that change? thanks, Takashi > --- > sound/core/seq/seq_queue.c | 11 ----------- > 1 file changed, 11 deletions(-) > > diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c > index 71a6ea62c3be..91b3f3295d0b 100644 > --- a/sound/core/seq/seq_queue.c > +++ b/sound/core/seq/seq_queue.c > @@ -545,21 +545,10 @@ void snd_seq_queue_client_termination(int client) > unsigned long flags; > int i; > struct snd_seq_queue *q; > - bool matched; > > for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { > if ((q = queueptr(i)) == NULL) > continue; > - spin_lock_irqsave(&q->owner_lock, flags); > - matched = (q->owner == client); > - if (matched) > - q->klocked = 1; > - spin_unlock_irqrestore(&q->owner_lock, flags); > - if (matched) { > - if (q->timer->running) > - snd_seq_timer_stop(q->timer); > - snd_seq_timer_reset(q->timer); > - } > queuefree(q); > } > } > -- > 2.17.1 >
Yes, I can do that. And a quick question, to resubmit with that change means that I should create a new submission and this one ends, right? Thanks. On Tue, Nov 3, 2020 at 5:09 AM Takashi Iwai <tiwai@suse.de> wrote: > On Mon, 02 Nov 2020 08:11:54 +0100, > Yu Hao wrote: > > > > The function snd_seq_queue_client_termination() is only called from > > function seq_free_client1(). The seq_free_client1() calls function > > snd_seq_queue_client_leave(), which deletes all objects whose owner > > equals to client->number in global array queue_list, before the function > > snd_seq_queue_client_termination(), which checks whether there are > > any objects in global array queue_list whose owner equals to > > client->number, with the same argument client->number. So > > the checking code in function snd_seq_queue_client_termination() is > > dead code. Remove those dead code. > > > > Signed-off-by: Yu Hao <yuhaobehappy@gmail.com> > > Actually the whole function snd_seq_queue_client_termination() can be > removed. It's a quite old code and I don't remember clearly, but I > guess the intention was to call this before the actual queue > deletion. OTOH, it doesn't make any sense to change that order any > longer, as the snd_seq_queue_client_leave() already takes similar > procedure anyway, so let's rather wipe off the useless function. > > Could you resubmit with that change? > > > thanks, > > Takashi > > > --- > > sound/core/seq/seq_queue.c | 11 ----------- > > 1 file changed, 11 deletions(-) > > > > diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c > > index 71a6ea62c3be..91b3f3295d0b 100644 > > --- a/sound/core/seq/seq_queue.c > > +++ b/sound/core/seq/seq_queue.c > > @@ -545,21 +545,10 @@ void snd_seq_queue_client_termination(int client) > > unsigned long flags; > > int i; > > struct snd_seq_queue *q; > > - bool matched; > > > > for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { > > if ((q = queueptr(i)) == NULL) > > continue; > > - spin_lock_irqsave(&q->owner_lock, flags); > > - matched = (q->owner == client); > > - if (matched) > > - q->klocked = 1; > > - spin_unlock_irqrestore(&q->owner_lock, flags); > > - if (matched) { > > - if (q->timer->running) > > - snd_seq_timer_stop(q->timer); > > - snd_seq_timer_reset(q->timer); > > - } > > queuefree(q); > > } > > } > > -- > > 2.17.1 > > >
On Tue, 03 Nov 2020 19:43:55 +0100, Yu Hao wrote: > > Yes, I can do that. > > And a quick question, to resubmit with that change means that I should create > a new submission and this one ends, right? Yes, just submit a fresh patch. thanks, Takashi > > Thanks. > > On Tue, Nov 3, 2020 at 5:09 AM Takashi Iwai <tiwai@suse.de> wrote: > > On Mon, 02 Nov 2020 08:11:54 +0100, > Yu Hao wrote: > > > > The function snd_seq_queue_client_termination() is only called from > > function seq_free_client1(). The seq_free_client1() calls function > > snd_seq_queue_client_leave(), which deletes all objects whose owner > > equals to client->number in global array queue_list, before the function > > snd_seq_queue_client_termination(), which checks whether there are > > any objects in global array queue_list whose owner equals to > > client->number, with the same argument client->number. So > > the checking code in function snd_seq_queue_client_termination() is > > dead code. Remove those dead code. > > > > Signed-off-by: Yu Hao <yuhaobehappy@gmail.com> > > Actually the whole function snd_seq_queue_client_termination() can be > removed. It's a quite old code and I don't remember clearly, but I > guess the intention was to call this before the actual queue > deletion. OTOH, it doesn't make any sense to change that order any > longer, as the snd_seq_queue_client_leave() already takes similar > procedure anyway, so let's rather wipe off the useless function. > > Could you resubmit with that change? > > thanks, > > Takashi > > > --- > > sound/core/seq/seq_queue.c | 11 ----------- > > 1 file changed, 11 deletions(-) > > > > diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c > > index 71a6ea62c3be..91b3f3295d0b 100644 > > --- a/sound/core/seq/seq_queue.c > > +++ b/sound/core/seq/seq_queue.c > > @@ -545,21 +545,10 @@ void snd_seq_queue_client_termination(int client) > > unsigned long flags; > > int i; > > struct snd_seq_queue *q; > > - bool matched; > > > > for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { > > if ((q = queueptr(i)) == NULL) > > continue; > > - spin_lock_irqsave(&q->owner_lock, flags); > > - matched = (q->owner == client); > > - if (matched) > > - q->klocked = 1; > > - spin_unlock_irqrestore(&q->owner_lock, flags); > > - if (matched) { > > - if (q->timer->running) > > - snd_seq_timer_stop(q->timer); > > - snd_seq_timer_reset(q->timer); > > - } > > queuefree(q); > > } > > } > > -- > > 2.17.1 > > > >
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 71a6ea62c3be..91b3f3295d0b 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -545,21 +545,10 @@ void snd_seq_queue_client_termination(int client) unsigned long flags; int i; struct snd_seq_queue *q; - bool matched; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) continue; - spin_lock_irqsave(&q->owner_lock, flags); - matched = (q->owner == client); - if (matched) - q->klocked = 1; - spin_unlock_irqrestore(&q->owner_lock, flags); - if (matched) { - if (q->timer->running) - snd_seq_timer_stop(q->timer); - snd_seq_timer_reset(q->timer); - } queuefree(q); } }
The function snd_seq_queue_client_termination() is only called from function seq_free_client1(). The seq_free_client1() calls function snd_seq_queue_client_leave(), which deletes all objects whose owner equals to client->number in global array queue_list, before the function snd_seq_queue_client_termination(), which checks whether there are any objects in global array queue_list whose owner equals to client->number, with the same argument client->number. So the checking code in function snd_seq_queue_client_termination() is dead code. Remove those dead code. Signed-off-by: Yu Hao <yuhaobehappy@gmail.com> --- sound/core/seq/seq_queue.c | 11 ----------- 1 file changed, 11 deletions(-)