netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bailey Forrest <bcf@google.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH net] gve: DQO: Suppress unused var warnings
Date: Tue, 28 Sep 2021 13:04:07 -0700	[thread overview]
Message-ID: <CANH7hM65PdbPfk44Dp0UG=A5sambfnHGsJsW+Mnr1n4J5nc96A@mail.gmail.com> (raw)
In-Reply-To: <CAK8P3a1P9ZGBCub2s62OjrUa1Hwk66zHHESEj06MPY8qwjK7Ag@mail.gmail.com>

On Tue, Sep 28, 2021 at 7:15 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> On Tue, Sep 28, 2021 at 2:00 AM Bailey Forrest <bcf@google.com> wrote:
> > On Mon, Sep 27, 2021 at 4:21 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > > On Mon, 27 Sep 2021 13:21:30 -0700 Bailey Forrest wrote:
> > >
> > > Looks like fixing this on the wrong end, dma_unmap_len_set()
> > > and friends should always evaluate their arguments.
> >
> > That makes sense.
> >
> > Arnd, if you want to fix this inside of the dma_* macros, the
> > following diff resolves the errors reported for this driver:
>
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index dca2b1355bb1..f51eee0f678e 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -590,10 +590,21 @@ static inline int dma_mmap_wc(struct device *dev,
> >  #else
> >  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
> >  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> > -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> > -#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> > -#define dma_unmap_len(PTR, LEN_NAME)             (0)
> > -#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> > +
> > +#define dma_unmap_addr(PTR, ADDR_NAME) ({ (void)PTR; 0; })
> > +
> > +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { \
>
> Unfortunately, this breaks every other driver using these macros, as the
> point of them is that the unmap-address is not actually defined
> and not taking up space in data structure. Referencing it by name
> is a compile-time bug.

My patch works with a small modification:

```
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index dca2b1355bb1..04ca5467562e 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -590,10 +590,10 @@ static inline int dma_mmap_wc(struct device *dev,
 #else
 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
-#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
-#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
-#define dma_unmap_len(PTR, LEN_NAME)             (0)
-#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
+#define dma_unmap_addr(PTR, ADDR_NAME) ({ (void)PTR; 0; })
+#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { (void)PTR; } while (0)
+#define dma_unmap_len(PTR, LEN_NAME) ({ (void)PTR; 0; })
+#define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { (void)PTR; } while (0)
 #endif

 #endif /* _LINUX_DMA_MAPPING_H */
```


To me, this is still the preferred solution. However, your latest
patch looked fine to me.

      reply	other threads:[~2021-09-28 20:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 23:19 [PATCH net] gve: DQO: Suppress unused var warnings Bailey Forrest
2021-09-27  9:58 ` Arnd Bergmann
2021-09-27 20:21   ` Bailey Forrest
2021-09-27 23:21     ` Jakub Kicinski
2021-09-27 23:59       ` Bailey Forrest
2021-09-28 14:15         ` Arnd Bergmann
2021-09-28 20:04           ` Bailey Forrest [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANH7hM65PdbPfk44Dp0UG=A5sambfnHGsJsW+Mnr1n4J5nc96A@mail.gmail.com' \
    --to=bcf@google.com \
    --cc=arnd@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).