Re: [PATCH] mm/vmstat: Fix -Wenum-enum-conversion warning in vmstat.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 21, 2024 at 01:16:04PM +0200, Shivamurthy Shastri wrote:
> 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':

OK, but why do we want -Wenum-enum-conversion enabled?  The code looks
perfectly fine before, and now it looks ugly.  What bugs does this
warning catch?

>  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_"
>  }

and honestly, I'd convert it to an int instead of enum node_stat_item.
Because it is not a node_stat_item, and it wouldn't make sense to
add two node_stat_items together.  Just like it doesn't make sense to
add two pointers together (but it does make sense to add an integer to a
pointer).




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux