lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200824094148.GY1793@kadam>
Date:   Mon, 24 Aug 2020 12:41:48 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Coiby Xu <coiby.xu@...il.com>
Cc:     devel@...verdev.osuosl.org, Alex Elder <elder@...nel.org>,
        Vaibhav Agarwal <vaibhav.sr@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Johan Hovold <johan@...nel.org>,
        Mark Greer <mgreer@...malcreek.com>,
        "moderated list:GREYBUS SUBSYSTEM" <greybus-dev@...ts.linaro.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: greybus: fix warnings detected by sparse

On Mon, Aug 24, 2020 at 10:50:59AM +0800, Coiby Xu wrote:
> This patch fix the following warnings from sparse,
> 
> $ make C=2 drivers/staging/greybus/
> drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in initializer (different base types)
> drivers/staging/greybus/audio_codec.c:691:36:    expected unsigned long long [usertype] formats
> drivers/staging/greybus/audio_codec.c:691:36:    got restricted snd_pcm_format_t [usertype]
> drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in initializer (different base types)
> drivers/staging/greybus/audio_codec.c:701:36:    expected unsigned long long [usertype] formats
> drivers/staging/greybus/audio_codec.c:701:36:    got restricted snd_pcm_format_t [usertype]
> drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_module.c:222:25:    expected restricted __le16 [usertype] data_cport
> drivers/staging/greybus/audio_module.c:222:25:    got unsigned short [usertype] intf_cport_id
> drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 degrades to integer
> drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:691:41:    expected unsigned int access
> drivers/staging/greybus/audio_topology.c:691:41:    got restricted __le32 [usertype] access
> drivers/staging/greybus/audio_topology.c:746:44: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:746:44:    expected unsigned int
> drivers/staging/greybus/audio_topology.c:746:44:    got restricted __le32
> drivers/staging/greybus/audio_topology.c:748:52: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:748:52:    expected unsigned int
> drivers/staging/greybus/audio_topology.c:748:52:    got restricted __le32
> drivers/staging/greybus/audio_topology.c:802:42: warning: restricted __le32 degrades to integer
> drivers/staging/greybus/audio_topology.c:805:50: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:805:50:    expected restricted __le32
> drivers/staging/greybus/audio_topology.c:805:50:    got unsigned int
> drivers/staging/greybus/audio_topology.c:814:50: warning: restricted __le32 degrades to integer
> drivers/staging/greybus/audio_topology.c:817:58: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:817:58:    expected restricted __le32
> drivers/staging/greybus/audio_topology.c:817:58:    got unsigned int
> drivers/staging/greybus/audio_topology.c:889:25: warning: incorrect type in assignment (different base types)
> drivers/staging/greybus/audio_topology.c:889:25:    expected unsigned int access
> drivers/staging/greybus/audio_topology.c:889:25:    got restricted __le32 [usertype] access
> 
> Signed-off-by: Coiby Xu <coiby.xu@...il.com>
> ---
>  drivers/staging/greybus/audio_codec.c    |  4 ++--
>  drivers/staging/greybus/audio_module.c   |  2 +-
>  drivers/staging/greybus/audio_topology.c | 18 +++++++++---------
>  3 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
> index 74538f8c5fa4..494aa823e998 100644
> --- a/drivers/staging/greybus/audio_codec.c
> +++ b/drivers/staging/greybus/audio_codec.c
> @@ -688,7 +688,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
>  		.playback = {
>  			.stream_name = "I2S 0 Playback",
>  			.rates = SNDRV_PCM_RATE_48000,
> -			.formats = SNDRV_PCM_FORMAT_S16_LE,
> +			.formats = SNDRV_PCM_FMTBIT_S16_LE,
>  			.rate_max = 48000,
>  			.rate_min = 48000,
>  			.channels_min = 1,
> @@ -698,7 +698,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
>  		.capture = {
>  			.stream_name = "I2S 0 Capture",
>  			.rates = SNDRV_PCM_RATE_48000,
> -			.formats = SNDRV_PCM_FORMAT_S16_LE,
> +			.formats = SNDRV_PCM_FMTBIT_S16_LE,
>  			.rate_max = 48000,
>  			.rate_min = 48000,
>  			.channels_min = 1,

These changes need to be explained better.  We're changing formats from
2 to 1 << 2.

When you're writing commit messages, please imagine me as the target
audience.  I have a fairly decent understanding of the kernel and C, but
I don't know very much about the sound subsystem.

This code used to work, right?  How was it that changing a 2 to a 4
makes it better?  It needs to be explained in the commit message.  This
change probably needs to be split into a separate commit because it
seems different from the rest of the patch.

(Presumably the rest of the patch doesn't affect runtime on little
endian systems.  This is the part which affects runtime so it is
different from the rest).

> diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c
> index 16f60256adb2..00848b84b022 100644
> --- a/drivers/staging/greybus/audio_module.c
> +++ b/drivers/staging/greybus/audio_module.c
> @@ -219,7 +219,7 @@ static int gb_audio_add_data_connection(struct gbaudio_module_info *gbmodule,
>  
>  	greybus_set_drvdata(bundle, gbmodule);
>  	dai->id = 0;
> -	dai->data_cport = connection->intf_cport_id;
> +	dai->data_cport = cpu_to_le16(connection->intf_cport_id);
>  	dai->connection = connection;
>  	list_add(&dai->list, &gbmodule->data_list);
>  

This is correct, but I think you should change the two places which
print the data_cport to print the CPU endian value.

   327          list_for_each_entry(dai, &gbmodule->data_list, list) {
   328                  ret = gb_connection_enable(dai->connection);
   329                  if (ret) {
   330                          dev_err(dev,
   331                                  "%d:Error while enabling %d:data connection\n",
   332                                  ret, dai->data_cport);
   333                          goto disable_data_connection;
   334                  }
   335          }

   449          list_for_each_entry(dai, &gbmodule->data_list, list) {
   450                  ret = gb_connection_enable(dai->connection);
   451                  if (ret) {
   452                          dev_err(dev,
   453                                  "%d:Error while enabling %d:data connection\n",
   454                                  ret, dai->data_cport);
   455                          return ret;
   456                  }
   457          }

Otherwise it's slightly confusing to mix the values.

The rest of the patch seems fine to me.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ