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] [day] [month] [year] [list]
Message-ID: <20250304083524.3fe2ced4@kernel.org>
Date: Tue, 4 Mar 2025 08:35:24 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Paolo Abeni <pabeni@...hat.com>, Christoph Hellwig <hch@....de>, Marek
 Szyprowski <m.szyprowski@...sung.com>, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org, Rasesh Mody <rmody@...vell.com>,
 GR-Linux-NIC-Dev@...vell.com, Andrew Lunn <andrew+netdev@...n.ch>, "David
 S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net v1 1/1] bnx2: Fix unused data compilation warning

On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:
> > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > > index b79925b1c433..927884f10b0f 100644
> > > --- a/include/linux/dma-mapping.h
> > > +++ b/include/linux/dma-mapping.h
> > > @@ -629,7 +629,7 @@ 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(PTR, ADDR_NAME)           (((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)
> > > ---
> > > 
> > > Would that work?  
> 
> Actually it won't work because the variable is under the same ifdeffery.
> What will work is to spreading the ifdeffery to the users, but it doesn't any
> better than __maybe_unsused, which is compact hack (yes, I admit that it is not
> the nicest solution, but it's spread enough in the kernel).

I meant something more like (untested):

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index b79925b1c433..a7ebcede43f6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -629,10 +629,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)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
+#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
 #endif
 
 #endif /* _LINUX_DMA_MAPPING_H */


I just don't know how much code out there depends on PTR not
existing if !CONFIG_NEED_DMA_MAP_STATE

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ