[PATCH] include/linux/kfifo.h

Xiaofeng Lian posted 1 patch 1 month, 3 weeks ago
include/linux/kfifo.h | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
[PATCH] include/linux/kfifo.h
Posted by Xiaofeng Lian 1 month, 3 weeks ago
In some IDEs, when using the ARRAY_SIZE macro to calculate the
buf size of kfifo, an error occurs (using incomplete types),
which belongs to the compiler INTELLIGENCE reporting error,
and can be compiled normally, specifically due to the gcc
compiler's __builtin_types_compatible_p function. Because the
KFIFO_PTR type uses a zero-length array and the macro definition
is a simple substitution, the ARRAY_SIZE macro will report
an error because of the zero-length array when calculating
__kfifo_esize in the INIT_KFIFO macro. Notice that the difference
between KFIFO and KFIFO_PTR is only whether or not the buf is inlined,
so (sizeof(KFIFO) - sizeof(KFIFO_PTR)) / sizeof(type_of_kfifo_member)
will give you the size of the buf of the kfifo, which bypasses the
compiler! Intelligence and bypasses the possibility that
ARRAY_SIZE may be passed in as a pointer, resulting in a compilation
error.

Signed-off-by: Xiaofeng Lian <1198715581lxf@gmail.com>
---
 include/linux/kfifo.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 564868bdce89..c080716b5125 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -123,6 +123,21 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
  */
 #define DECLARE_KFIFO(fifo, type, size)	STRUCT_KFIFO(type, size) fifo
 
+/**
+ * get_kfifo_data_type - macro to get type of kfifo's member
+ * @fifo: pointer of kfifo
+ */
+#define get_stack_data_type(fifo) typeof(*(fifo)->type)
+
+/**
+ * __STACK_SIZE - macro to calculate kfifo's buffer size
+ * @fifo: pointer of kfifo
+ */
+#define __STACK_SIZE(fifo)\
+	({\
+		DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
+		(sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
+	 })
 /**
  * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
  * @fifo: name of the declared fifo datatype
@@ -133,7 +148,7 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
 	struct __kfifo *__kfifo = &__tmp->kfifo; \
 	__kfifo->in = 0; \
 	__kfifo->out = 0; \
-	__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\
+	__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
 	__kfifo->esize = sizeof(*__tmp->buf); \
 	__kfifo->data = __is_kfifo_ptr(__tmp) ?  NULL : __tmp->buf; \
 })
-- 
2.45.2
Re: [PATCH] include/linux/kfifo.h
Posted by kernel test robot 1 month, 3 weeks ago
Hi Xiaofeng,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.12-rc1 next-20241004]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xiaofeng-Lian/include-linux-kfifo-h/20241003-002015
base:   linus/master
patch link:    https://lore.kernel.org/r/20241002161437.376042-1-1198715581lxf%40gmail.com
patch subject: [PATCH] include/linux/kfifo.h
config: sparc64-randconfig-r073-20241004 (https://download.01.org/0day-ci/archive/20241004/202410041700.hpvbX22r-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241004/202410041700.hpvbX22r-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410041700.hpvbX22r-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/gpio/gpiolib-cdev.c:20:
   drivers/gpio/gpiolib-cdev.c: In function 'linereq_create':
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:61:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:62:23: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:64:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:65:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:80:9: note: in definition of macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_event' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:139:66: note: in expansion of macro 'get_stack_data_type'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:1782:9: note: in expansion of macro 'INIT_KFIFO'
    1782 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c: In function 'lineevent_create':
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:61:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:62:23: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:64:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:65:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:80:9: note: in definition of macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpioevent_data' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:139:66: note: in expansion of macro 'get_stack_data_type'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2245:9: note: in expansion of macro 'INIT_KFIFO'
    2245 |         INIT_KFIFO(le->events);
         |         ^~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c: In function 'gpio_chrdev_open':
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:61:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:62:23: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:64:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:65:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:80:9: note: in definition of macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: 'struct gpio_v2_line_info_changed' has no member named 'type'
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:139:66: note: in expansion of macro 'get_stack_data_type'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpio/gpiolib-cdev.c:2777:9: note: in expansion of macro 'INIT_KFIFO'
    2777 |         INIT_KFIFO(cdev->events);
         |         ^~~~~~~~~~
..


vim +130 include/linux/kfifo.h

   125	
   126	/**
   127	 * get_kfifo_data_type - macro to get type of kfifo's member
   128	 * @fifo: pointer of kfifo
   129	 */
 > 130	#define get_stack_data_type(fifo) typeof(*(fifo)->type)
   131	
   132	/**
   133	 * __STACK_SIZE - macro to calculate kfifo's buffer size
   134	 * @fifo: pointer of kfifo
   135	 */
   136	#define __STACK_SIZE(fifo)\
   137		({\
   138			DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
   139			(sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
   140		 })
   141	/**
   142	 * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
   143	 * @fifo: name of the declared fifo datatype
   144	 */
   145	#define INIT_KFIFO(fifo) \
   146	(void)({ \
   147		typeof(&(fifo)) __tmp = &(fifo); \
   148		struct __kfifo *__kfifo = &__tmp->kfifo; \
   149		__kfifo->in = 0; \
   150		__kfifo->out = 0; \
 > 151		__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
   152		__kfifo->esize = sizeof(*__tmp->buf); \
   153		__kfifo->data = __is_kfifo_ptr(__tmp) ?  NULL : __tmp->buf; \
   154	})
   155	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] include/linux/kfifo.h
Posted by kernel test robot 1 month, 3 weeks ago
Hi Xiaofeng,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.12-rc1 next-20241004]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xiaofeng-Lian/include-linux-kfifo-h/20241003-002015
base:   linus/master
patch link:    https://lore.kernel.org/r/20241002161437.376042-1-1198715581lxf%40gmail.com
patch subject: [PATCH] include/linux/kfifo.h
config: x86_64-buildonly-randconfig-002-20241004 (https://download.01.org/0day-ci/archive/20241004/202410041702.fCzWLtzn-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241004/202410041702.fCzWLtzn-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410041702.fCzWLtzn-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/crypto/hisilicon/sec/sec_drv.h:8,
                    from drivers/crypto/hisilicon/sec/sec_algs.c:17:
   drivers/crypto/hisilicon/sec/sec_algs.c: In function 'sec_alg_skcipher_init_with_queue':
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:61:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:62:23: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:64:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:65:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:80:9: note: in definition of macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct sec_request_el **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:139:66: note: in expansion of macro 'get_stack_data_type'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/crypto/hisilicon/sec/sec_algs.c:912:9: note: in expansion of macro 'INIT_KFIFO'
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~
--
   In file included from drivers/gpu/drm/sun4i/sun4i_drv.c:11:
   drivers/gpu/drm/sun4i/sun4i_drv.c: In function 'sun4i_drv_probe':
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:61:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:62:23: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:64:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:65:17: note: in definition of macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
   include/linux/kfifo.h:84:16: note: in expansion of macro '__STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:80:9: note: in definition of macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
   include/linux/kfifo.h:116:41: note: in expansion of macro 'STRUCT_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:17: note: in expansion of macro 'DECLARE_KFIFO_PTR'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                 ^~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:48: note: in expansion of macro 'get_stack_data_type'
     138 |                 DECLARE_KFIFO_PTR(__tmp_stack, get_stack_data_type(fifo));\
         |                                                ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~
>> include/linux/kfifo.h:130:49: error: '*(struct device_node **)&__tmp->buf' is a pointer; did you mean to use '->'?
     130 | #define get_stack_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^~
   include/linux/kfifo.h:139:66: note: in expansion of macro 'get_stack_data_type'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_stack)) / sizeof(get_stack_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:53: note: in expansion of macro '__STACK_SIZE'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __STACK_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~
   drivers/gpu/drm/sun4i/sun4i_drv.c:372:9: note: in expansion of macro 'INIT_KFIFO'
     372 |         INIT_KFIFO(list.fifo);
         |         ^~~~~~~~~~


vim +130 include/linux/kfifo.h

   125	
   126	/**
   127	 * get_kfifo_data_type - macro to get type of kfifo's member
   128	 * @fifo: pointer of kfifo
   129	 */
 > 130	#define get_stack_data_type(fifo) typeof(*(fifo)->type)
   131	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki