diff mbox

mm: swap: make free_swap_and_cache()/swapcache_prepare() inline functions

Message ID 20170823133213.712917-1-arnd@arndb.de
State New
Headers show

Commit Message

Arnd Bergmann Aug. 23, 2017, 1:31 p.m. UTC
We get a build warning from a boolean expression that is never used:

mm/madvise.c: In function 'madvise_free_pte_range':
include/linux/swap.h:490:55: error: value computed is not used [-Werror=unused-value]
 #define free_swap_and_cache(e) (is_migration_entry(e) || is_device_private_entry(e))
                                                       ^~
mm/madvise.c:353:4: note: in expansion of macro 'free_swap_and_cache'
    free_swap_and_cache(entry);

This changes the two macros to a compound expression that gcc does
not warn about. Changing them to inline functions would have been
nicer but is not possible here because that would introduce a recursive
header file dependency.

Fixes: mmotm ("mm/ZONE_DEVICE: new type of ZONE_DEVICE for unaddressable memory")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 include/linux/swap.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.9.0

Comments

Jerome Glisse Aug. 23, 2017, 6:27 p.m. UTC | #1
On Wed, Aug 23, 2017 at 03:31:42PM +0200, Arnd Bergmann wrote:
> We get a build warning from a boolean expression that is never used:

> 

> mm/madvise.c: In function 'madvise_free_pte_range':

> include/linux/swap.h:490:55: error: value computed is not used [-Werror=unused-value]

>  #define free_swap_and_cache(e) (is_migration_entry(e) || is_device_private_entry(e))

>                                                        ^~

> mm/madvise.c:353:4: note: in expansion of macro 'free_swap_and_cache'

>     free_swap_and_cache(entry);

> 

> This changes the two macros to a compound expression that gcc does

> not warn about. Changing them to inline functions would have been

> nicer but is not possible here because that would introduce a recursive

> header file dependency.

> 

> Fixes: mmotm ("mm/ZONE_DEVICE: new type of ZONE_DEVICE for unaddressable memory")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Thanks for taking care of that.

Reviewed-by: Jérôme Glisse <jglisse@redhat.com>
diff mbox

Patch

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 2be396acdf48..8a807292037f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -487,8 +487,8 @@  static inline void show_swap_cache_info(void)
 {
 }
 
-#define free_swap_and_cache(e) (is_migration_entry(e) || is_device_private_entry(e))
-#define swapcache_prepare(e) (is_migration_entry(e) || is_device_private_entry(e))
+#define free_swap_and_cache(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
+#define swapcache_prepare(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
 
 static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask)
 {