All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ALSA: seq: Fix assignment in if condition
@ 2021-06-17 13:18 Dan Carpenter
  2021-06-17 13:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-06-17 13:18 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel

Hello Takashi Iwai,

The patch f9a6bb841f73: "ALSA: seq: Fix assignment in if condition"
from Jun 8, 2021, leads to the following static checker warning:

	sound/core/seq/oss/seq_oss_init.c:99 snd_seq_oss_create_client()
	warn: 'port->addr.port' is unsigned

sound/core/seq/oss/seq_oss_init.c
    82  
    83          /* create annoucement receiver port */
    84          memset(port, 0, sizeof(*port));
    85          strcpy(port->name, "Receiver");
    86          port->addr.client = system_client;
    87          port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
    88          port->type = 0;
    89  
    90          memset(&port_callback, 0, sizeof(port_callback));
    91          /* don't set port_callback.owner here. otherwise the module counter
    92           * is incremented and we can no longer release the module..
    93           */
    94          port_callback.event_input = receive_announce;
    95          port->kernel = &port_callback;
    96          
    97          call_ctl(SNDRV_SEQ_IOCTL_CREATE_PORT, port);
    98          system_port = port->addr.port;
    99          if (system_port >= 0) {
                    ^^^^^^^^^^^^^^^^
This was from the old code.  It's not clear what is going on.  I think
the condition can be deleted.

   100                  struct snd_seq_port_subscribe subs;
   101  
   102                  memset(&subs, 0, sizeof(subs));
   103                  subs.sender.client = SNDRV_SEQ_CLIENT_SYSTEM;
   104                  subs.sender.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE;
   105                  subs.dest.client = system_client;
   106                  subs.dest.port = system_port;
   107                  call_ctl(SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, &subs);
   108          }
   109          rc = 0;
   110  
   111          /* look up midi devices */
   112          schedule_work(&async_lookup_work);
   113  
   114   __error:
   115          kfree(port);
   116          return rc;
   117  }

regards,
dan carpenter

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

* Re: [bug report] ALSA: seq: Fix assignment in if condition
  2021-06-17 13:18 [bug report] ALSA: seq: Fix assignment in if condition Dan Carpenter
@ 2021-06-17 13:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-06-17 13:41 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel

On Thu, 17 Jun 2021 15:18:03 +0200,
Dan Carpenter wrote:
> 
> Hello Takashi Iwai,
> 
> The patch f9a6bb841f73: "ALSA: seq: Fix assignment in if condition"
> from Jun 8, 2021, leads to the following static checker warning:
> 
> 	sound/core/seq/oss/seq_oss_init.c:99 snd_seq_oss_create_client()
> 	warn: 'port->addr.port' is unsigned
> 
> sound/core/seq/oss/seq_oss_init.c
>     82  
>     83          /* create annoucement receiver port */
>     84          memset(port, 0, sizeof(*port));
>     85          strcpy(port->name, "Receiver");
>     86          port->addr.client = system_client;
>     87          port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
>     88          port->type = 0;
>     89  
>     90          memset(&port_callback, 0, sizeof(port_callback));
>     91          /* don't set port_callback.owner here. otherwise the module counter
>     92           * is incremented and we can no longer release the module..
>     93           */
>     94          port_callback.event_input = receive_announce;
>     95          port->kernel = &port_callback;
>     96          
>     97          call_ctl(SNDRV_SEQ_IOCTL_CREATE_PORT, port);
>     98          system_port = port->addr.port;
>     99          if (system_port >= 0) {
>                     ^^^^^^^^^^^^^^^^
> This was from the old code.  It's not clear what is going on.  I think
> the condition can be deleted.

Yeah, that's a quite old code.  The check should have been like

	if (call_ctl(SNDRV_SEQ_IOCTL_CREATE_PORT, port) >= 0) {
		....

and system_port is assigned in that block.
I'll cook up the patch.


thanks,

Takashi

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

end of thread, other threads:[~2021-06-17 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 13:18 [bug report] ALSA: seq: Fix assignment in if condition Dan Carpenter
2021-06-17 13:41 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.