Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [vhost:vhost 32/52] include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
@ 2020-08-05 20:17 kernel test robot
  2020-08-05 23:51 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2020-08-05 20:17 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: kbuild-all, kvm, virtualization, netdev

[-- Attachment #1: Type: text/plain, Size: 4889 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head:   4c05433bc6fb4ae172270f0279be8ba89a3da64f
commit: b025584098e621d88894d28e80af686958e273af [32/52] virtio_input: convert to LE accessors
config: parisc-randconfig-r003-20200805 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout b025584098e621d88894d28e80af686958e273af
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/irqflags.h:15,
                    from include/asm-generic/cmpxchg-local.h:6,
                    from arch/parisc/include/asm/cmpxchg.h:89,
                    from arch/parisc/include/asm/atomic.h:10,
                    from include/linux/atomic.h:7,
                    from arch/parisc/include/asm/bitops.h:13,
                    from include/linux/bitops.h:29,
                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from drivers/virtio/virtio_input.c:2:
   drivers/virtio/virtio_input.c: In function 'virtinput_probe':
>> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
      12 |  (void)(&__dummy == &__dummy2); \
         |                  ^~
   include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
     405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
         |   ^~~~~~~~~
   drivers/virtio/virtio_input.c:247:3: note: in expansion of macro 'virtio_cread_le'
     247 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
         |   ^~~~~~~~~~~~~~~
>> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
      12 |  (void)(&__dummy == &__dummy2); \
         |                  ^~
   include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
     405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
         |   ^~~~~~~~~
   drivers/virtio/virtio_input.c:249:3: note: in expansion of macro 'virtio_cread_le'
     249 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
         |   ^~~~~~~~~~~~~~~
>> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
      12 |  (void)(&__dummy == &__dummy2); \
         |                  ^~
   include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
     405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
         |   ^~~~~~~~~
   drivers/virtio/virtio_input.c:251:3: note: in expansion of macro 'virtio_cread_le'
     251 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
         |   ^~~~~~~~~~~~~~~
>> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
      12 |  (void)(&__dummy == &__dummy2); \
         |                  ^~
   include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
     405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
         |   ^~~~~~~~~
   drivers/virtio/virtio_input.c:253:3: note: in expansion of macro 'virtio_cread_le'
     253 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
         |   ^~~~~~~~~~~~~~~

vim +12 include/linux/typecheck.h

e0deaff470900a4 Andrew Morton 2008-07-25   4  
e0deaff470900a4 Andrew Morton 2008-07-25   5  /*
e0deaff470900a4 Andrew Morton 2008-07-25   6   * Check at compile time that something is of a particular type.
e0deaff470900a4 Andrew Morton 2008-07-25   7   * Always evaluates to 1 so you may use it easily in comparisons.
e0deaff470900a4 Andrew Morton 2008-07-25   8   */
e0deaff470900a4 Andrew Morton 2008-07-25   9  #define typecheck(type,x) \
e0deaff470900a4 Andrew Morton 2008-07-25  10  ({	type __dummy; \
e0deaff470900a4 Andrew Morton 2008-07-25  11  	typeof(x) __dummy2; \
e0deaff470900a4 Andrew Morton 2008-07-25 @12  	(void)(&__dummy == &__dummy2); \
e0deaff470900a4 Andrew Morton 2008-07-25  13  	1; \
e0deaff470900a4 Andrew Morton 2008-07-25  14  })
e0deaff470900a4 Andrew Morton 2008-07-25  15  

:::::: The code at line 12 was first introduced by commit
:::::: e0deaff470900a4c3222ca7139f6c9639e26a2f5 split the typecheck macros out of include/linux/kernel.h

:::::: TO: Andrew Morton <akpm@linux-foundation.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22500 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [vhost:vhost 32/52] include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
  2020-08-05 20:17 [vhost:vhost 32/52] include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast kernel test robot
@ 2020-08-05 23:51 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2020-08-05 23:51 UTC (permalink / raw)
  To: kernel test robot; +Cc: kbuild-all, kvm, virtualization, netdev

On Thu, Aug 06, 2020 at 04:17:13AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
> head:   4c05433bc6fb4ae172270f0279be8ba89a3da64f
> commit: b025584098e621d88894d28e80af686958e273af [32/52] virtio_input: convert to LE accessors
> config: parisc-randconfig-r003-20200805 (attached as .config)
> compiler: hppa-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout b025584098e621d88894d28e80af686958e273af
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc 

Weird. So the following fixes it:


diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index ecb166c824bb..8fe857e27ef3 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -357,10 +357,10 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
  */
 #define virtio_le_to_cpu(x) \
 	_Generic((x), \
-		__u8: (x), \
-		 __le16: le16_to_cpu(x), \
-		 __le32: le32_to_cpu(x), \
-		 __le64: le64_to_cpu(x) \
+		__u8: (u8)(x), \
+		 __le16: (u16)le16_to_cpu(x), \
+		 __le32: (u32)le32_to_cpu(x), \
+		 __le64: (u64)le64_to_cpu(x) \
 		)
 
 #define virtio_cpu_to_le(x, m) \
@@ -400,7 +400,6 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
 		*(ptr) = virtio_le_to_cpu(virtio_cread_v);		\
 	} while(0)
 
-/* Config space accessors. */
 #define virtio_cwrite_le(vdev, structname, member, ptr)			\
 	do {								\
 		typeof(((structname*)0)->member) virtio_cwrite_v =	\


How could this be? le16_to_cpu doesn't return a u16?
I suspect this compiler gets confused by _Generic.
Let's hope it does not also miscompile the code :)


> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/irqflags.h:15,
>                     from include/asm-generic/cmpxchg-local.h:6,
>                     from arch/parisc/include/asm/cmpxchg.h:89,
>                     from arch/parisc/include/asm/atomic.h:10,
>                     from include/linux/atomic.h:7,
>                     from arch/parisc/include/asm/bitops.h:13,
>                     from include/linux/bitops.h:29,
>                     from include/linux/kernel.h:12,
>                     from include/linux/list.h:9,
>                     from include/linux/module.h:12,
>                     from drivers/virtio/virtio_input.c:2:
>    drivers/virtio/virtio_input.c: In function 'virtinput_probe':
> >> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
>       12 |  (void)(&__dummy == &__dummy2); \
>          |                  ^~
>    include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
>      405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
>          |   ^~~~~~~~~
>    drivers/virtio/virtio_input.c:247:3: note: in expansion of macro 'virtio_cread_le'
>      247 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
>          |   ^~~~~~~~~~~~~~~
> >> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
>       12 |  (void)(&__dummy == &__dummy2); \
>          |                  ^~
>    include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
>      405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
>          |   ^~~~~~~~~
>    drivers/virtio/virtio_input.c:249:3: note: in expansion of macro 'virtio_cread_le'
>      249 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
>          |   ^~~~~~~~~~~~~~~
> >> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
>       12 |  (void)(&__dummy == &__dummy2); \
>          |                  ^~
>    include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
>      405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
>          |   ^~~~~~~~~
>    drivers/virtio/virtio_input.c:251:3: note: in expansion of macro 'virtio_cread_le'
>      251 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
>          |   ^~~~~~~~~~~~~~~
> >> include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
>       12 |  (void)(&__dummy == &__dummy2); \
>          |                  ^~
>    include/linux/virtio_config.h:405:3: note: in expansion of macro 'typecheck'
>      405 |   typecheck(typeof(virtio_le_to_cpu(virtio_cread_v)), *(ptr)); \
>          |   ^~~~~~~~~
>    drivers/virtio/virtio_input.c:253:3: note: in expansion of macro 'virtio_cread_le'
>      253 |   virtio_cread_le(vi->vdev, struct virtio_input_config,
>          |   ^~~~~~~~~~~~~~~
> 
> vim +12 include/linux/typecheck.h
> 
> e0deaff470900a4 Andrew Morton 2008-07-25   4  
> e0deaff470900a4 Andrew Morton 2008-07-25   5  /*
> e0deaff470900a4 Andrew Morton 2008-07-25   6   * Check at compile time that something is of a particular type.
> e0deaff470900a4 Andrew Morton 2008-07-25   7   * Always evaluates to 1 so you may use it easily in comparisons.
> e0deaff470900a4 Andrew Morton 2008-07-25   8   */
> e0deaff470900a4 Andrew Morton 2008-07-25   9  #define typecheck(type,x) \
> e0deaff470900a4 Andrew Morton 2008-07-25  10  ({	type __dummy; \
> e0deaff470900a4 Andrew Morton 2008-07-25  11  	typeof(x) __dummy2; \
> e0deaff470900a4 Andrew Morton 2008-07-25 @12  	(void)(&__dummy == &__dummy2); \
> e0deaff470900a4 Andrew Morton 2008-07-25  13  	1; \
> e0deaff470900a4 Andrew Morton 2008-07-25  14  })
> e0deaff470900a4 Andrew Morton 2008-07-25  15  
> 
> :::::: The code at line 12 was first introduced by commit
> :::::: e0deaff470900a4c3222ca7139f6c9639e26a2f5 split the typecheck macros out of include/linux/kernel.h
> 
> :::::: TO: Andrew Morton <akpm@linux-foundation.org>
> :::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-05 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 20:17 [vhost:vhost 32/52] include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast kernel test robot
2020-08-05 23:51 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).