diff mbox series

ASoC: fsl_asrc_dma: fully initialize structs

Message ID 20220614101546.1559434-1-s.hauer@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series ASoC: fsl_asrc_dma: fully initialize structs | expand

Commit Message

Sascha Hauer June 14, 2022, 10:15 a.m. UTC
The driver uses two statically ininitialized struct dma_slave_config,
but only one of them is initialized to zero. Initialize config_be to
zero as well to make sure that no fields are filled with random values.
Let the compiler do this instead of explicitly calling memset() which
makes it easier to read.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/fsl/fsl_asrc_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Fabio Estevam June 14, 2022, 11:27 a.m. UTC | #1
Hi Sascha,

On Tue, Jun 14, 2022 at 7:15 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> The driver uses two statically ininitialized struct dma_slave_config,
> but only one of them is initialized to zero. Initialize config_be to
> zero as well to make sure that no fields are filled with random values.
> Let the compiler do this instead of explicitly calling memset() which
> makes it easier to read.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Shengjiu Wang June 14, 2022, 12:11 p.m. UTC | #2
On Tue, Jun 14, 2022 at 6:15 PM Sascha Hauer <s.hauer@pengutronix.de> wrote:

> The driver uses two statically ininitialized struct dma_slave_config,
> but only one of them is initialized to zero. Initialize config_be to
> zero as well to make sure that no fields are filled with random values.
> Let the compiler do this instead of explicitly calling memset() which
> makes it easier to read.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>

Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>

Best regards
Wang Shengjiu

> ---
>  sound/soc/fsl/fsl_asrc_dma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
> index 5038faf035cba..fec56dbb64e60 100644
> --- a/sound/soc/fsl/fsl_asrc_dma.c
> +++ b/sound/soc/fsl/fsl_asrc_dma.c
> @@ -138,7 +138,7 @@ static int fsl_asrc_dma_hw_params(struct
> snd_soc_component *component,
>         struct dma_chan *tmp_chan = NULL, *be_chan = NULL;
>         struct snd_soc_component *component_be = NULL;
>         struct fsl_asrc *asrc = pair->asrc;
> -       struct dma_slave_config config_fe, config_be;
> +       struct dma_slave_config config_fe = {}, config_be = {};
>         enum asrc_pair_index index = pair->index;
>         struct device *dev = component->dev;
>         struct device_node *of_dma_node;
> @@ -181,7 +181,6 @@ static int fsl_asrc_dma_hw_params(struct
> snd_soc_component *component,
>                 return -EINVAL;
>         }
>
> -       memset(&config_fe, 0, sizeof(config_fe));
>         ret = snd_dmaengine_pcm_prepare_slave_config(substream, params,
> &config_fe);
>         if (ret) {
>                 dev_err(dev, "failed to prepare DMA config for
> Front-End\n");
> --
> 2.30.2
>
>
Shengjiu Wang Aug. 5, 2022, 3:06 a.m. UTC | #3
On Tue, Jun 14, 2022 at 6:15 PM Sascha Hauer <s.hauer@pengutronix.de> wrote:

> The driver uses two statically ininitialized struct dma_slave_config,
> but only one of them is initialized to zero. Initialize config_be to
> zero as well to make sure that no fields are filled with random values.
> Let the compiler do this instead of explicitly calling memset() which
> makes it easier to read.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>

Maybe you need to resend this commit and cc Mark.

Best regards
Wang shengjiu

> ---
>  sound/soc/fsl/fsl_asrc_dma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
> index 5038faf035cba..fec56dbb64e60 100644
> --- a/sound/soc/fsl/fsl_asrc_dma.c
> +++ b/sound/soc/fsl/fsl_asrc_dma.c
> @@ -138,7 +138,7 @@ static int fsl_asrc_dma_hw_params(struct
> snd_soc_component *component,
>         struct dma_chan *tmp_chan = NULL, *be_chan = NULL;
>         struct snd_soc_component *component_be = NULL;
>         struct fsl_asrc *asrc = pair->asrc;
> -       struct dma_slave_config config_fe, config_be;
> +       struct dma_slave_config config_fe = {}, config_be = {};
>         enum asrc_pair_index index = pair->index;
>         struct device *dev = component->dev;
>         struct device_node *of_dma_node;
> @@ -181,7 +181,6 @@ static int fsl_asrc_dma_hw_params(struct
> snd_soc_component *component,
>                 return -EINVAL;
>         }
>
> -       memset(&config_fe, 0, sizeof(config_fe));
>         ret = snd_dmaengine_pcm_prepare_slave_config(substream, params,
> &config_fe);
>         if (ret) {
>                 dev_err(dev, "failed to prepare DMA config for
> Front-End\n");
> --
> 2.30.2
>
>
diff mbox series

Patch

diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index 5038faf035cba..fec56dbb64e60 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -138,7 +138,7 @@  static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
 	struct dma_chan *tmp_chan = NULL, *be_chan = NULL;
 	struct snd_soc_component *component_be = NULL;
 	struct fsl_asrc *asrc = pair->asrc;
-	struct dma_slave_config config_fe, config_be;
+	struct dma_slave_config config_fe = {}, config_be = {};
 	enum asrc_pair_index index = pair->index;
 	struct device *dev = component->dev;
 	struct device_node *of_dma_node;
@@ -181,7 +181,6 @@  static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
 		return -EINVAL;
 	}
 
-	memset(&config_fe, 0, sizeof(config_fe));
 	ret = snd_dmaengine_pcm_prepare_slave_config(substream, params, &config_fe);
 	if (ret) {
 		dev_err(dev, "failed to prepare DMA config for Front-End\n");