linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmstat: Fix -Wenum-enum-conversion warning in vmstat.h
@ 2024-06-21 11:16 Shivamurthy Shastri
  2024-06-21 18:13 ` Matthew Wilcox
  2024-10-07 20:13 ` Aleksei Vetrov
  0 siblings, 2 replies; 10+ messages in thread
From: Shivamurthy Shastri @ 2024-06-21 11:16 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: akpm, vbabka, willy, hannes, anna-maria, tglx, shivamurthy.shastri

A W=1 build with -Wenum-enum-conversion enabled, results in the
following build warning due to an arithmetic operation between different
enumeration types 'enum node_stat_item' and 'enum lru_list':

  include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
    514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
        |                               ~~~~~~~~~~~ ^ ~~~

Address this by casting lru to the proper type.

Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linutronix.de>
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 include/linux/vmstat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 735eae6e272c..72ecd46fd0c4 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -511,7 +511,7 @@ static inline const char *node_stat_name(enum node_stat_item item)
 
 static inline const char *lru_list_name(enum lru_list lru)
 {
-	return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
+	return node_stat_name(NR_LRU_BASE + (enum node_stat_item)lru) + 3; // skip "nr_"
 }
 
 static inline const char *writeback_stat_name(enum writeback_stat_item item)
-- 
2.34.1



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

end of thread, other threads:[~2024-10-16 18:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21 11:16 [PATCH] mm/vmstat: Fix -Wenum-enum-conversion warning in vmstat.h Shivamurthy Shastri
2024-06-21 18:13 ` Matthew Wilcox
2024-06-22  0:59   ` Andrew Morton
2024-10-07 20:13 ` Aleksei Vetrov
2024-10-08  0:51   ` Nathan Chancellor
2024-10-10 10:40     ` Aleksei Vetrov
2024-10-11 14:05       ` Arnd Bergmann
2024-10-15  8:47         ` Nathan Chancellor
2024-10-15 16:55           ` Aleksei Vetrov
2024-10-16 18:02             ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox