dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH -next] dmaengine: fsl-dpaa2-qdma: Remove unnecessary local variables in DPDMAI_CMD_CREATE macro
@ 2019-10-22 17:16 Nathan Chancellor
  2019-11-02 16:33 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2019-10-22 17:16 UTC (permalink / raw)
  To: Peng Ma, Vinod Koul
  Cc: Dan Williams, dmaengine, linux-kernel, clang-built-linux,
	Nathan Chancellor

Clang warns:

drivers/dma/fsl-dpaa2-qdma/dpdmai.c:148:25: warning: variable 'cfg' is
uninitialized when used within its own initialization [-Wuninitialized]
        DPDMAI_CMD_CREATE(cmd, cfg);
        ~~~~~~~~~~~~~~~~~~~~~~~^~~~
drivers/dma/fsl-dpaa2-qdma/dpdmai.c:42:24: note: expanded from macro
'DPDMAI_CMD_CREATE'
        typeof(_cfg) (cfg) = (_cfg); \
                      ~~~     ^~~~
1 warning generated.

Looking at the preprocessed source, we can see that this is true.

int dpdmai_create(struct fsl_mc_io *mc_io, u32 cmd_flags,
                  const struct dpdmai_cfg *cfg, u16 *token)
{
        struct fsl_mc_command cmd = { 0 };
        int err;

        cmd.header = mc_encode_cmd_header((((0x90E) << 4) | 0), cmd_flags, 0);
        do {
                typeof(cmd)(cmd) = (cmd);
                typeof(cfg)(cfg) = (cfg);
                ((cmd).params[0] |= mc_enc((8), (8), (cfg)->priorities[0]));
                ((cmd).params[0] |= mc_enc((16), (8), (cfg)->priorities[1]));
        } while (0);

I cannot see a good reason to create another version of cfg when the
parameter one will work perfectly fine and cmd can just be used as is.
Remove them to fix this warning.

Fixes: f2835adf8afb ("dmaengine: fsl-dpaa2-qdma: Add the DPDMAI(Data Path DMA Interface) support")
Link: https://github.com/ClangBuiltLinux/linux/issues/746
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/dma/fsl-dpaa2-qdma/dpdmai.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/fsl-dpaa2-qdma/dpdmai.c b/drivers/dma/fsl-dpaa2-qdma/dpdmai.c
index fbc2b2f39bec..f26c0b71688a 100644
--- a/drivers/dma/fsl-dpaa2-qdma/dpdmai.c
+++ b/drivers/dma/fsl-dpaa2-qdma/dpdmai.c
@@ -36,10 +36,8 @@ struct dpdmai_rsp_get_tx_queue {
 	((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
 
 /* cmd, param, offset, width, type, arg_name */
-#define DPDMAI_CMD_CREATE(_cmd, _cfg) \
+#define DPDMAI_CMD_CREATE(cmd, cfg) \
 do { \
-	typeof(_cmd) (cmd) = (_cmd); \
-	typeof(_cfg) (cfg) = (_cfg); \
 	MC_CMD_OP(cmd, 0, 8,  8,  u8,  (cfg)->priorities[0]);\
 	MC_CMD_OP(cmd, 0, 16, 8,  u8,  (cfg)->priorities[1]);\
 } while (0)
-- 
2.23.0


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

* Re: [PATCH -next] dmaengine: fsl-dpaa2-qdma: Remove unnecessary local variables in DPDMAI_CMD_CREATE macro
  2019-10-22 17:16 [PATCH -next] dmaengine: fsl-dpaa2-qdma: Remove unnecessary local variables in DPDMAI_CMD_CREATE macro Nathan Chancellor
@ 2019-11-02 16:33 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2019-11-02 16:33 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Peng Ma, Dan Williams, dmaengine, linux-kernel, clang-built-linux

On 22-10-19, 10:16, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/dma/fsl-dpaa2-qdma/dpdmai.c:148:25: warning: variable 'cfg' is
> uninitialized when used within its own initialization [-Wuninitialized]
>         DPDMAI_CMD_CREATE(cmd, cfg);
>         ~~~~~~~~~~~~~~~~~~~~~~~^~~~
> drivers/dma/fsl-dpaa2-qdma/dpdmai.c:42:24: note: expanded from macro
> 'DPDMAI_CMD_CREATE'
>         typeof(_cfg) (cfg) = (_cfg); \
>                       ~~~     ^~~~
> 1 warning generated.
> 
> Looking at the preprocessed source, we can see that this is true.
> 
> int dpdmai_create(struct fsl_mc_io *mc_io, u32 cmd_flags,
>                   const struct dpdmai_cfg *cfg, u16 *token)
> {
>         struct fsl_mc_command cmd = { 0 };
>         int err;
> 
>         cmd.header = mc_encode_cmd_header((((0x90E) << 4) | 0), cmd_flags, 0);
>         do {
>                 typeof(cmd)(cmd) = (cmd);
>                 typeof(cfg)(cfg) = (cfg);
>                 ((cmd).params[0] |= mc_enc((8), (8), (cfg)->priorities[0]));
>                 ((cmd).params[0] |= mc_enc((16), (8), (cfg)->priorities[1]));
>         } while (0);
> 
> I cannot see a good reason to create another version of cfg when the
> parameter one will work perfectly fine and cmd can just be used as is.
> Remove them to fix this warning.

Applied, thanks

-- 
~Vinod

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 17:16 [PATCH -next] dmaengine: fsl-dpaa2-qdma: Remove unnecessary local variables in DPDMAI_CMD_CREATE macro Nathan Chancellor
2019-11-02 16:33 ` Vinod Koul

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git