[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y7iF/Mu6Wigwkolg@casper.infradead.org>
Date: Fri, 6 Jan 2023 20:35:08 +0000
From: Matthew Wilcox <willy@...radead.org>
To: kernel test robot <lkp@...el.com>
Cc: Jesper Dangaard Brouer <hawk@...nel.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>,
llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
netdev@...r.kernel.org, linux-mm@...ck.org,
Shakeel Butt <shakeelb@...gle.com>
Subject: Re: [PATCH v2 02/24] netmem: Add utility functions
On Fri, Jan 06, 2023 at 10:24:30AM +0800, kernel test robot wrote:
> >> include/net/page_pool.h:111:21: warning: due to lvalue conversion of the controlling expression, association of type 'const struct netmem' will never be selected because it is qualified [-Wunreachable-code-generic-assoc]
> return page_to_pfn(netmem_page(nmem));
> ^
> include/net/page_pool.h:100:8: note: expanded from macro 'netmem_page'
> const struct netmem: (const struct page *)nmem, \
> ^
OK, figured out what this error means.
#define netmem_page(nmem) (_Generic((*nmem), \
const struct netmem: (const struct page *)nmem, \
struct netmem: (struct page *)nmem))
Because I defined this with _Generic((*nmem),...) instead of
_Generic((nmem),...) (like page_folio() is defined), clang always
selects the second case and not the const case. Apparently lvalue
coversions remove the const (backed up by
https://en.cppreference.com/w/c/language/conversion) but I had no idea
that _Generic applied lvalue conversion to the controlling-expression
(it does! https://en.cppreference.com/w/c/language/generic)
So, yay for clang's extra warning. I'll fix this up (as below) and send
a v3 next week including the various R-b that I've received.
-#define netmem_page(nmem) (_Generic((*nmem), \
- const struct netmem: (const struct page *)nmem, \
- struct netmem: (struct page *)nmem))
+#define netmem_page(nmem) (_Generic((nmem), \
+ const struct netmem *: (const struct page *)nmem, \
+ struct netmem *: (struct page *)nmem))
Powered by blists - more mailing lists