linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sound/core/seq: remove dead code
@ 2020-11-02  7:11 Yu Hao
  2020-11-03 12:03 ` [kbuild] " Dan Carpenter
  2020-11-03 13:09 ` Takashi Iwai
  0 siblings, 2 replies; 4+ messages in thread
From: Yu Hao @ 2020-11-02  7:11 UTC (permalink / raw)
  To: perex, tiwai, alsa-devel; +Cc: yuhaobehappy, linux-kernel

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(-)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [kbuild] Re: [PATCH] sound/core/seq: remove dead code
  2020-11-02  7:11 [PATCH] sound/core/seq: remove dead code Yu Hao
@ 2020-11-03 12:03 ` Dan Carpenter
  2020-11-03 13:09 ` Takashi Iwai
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-11-03 12:03 UTC (permalink / raw)
  To: kbuild, Yu Hao, perex, tiwai, alsa-devel
  Cc: lkp, kbuild-all, yuhaobehappy, linux-kernel

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 
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sound/core/seq: remove dead code
  2020-11-02  7:11 [PATCH] sound/core/seq: remove dead code Yu Hao
  2020-11-03 12:03 ` [kbuild] " Dan Carpenter
@ 2020-11-03 13:09 ` Takashi Iwai
       [not found]   ` <CAM0=KirN+ALL=kzQsV2CenBcUNAgP6pQTZaSTEC+oimWmrkjSg@mail.gmail.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2020-11-03 13:09 UTC (permalink / raw)
  To: Yu Hao; +Cc: perex, tiwai, alsa-devel, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sound/core/seq: remove dead code
       [not found]   ` <CAM0=KirN+ALL=kzQsV2CenBcUNAgP6pQTZaSTEC+oimWmrkjSg@mail.gmail.com>
@ 2020-11-03 20:17     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-11-03 20:17 UTC (permalink / raw)
  To: Yu Hao; +Cc: perex, tiwai, alsa-devel, linux-kernel

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
>     >
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-03 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02  7:11 [PATCH] sound/core/seq: remove dead code Yu Hao
2020-11-03 12:03 ` [kbuild] " Dan Carpenter
2020-11-03 13:09 ` Takashi Iwai
     [not found]   ` <CAM0=KirN+ALL=kzQsV2CenBcUNAgP6pQTZaSTEC+oimWmrkjSg@mail.gmail.com>
2020-11-03 20:17     ` Takashi Iwai

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).