[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9bd050f6-eba1-a15c-3d42-948975be484b@petrovitsch.priv.at>
Date: Tue, 4 Sep 2018 00:54:40 +0200
From: Bernd Petrovitsch <bernd@...rovitsch.priv.at>
To: Joe Perches <joe@...ches.com>, Jonathan Corbet <corbet@....net>,
Heinrich Schuchardt <xypron.glpk@....de>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] docs: kernel-doc: fix parsing of function pointers
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@....de> 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@...rovitsch.priv.at
LUGA : http://www.luga.at
Download attachment "pEpkey.asc" of type "application/pgp-keys" (1779 bytes)
Powered by blists - more mailing lists