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