[PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed

Xiaofeng Lian posted 1 patch 1 month, 3 weeks ago
include/linux/kfifo.h | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
[PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
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..e5972c2b10f9 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_kfifo_data_type(fifo) typeof(*(fifo)->type)
+
+/**
+ * __STACK_SIZE - macro to calculate kfifo's buffer size
+ * @fifo: pointer of kfifo
+ */
+#define __KFIFO_SIZE(fifo)\
+	({\
+		DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
+		(sizeof(*(fifo)) - sizeof(__tmp_kfifo)) / sizeof(get_kfifo_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 : __KFIFO_SIZE(__tmp->buf) - 1;\
 	__kfifo->esize = sizeof(*__tmp->buf); \
 	__kfifo->data = __is_kfifo_ptr(__tmp) ?  NULL : __tmp->buf; \
 })
-- 
2.45.2
Re: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
Posted by kernel test robot 1 month, 2 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-rc2 next-20241008]
[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-fix-some-IDEs-Intelligence-errors-and-the-previous-patch-was-misnamed/20241006-015547
base:   linus/master
patch link:    https://lore.kernel.org/r/20241002172427.412715-1-1198715581lxf%40gmail.com
patch subject: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
config: i386-randconfig-012-20241008 (https://download.01.org/0day-ci/archive/20241008/202410081934.6u1I94gw-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241008/202410081934.6u1I94gw-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/202410081934.6u1I94gw-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:61:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:62:9: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:64:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:65:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   include/linux/kfifo.h:116:56: note: expanded from macro 'DECLARE_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:80:2: note: expanded from macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
>> drivers/greybus/es2.c:1282:2: error: member reference base type 'char' is not a structure or union
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:139:52: note: expanded from macro '__KFIFO_SIZE'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_kfifo)) / sizeof(get_kfifo_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                           ~~~~~~^ ~~~~
>> drivers/greybus/es2.c:1282:2: error: invalid operands to binary expression ('void' and 'int')
    1282 |         INIT_KFIFO(es2->apb_log_fifo);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:71: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
   7 errors generated.


vim +/char +1282 drivers/greybus/es2.c

24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1237  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1238  /*
4d5c446b53655d drivers/staging/greybus/es2.c    Johan Hovold       2015-11-02  1239   * The ES2 USB Bridge device has 15 endpoints
4d5c446b53655d drivers/staging/greybus/es2.c    Johan Hovold       2015-11-02  1240   * 1 Control - usual USB stuff + AP -> APBridgeA messages
4d5c446b53655d drivers/staging/greybus/es2.c    Johan Hovold       2015-11-02  1241   * 7 Bulk IN - CPort data in
4d5c446b53655d drivers/staging/greybus/es2.c    Johan Hovold       2015-11-02  1242   * 7 Bulk OUT - CPort data out
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1243   */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1244  static int ap_probe(struct usb_interface *interface,
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1245  		    const struct usb_device_id *id)
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1246  {
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1247  	struct es2_ap_dev *es2;
2537636abae5b8 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-03  1248  	struct gb_host_device *hd;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1249  	struct usb_device *udev;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1250  	struct usb_host_interface *iface_desc;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1251  	struct usb_endpoint_descriptor *endpoint;
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1252  	__u8 ep_addr;
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1253  	int retval;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1254  	int i;
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1255  	int num_cports;
403074b50b66f1 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1256  	bool bulk_out_found = false;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1257  	bool bulk_in_found = false;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1258  	bool arpc_in_found = false;
4bc1389de9fcaa drivers/staging/greybus/es2.c    Alex Elder         2015-06-13  1259  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1260  	udev = usb_get_dev(interface_to_usbdev(interface));
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1261  
3be0e17d62d5a9 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1262  	num_cports = apb_get_cport_count(udev);
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1263  	if (num_cports < 0) {
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1264  		usb_put_dev(udev);
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1265  		dev_err(&udev->dev, "Cannot retrieve CPort count: %d\n",
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1266  			num_cports);
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1267  		return num_cports;
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1268  	}
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1269  
d6e139bc15118c drivers/staging/greybus/es2.c    Johan Hovold       2015-11-03  1270  	hd = gb_hd_create(&es2_driver, &udev->dev, ES2_GBUF_MSG_SIZE_MAX,
24a6112fa53e8a drivers/staging/greybus/es2.c    Fabien Parent      2015-09-02  1271  			  num_cports);
8ea70fe0497c5d drivers/staging/greybus/es2.c    Alex Elder         2015-05-22  1272  	if (IS_ERR(hd)) {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1273  		usb_put_dev(udev);
8ea70fe0497c5d drivers/staging/greybus/es2.c    Alex Elder         2015-05-22  1274  		return PTR_ERR(hd);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1275  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1276  
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1277  	es2 = hd_to_es2(hd);
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1278  	es2->hd = hd;
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1279  	es2->usb_intf = interface;
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1280  	es2->usb_dev = udev;
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1281  	spin_lock_init(&es2->cport_out_urb_lock);
3be0e17d62d5a9 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27 @1282  	INIT_KFIFO(es2->apb_log_fifo);
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1283  	usb_set_intfdata(interface, es2);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1284  
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1285  	/*
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1286  	 * Reserve the CDSI0 and CDSI1 CPorts so they won't be allocated
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1287  	 * dynamically.
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1288  	 */
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1289  	retval = gb_hd_cport_reserve(hd, ES2_CPORT_CDSI0);
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1290  	if (retval)
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1291  		goto error;
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1292  	retval = gb_hd_cport_reserve(hd, ES2_CPORT_CDSI1);
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1293  	if (retval)
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1294  		goto error;
050615076699e5 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1295  
4d5c446b53655d drivers/staging/greybus/es2.c    Johan Hovold       2015-11-02  1296  	/* find all bulk endpoints */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1297  	iface_desc = interface->cur_altsetting;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1298  	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1299  		endpoint = &iface_desc->endpoint[i].desc;
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1300  		ep_addr = endpoint->bEndpointAddress;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1301  
b767ee402070ce drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2015-07-24  1302  		if (usb_endpoint_is_bulk_in(endpoint)) {
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1303  			if (!bulk_in_found) {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1304  				es2->cport_in.endpoint = ep_addr;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1305  				bulk_in_found = true;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1306  			} else if (!arpc_in_found) {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1307  				es2->arpc_endpoint_in = ep_addr;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1308  				arpc_in_found = true;
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1309  			} else {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1310  				dev_warn(&udev->dev,
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1311  					 "Unused bulk IN endpoint found: 0x%02x\n",
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1312  					 ep_addr);
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1313  			}
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1314  			continue;
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1315  		}
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1316  		if (usb_endpoint_is_bulk_out(endpoint)) {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1317  			if (!bulk_out_found) {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1318  				es2->cport_out_endpoint = ep_addr;
403074b50b66f1 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1319  				bulk_out_found = true;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1320  			} else {
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1321  				dev_warn(&udev->dev,
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1322  					 "Unused bulk OUT endpoint found: 0x%02x\n",
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1323  					 ep_addr);
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1324  			}
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1325  			continue;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1326  		}
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1327  		dev_warn(&udev->dev,
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1328  			 "Unknown endpoint type found, address 0x%02x\n",
272291008fc55e drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1329  			 ep_addr);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1330  	}
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1331  	if (!bulk_in_found || !arpc_in_found || !bulk_out_found) {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1332  		dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1333  		retval = -ENODEV;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1334  		goto error;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1335  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1336  
0ce68ce41779c3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1337  	/* Allocate buffers for our cport in messages */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1338  	for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1339  		struct urb *urb;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1340  		u8 *buffer;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1341  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1342  		urb = usb_alloc_urb(0, GFP_KERNEL);
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1343  		if (!urb) {
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1344  			retval = -ENOMEM;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1345  			goto error;
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1346  		}
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1347  		es2->cport_in.urb[i] = urb;
5f62eab04ab7d7 drivers/staging/greybus/es2.c    Johan Hovold       2016-08-17  1348  
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1349  		buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1350  		if (!buffer) {
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1351  			retval = -ENOMEM;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1352  			goto error;
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1353  		}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1354  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1355  		usb_fill_bulk_urb(urb, udev,
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1356  				  usb_rcvbulkpipe(udev, es2->cport_in.endpoint),
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1357  				  buffer, ES2_GBUF_MSG_SIZE_MAX,
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1358  				  cport_in_callback, hd);
5f62eab04ab7d7 drivers/staging/greybus/es2.c    Johan Hovold       2016-08-17  1359  
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1360  		es2->cport_in.buffer[i] = buffer;
606addd2847ccc drivers/staging/greybus/es2.c    Alexandre Bailon   2015-06-15  1361  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1362  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1363  	/* Allocate buffers for ARPC in messages */
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1364  	for (i = 0; i < NUM_ARPC_IN_URB; ++i) {
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1365  		struct urb *urb;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1366  		u8 *buffer;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1367  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1368  		urb = usb_alloc_urb(0, GFP_KERNEL);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1369  		if (!urb) {
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1370  			retval = -ENOMEM;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1371  			goto error;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1372  		}
5f62eab04ab7d7 drivers/staging/greybus/es2.c    Johan Hovold       2016-08-17  1373  		es2->arpc_urb[i] = urb;
5f62eab04ab7d7 drivers/staging/greybus/es2.c    Johan Hovold       2016-08-17  1374  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1375  		buffer = kmalloc(ARPC_IN_SIZE_MAX, GFP_KERNEL);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1376  		if (!buffer) {
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1377  			retval = -ENOMEM;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1378  			goto error;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1379  		}
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1380  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1381  		usb_fill_bulk_urb(urb, udev,
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1382  				  usb_rcvbulkpipe(udev,
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1383  						  es2->arpc_endpoint_in),
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1384  				  buffer, ARPC_IN_SIZE_MAX,
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1385  				  arpc_in_callback, es2);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1386  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1387  		es2->arpc_buffer[i] = buffer;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1388  	}
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1389  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1390  	/* Allocate urbs for our CPort OUT messages */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1391  	for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1392  		struct urb *urb;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1393  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1394  		urb = usb_alloc_urb(0, GFP_KERNEL);
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1395  		if (!urb) {
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1396  			retval = -ENOMEM;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1397  			goto error;
be5d01f10bdb78 drivers/staging/greybus/es2.c    Johan Hovold       2016-05-11  1398  		}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1399  
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1400  		es2->cport_out_urb[i] = urb;
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1401  		es2->cport_out_urb_busy[i] = false;	/* just to be anal */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1402  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1403  
3be0e17d62d5a9 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1404  	/* XXX We will need to rename this per APB */
3be0e17d62d5a9 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1405  	es2->apb_log_enable_dentry = debugfs_create_file("apb_log_enable",
563a8412c563cd drivers/staging/greybus/es2.c    Gioh Kim           2017-02-09  1406  							 0644,
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1407  							 gb_debugfs_get(), es2,
3be0e17d62d5a9 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  1408  							 &apb_log_enable_fops);
0ce68ce41779c3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1409  
c14118a8411c4d drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1410  	INIT_LIST_HEAD(&es2->arpcs);
c14118a8411c4d drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1411  	spin_lock_init(&es2->arpc_lock);
c14118a8411c4d drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1412  
1305f2b2f52af5 drivers/staging/greybus/es2.c    Wei Yongjun        2016-10-19  1413  	retval = es2_arpc_in_enable(es2);
1305f2b2f52af5 drivers/staging/greybus/es2.c    Wei Yongjun        2016-10-19  1414  	if (retval)
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1415  		goto error;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1416  
c1700479845bc3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1417  	retval = gb_hd_add(hd);
c1700479845bc3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1418  	if (retval)
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1419  		goto err_disable_arpc_in;
c1700479845bc3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1420  
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1421  	retval = es2_cport_in_enable(es2, &es2->cport_in);
0ce68ce41779c3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1422  	if (retval)
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1423  		goto err_hd_del;
0ce68ce41779c3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1424  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1425  	return 0;
57bc17ffc566de drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1426  
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  1427  err_hd_del:
c1700479845bc3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1428  	gb_hd_del(hd);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1429  err_disable_arpc_in:
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  1430  	es2_arpc_in_disable(es2);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1431  error:
57bc17ffc566de drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  1432  	es2_destroy(es2);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1433  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1434  	return retval;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1435  }
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  1436  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
Posted by kernel test robot 1 month, 2 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-rc2 next-20241008]
[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-fix-some-IDEs-Intelligence-errors-and-the-previous-patch-was-misnamed/20241006-015547
base:   linus/master
patch link:    https://lore.kernel.org/r/20241002172427.412715-1-1198715581lxf%40gmail.com
patch subject: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
config: i386-buildonly-randconfig-005-20241008 (https://download.01.org/0day-ci/archive/20241008/202410081818.V12XcEDC-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241008/202410081818.V12XcEDC-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/202410081818.V12XcEDC-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:61:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:62:9: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:64:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:65:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   include/linux/kfifo.h:116:56: note: expanded from macro 'DECLARE_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:80:2: note: expanded from macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: member reference base type 'typeof(struct sec_request_el *)' (aka 'struct sec_request_el *') is not a structure or union
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:139:52: note: expanded from macro '__KFIFO_SIZE'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_kfifo)) / sizeof(get_kfifo_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                           ~~~~~~^ ~~~~
>> drivers/crypto/hisilicon/sec/sec_algs.c:912:2: error: invalid operands to binary expression ('void' and 'int')
     912 |         INIT_KFIFO(ctx->queue->softqueue);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:71: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
   7 errors generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for MODVERSIONS
   Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
   Selected by [y]:
   - RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]


vim +912 drivers/crypto/hisilicon/sec/sec_algs.c

915e4e8413dacc Jonathan Cameron 2018-07-23  902  
915e4e8413dacc Jonathan Cameron 2018-07-23  903  static int sec_alg_skcipher_init_with_queue(struct crypto_skcipher *tfm)
915e4e8413dacc Jonathan Cameron 2018-07-23  904  {
915e4e8413dacc Jonathan Cameron 2018-07-23  905  	struct sec_alg_tfm_ctx *ctx = crypto_skcipher_ctx(tfm);
915e4e8413dacc Jonathan Cameron 2018-07-23  906  	int ret;
915e4e8413dacc Jonathan Cameron 2018-07-23  907  
915e4e8413dacc Jonathan Cameron 2018-07-23  908  	ret = sec_alg_skcipher_init(tfm);
915e4e8413dacc Jonathan Cameron 2018-07-23  909  	if (ret)
915e4e8413dacc Jonathan Cameron 2018-07-23  910  		return ret;
915e4e8413dacc Jonathan Cameron 2018-07-23  911  
915e4e8413dacc Jonathan Cameron 2018-07-23 @912  	INIT_KFIFO(ctx->queue->softqueue);
915e4e8413dacc Jonathan Cameron 2018-07-23  913  	ret = kfifo_alloc(&ctx->queue->softqueue, 512, GFP_KERNEL);
915e4e8413dacc Jonathan Cameron 2018-07-23  914  	if (ret) {
915e4e8413dacc Jonathan Cameron 2018-07-23  915  		sec_alg_skcipher_exit(tfm);
915e4e8413dacc Jonathan Cameron 2018-07-23  916  		return ret;
915e4e8413dacc Jonathan Cameron 2018-07-23  917  	}
915e4e8413dacc Jonathan Cameron 2018-07-23  918  	ctx->queue->havesoftqueue = true;
915e4e8413dacc Jonathan Cameron 2018-07-23  919  
915e4e8413dacc Jonathan Cameron 2018-07-23  920  	return 0;
915e4e8413dacc Jonathan Cameron 2018-07-23  921  }
915e4e8413dacc Jonathan Cameron 2018-07-23  922  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
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-fix-some-IDEs-Intelligence-errors-and-the-previous-patch-was-misnamed/20241003-012640
base:   linus/master
patch link:    https://lore.kernel.org/r/20241002172427.412715-1-1198715581lxf%40gmail.com
patch subject: [PATCH v2] include/linux/kfifo.h: fix some IDEs Intelligence errors and the previous patch was misnamed
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20241005/202410051712.VDmFpiVZ-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241005/202410051712.VDmFpiVZ-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/202410051712.VDmFpiVZ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:61:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      61 |                 datatype        *type; \
         |                 ^~~~~~~~
>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:79:24: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:62:9: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      62 |                 const datatype  *const_type; \
         |                       ^~~~~~~~
>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:64:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      64 |                 ptrtype         *ptr; \
         |                 ^~~~~~~
>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/kfifo.h:84:37: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:79:39: note: expanded from macro '__STRUCT_KFIFO_PTR'
      79 |         __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
   include/linux/kfifo.h:65:3: note: expanded from macro '__STRUCT_KFIFO_COMMON'
      65 |                 ptrtype const   *ptr_const; \
         |                 ^~~~~~~
>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:138:34: note: expanded from macro '__KFIFO_SIZE'
     138 |                 DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                                 ^ ~~~~
   include/linux/kfifo.h:116:56: note: expanded from macro 'DECLARE_KFIFO_PTR'
     116 | #define DECLARE_KFIFO_PTR(fifo, type)   STRUCT_KFIFO_PTR(type) fifo
         |                                         ~~~~~~~~~~~~~~~~~^~~~~
   include/linux/kfifo.h:84:28: note: expanded from macro 'STRUCT_KFIFO_PTR'
      84 |         struct __STRUCT_KFIFO_PTR(type, 0, type)
         |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
   include/linux/kfifo.h:80:2: note: expanded from macro '__STRUCT_KFIFO_PTR'
      80 |         type            buf[0]; \
         |         ^~~~
>> arch/x86/kvm/hyperv.c:984:3: error: member reference base type 'u64' (aka 'unsigned long long') is not a structure or union
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:46: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:139:52: note: expanded from macro '__KFIFO_SIZE'
     139 |                 (sizeof(*(fifo)) - sizeof(__tmp_kfifo)) / sizeof(get_kfifo_data_type(fifo));\
         |                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:130:49: note: expanded from macro 'get_kfifo_data_type'
     130 | #define get_kfifo_data_type(fifo) typeof(*(fifo)->type)
         |                                           ~~~~~~^ ~~~~
>> arch/x86/kvm/hyperv.c:984:3: error: invalid operands to binary expression ('void' and 'int')
     984 |                 INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:151:71: note: expanded from macro 'INIT_KFIFO'
     151 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp->buf) - 1;\
         |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
   7 errors generated.


vim +984 arch/x86/kvm/hyperv.c

1f4b34f825e8ce Andrey Smetanin     2015-11-30  959  
3be29eb7b5251a Sean Christopherson 2022-08-30  960  int kvm_hv_vcpu_init(struct kvm_vcpu *vcpu)
5c919412fe61c3 Andrey Smetanin     2015-11-10  961  {
1cac8d9f6bd25d Sean Christopherson 2022-08-30  962  	struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
1f4b34f825e8ce Andrey Smetanin     2015-11-30  963  	int i;
1f4b34f825e8ce Andrey Smetanin     2015-11-30  964  
1cac8d9f6bd25d Sean Christopherson 2022-08-30  965  	if (hv_vcpu)
1cac8d9f6bd25d Sean Christopherson 2022-08-30  966  		return 0;
1cac8d9f6bd25d Sean Christopherson 2022-08-30  967  
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  968  	hv_vcpu = kzalloc(sizeof(struct kvm_vcpu_hv), GFP_KERNEL_ACCOUNT);
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  969  	if (!hv_vcpu)
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  970  		return -ENOMEM;
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  971  
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  972  	vcpu->arch.hyperv = hv_vcpu;
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  973  	hv_vcpu->vcpu = vcpu;
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  974  
1f4b34f825e8ce Andrey Smetanin     2015-11-30  975  	synic_init(&hv_vcpu->synic);
1f4b34f825e8ce Andrey Smetanin     2015-11-30  976  
1f4b34f825e8ce Andrey Smetanin     2015-11-30  977  	bitmap_zero(hv_vcpu->stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);
1f4b34f825e8ce Andrey Smetanin     2015-11-30  978  	for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++)
1f4b34f825e8ce Andrey Smetanin     2015-11-30  979  		stimer_init(&hv_vcpu->stimer[i], i);
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  980  
4eeef2424153e7 Sean Christopherson 2021-09-10  981  	hv_vcpu->vp_index = vcpu->vcpu_idx;
fc08b628d7c96d Vitaly Kuznetsov    2021-01-26  982  
53ca765a041d5a Vitaly Kuznetsov    2022-11-01  983  	for (i = 0; i < HV_NR_TLB_FLUSH_FIFOS; i++) {
53ca765a041d5a Vitaly Kuznetsov    2022-11-01 @984  		INIT_KFIFO(hv_vcpu->tlb_flush_fifo[i].entries);
53ca765a041d5a Vitaly Kuznetsov    2022-11-01  985  		spin_lock_init(&hv_vcpu->tlb_flush_fifo[i].write_lock);
53ca765a041d5a Vitaly Kuznetsov    2022-11-01  986  	}
0823570f01989d Vitaly Kuznetsov    2022-11-01  987  
4592b7eaa87d35 Vitaly Kuznetsov    2021-01-26  988  	return 0;
5c919412fe61c3 Andrey Smetanin     2015-11-10  989  }
5c919412fe61c3 Andrey Smetanin     2015-11-10  990  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
[PATCH v3 1/2] include/linux/kfifo.h: fix some IDEs Intelligence errors
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..66eb1b8971f7 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_kfifo_data_type(fifo) typeof(*(fifo)->type)
+
+/**
+ * __KFIFO_SIZE - macro to calculate kfifo's buffer size
+ * @fifo: pointer of kfifo
+ */
+#define __KFIFO_SIZE(fifo)\
+	({\
+		DECLARE_KFIFO_PTR(__tmp_kfifo, get_kfifo_data_type(fifo));\
+		(sizeof(*(fifo)) - sizeof(__tmp_kfifo)) / sizeof(get_kfifo_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 : __KFIFO_SIZE(__tmp->buf) - 1;\
 	__kfifo->esize = sizeof(*__tmp->buf); \
 	__kfifo->data = __is_kfifo_ptr(__tmp) ?  NULL : __tmp->buf; \
 })
-- 
2.45.2
[PATCH v3 2/2] include/linux/kfifo.h:fix errors
Posted by Xiaofeng Lian 1 month, 3 weeks ago
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410051712.VDmFpiVZ-lkp@intel.com/

    - Fixed an error detected by the kernel test robot caused by an
      incorrectly passed parameter in the INIT_KFIFO macro.

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

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 66eb1b8971f7..316b6c019550 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -148,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 : __KFIFO_SIZE(__tmp->buf) - 1;\
+	__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : __KFIFO_SIZE(__tmp) - 1;\
 	__kfifo->esize = sizeof(*__tmp->buf); \
 	__kfifo->data = __is_kfifo_ptr(__tmp) ?  NULL : __tmp->buf; \
 })
-- 
2.45.2