From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Shivamurthy Shastri <shivamurthy.shastri@linutronix.de>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz,
hannes@cmpxchg.org, anna-maria@linutronix.de, tglx@linutronix.de
Subject: Re: [PATCH] mm/vmstat: Fix -Wenum-enum-conversion warning in vmstat.h
Date: Fri, 21 Jun 2024 17:59:40 -0700 [thread overview]
Message-ID: <20240621175940.dd080730047a3f5f5a190ea0@linux-foundation.org> (raw)
In-Reply-To: <ZnXC5Xa4R0Mp7FCB@casper.infradead.org>
On Fri, 21 Jun 2024 19:13:57 +0100 Matthew Wilcox <willy@infradead.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.
next prev parent reply other threads:[~2024-06-22 0:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 11:16 Shivamurthy Shastri
2024-06-21 18:13 ` Matthew Wilcox
2024-06-22 0:59 ` Andrew Morton [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621175940.dd080730047a3f5f5a190ea0@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=anna-maria@linutronix.de \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shivamurthy.shastri@linutronix.de \
--cc=tglx@linutronix.de \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox