On 04/09/18 00:28, Joe Perches wrote: > On Mon, 2018-09-03 at 15:38 -0600, Jonathan Corbet wrote: >> On Mon, 3 Sep 2018 22:29:00 +0200 >> Heinrich Schuchardt <xypron.glpk@xxxxxx> wrote: >> >>>>> # pointer-to-function >>>>> $arg =~ tr/#/,/; >>>>> - $arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/; >>> >>> m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/; >>> ^ >>> Here we allow for 0..1 asterixes. What's with pointers to function pointers and/or function pointer arrays? ;-) >>> If there is no asterix it is not a function pointer. Why should we care >>> for this case? >> >> GCC seems to allow that asterisk (asterix is an indomitable Gaul :) to be *g* >> missing; not sure if that's officially allowed by the language or not. I >> also don't know if any code in the kernel elides it, > > Many typedefs for function pointers do not use the * > Dunno if there are many others, I didn't look hard. ---- snip ---- typedef void (*foo)(int); ---- snip ---- is a function pointer type (and nothing else;-) and can be used to declare and/or define a pointer to a function as in ---- snip ---- foo ptr_to_func_with_int_param_and_no_result; ---- snip ---- ---- snip ---- typedef void bar(int); ---- snip ---- is a function type and can be used for function prototypes as in ---- snip ---- bar func_with_int_param_and_no_result; ---- snip ---- and/or function pointers as in ---- snip ---- bar *also_ptr_to_func_with_int_param_and_no_result; ---- snip ---- Both of work (in functions) as ---- snip ---- ptr_to_func_with_int_param_and_no_result = &func_with_int_param_and_no_result; ptr_to_func_with_int_param_and_no_result = func_with_int_param_and_no_result; also_ptr_to_func_with_int_param_and_no_result = &func_with_int_param_and_no_result; also_ptr_to_func_with_int_param_and_no_result = func_with_int_param_and_no_result; ---- snip ---- Note the missing "()" in both cases (otherwise it would be a function call - possibly returning the function pointers). I don't know if there is a preferred style in the kernel though. MfG, Bernd -- Bernd Petrovitsch Email : bernd@xxxxxxxxxxxxxxxxxxx LUGA : http://www.luga.at
Attachment:
pEpkey.asc
Description: application/pgp-keys