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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240621175940.dd080730047a3f5f5a190ea0@linux-foundation.org>
Date: Fri, 21 Jun 2024 17:59:40 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Matthew Wilcox <willy@...radead.org>
Cc: Shivamurthy Shastri <shivamurthy.shastri@...utronix.de>,
 linux-kernel@...r.kernel.org, linux-mm@...ck.org, vbabka@...e.cz,
 hannes@...xchg.org, anna-maria@...utronix.de, tglx@...utronix.de
Subject: Re: [PATCH] mm/vmstat: Fix -Wenum-enum-conversion warning in
 vmstat.h

On Fri, 21 Jun 2024 19:13:57 +0100 Matthew Wilcox <willy@...radead.org> wrote:

> 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).

Yeah, I suppose so.  The calling code iterates across enums with an
int, imaginatively called `i'.

Then again, it seems right that a function called lru_list_name() takes
an enum lru_list.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ