staging : gpib : agilent_82350b : agilent_82350b.c : fixes checks on the file
It has recommended to
Prefer kzalloc(sizeof(*board->private_data)...) over kzalloc(sizeof(struct agilent_82350b_priv)...)
--- drivers/staging/gpib/agilent_82350b/agilent_82350b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +1 -1
@@ -479,7 +479,7 @@ static void agilent_82350b_return_to_local(struct gpib_board *board)static int agilent_82350b_allocate_private (struct gpib_board *board) { - board->private_data =kzalloc (sizeof (struct agilent_82350b_priv ),GFP_KERNEL ); + board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);if (!board->private_data)return -ENOMEM ;return 0 ;
Signature · 1 line
2.43.0
Quoted 25 lines · Rujra Bhatt
It has recommended to
Prefer kzalloc(sizeof(*board->private_data)...) overkzalloc(sizeof(struct agilent_82350b_priv)...)Signed-off-by Rujra Bhatt <[email protected]>--- drivers/staging/gpib/agilent_82350b/agilent_82350b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/gpib/agilent_82350b/agilent_82350b.c +1
-1@@ -479,7 +479,7 @@ static void agilent_82350b_return_to_local(struct gpib_board *board)static int agilent_82350b_allocate_private (struct gpib_board *board) { - board->private_data =kzalloc (sizeof (struct agilent_82350b_priv ),GFP_KERNEL ); + board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);if (!board->private_data)return -ENOMEM ;return 0 ;Signature · 1 line
2.43.0
This will not work and the recommendation in this case is also wrong:
kzalloc(sizeof(*board->private_data)...) only allocates space for a void *, not enough to hold the agilent_82350b_priv struct. cheers,
-dave
Greg KH
maintainerQuoted 26 lines · Rujra Bhatt
It has recommended to
Prefer kzalloc(sizeof(*board->private_data)...) overkzalloc(sizeof(struct agilent_82350b_priv)...)Signed-off-by Rujra Bhatt <[email protected]>--- drivers/staging/gpib/agilent_82350b/agilent_82350b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/gpib/agilent_82350b/agilent_82350b.c +1
-1@@ -479,7 +479,7 @@ static void agilent_82350b_return_to_local(struct gpib_board *board)static int agilent_82350b_allocate_private (struct gpib_board *board) { - board->private_data =kzalloc (sizeof (struct agilent_82350b_priv ),GFP_KERNEL ); + board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);if (!board->private_data)return -ENOMEM ;return 0 ;Signature · 1 line
2.43.0
Is there a reason you did not even build your patch before submitting it?
Please take some time to learn the C language first before working on the kernel.
good luck!
greg k-hh
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Rujra,
kernel test robot noticed the following build errors:
[auto build test ERROR on staging/staging-testing]
[also build test ERROR on staging/staging-next staging/staging-linus linus/master v6.15-rc5 next-20250506] [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/Rujra-Bhatt/staging-gpib-agilent_82350b-agilent_82350b-c-fixes-checks-on-the-file/20250416-205032 base: staging/staging-testing patch link: https://lore.kernel.org/r/Z_-nR5Vt2A5kvbro%40brak3rDesk patch subject: [FIRST-PATCH] staging : gpib : agilent_82350b : agilent_82350b.c : fixes checks on the file config: x86_64-randconfig-002-20250424 (https://download.01.org/0day-ci/archive/20250507/[email protected]/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/20250507/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/percpu.h:5,
from include/linux/radix-tree.h:16,
from include/linux/idr.h:15,
from include/linux/kernfs.h:12,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/energy_model.h:7,
from include/linux/device.h:16,
from drivers/staging/gpib/include/gpib_types.h:18,
from drivers/staging/gpib/include/gpibP.h:12,
from drivers/staging/gpib/agilent_82350b/agilent_82350b.h:7,
from drivers/staging/gpib/agilent_82350b/agilent_82350b.c:11:
drivers/staging/gpib/agilent_82350b/agilent_82350b.c: In function 'agilent_82350b_allocate_private':
>> drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:227:16: note: in definition of macro 'alloc_hooks_tag'
227 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
>> drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:231:24: note: in definition of macro 'alloc_hooks_tag'
231 | _res = _do_alloc; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
>> drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:234:24: note: in definition of macro 'alloc_hooks_tag'
234 | _res = _do_alloc; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:29: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^vim +482 drivers/staging/gpib/agilent_82350b/agilent_82350b.c
479
480 static int agilent_82350b_allocate_private(struct gpib_board *board)
481 {
> 482 board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
483 if (!board->private_data)
484 return -ENOMEM;
485 return 0;
486 }
487
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Rujra,
kernel test robot noticed the following build warnings:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on staging/staging-next staging/staging-linus linus/master v6.15-rc5 next-20250507] [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/Rujra-Bhatt/staging-gpib-agilent_82350b-agilent_82350b-c-fixes-checks-on-the-file/20250416-205032 base: staging/staging-testing patch link: https://lore.kernel.org/r/Z_-nR5Vt2A5kvbro%40brak3rDesk patch subject: [FIRST-PATCH] staging : gpib : agilent_82350b : agilent_82350b.c : fixes checks on the file config: x86_64-randconfig-002-20250424 (https://download.01.org/0day-ci/archive/20250507/[email protected]/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/20250507/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/linux/percpu.h:5,
from include/linux/radix-tree.h:16,
from include/linux/idr.h:15,
from include/linux/kernfs.h:12,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/energy_model.h:7,
from include/linux/device.h:16,
from drivers/staging/gpib/include/gpib_types.h:18,
from drivers/staging/gpib/include/gpibP.h:12,
from drivers/staging/gpib/agilent_82350b/agilent_82350b.h:7,
from drivers/staging/gpib/agilent_82350b/agilent_82350b.c:11:
drivers/staging/gpib/agilent_82350b/agilent_82350b.c: In function 'agilent_82350b_allocate_private':
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:227:16: note: in definition of macro 'alloc_hooks_tag'
227 | typeof(_do_alloc) _res; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:231:24: note: in definition of macro 'alloc_hooks_tag'
231 | _res = _do_alloc; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:53: error: expected '{' before '*' token
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^
include/linux/alloc_tag.h:234:24: note: in definition of macro 'alloc_hooks_tag'
234 | _res = _do_alloc; \
| ^~~~~~~~~
include/linux/slab.h:1041:49: note: in expansion of macro 'alloc_hooks'
1041 | #define kzalloc(...) alloc_hooks(kzalloc_noprof(__VA_ARGS__))
| ^~~~~~~~~~~
drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:31: note: in expansion of macro 'kzalloc'
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^~~~~~~
>> drivers/staging/gpib/agilent_82350b/agilent_82350b.c:482:29: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
482 | board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
| ^vim +482 drivers/staging/gpib/agilent_82350b/agilent_82350b.c
479
480 static int agilent_82350b_allocate_private(struct gpib_board *board)
481 {
> 482 board->private_data = kzalloc(sizeof(struct * board->private_data), GFP_KERNEL);
483 if (!board->private_data)
484 return -ENOMEM;
485 return 0;
486 }
487
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki