[bug report] ALSA: seq: Fix assignment in if condition

Takashi Iwai tiwai at suse.de
Thu Jun 17 15:41:00 CEST 2021


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


More information about the Alsa-devel mailing list