All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/kernel-doc: Add missing close-paren in c:function directives
@ 2020-04-14 14:37 Peter Maydell
  2020-04-15 21:11 ` Jonathan Corbet
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2020-04-14 14:37 UTC (permalink / raw)
  To: linux-doc; +Cc: linux-kernel, Jonathan Corbet, Paolo Bonzini

When kernel-doc generates a 'c:function' directive for a function
one of whose arguments is a function pointer, it fails to print
the close-paren after the argument list of the function pointer
argument. For instance:

 long work_on_cpu(int cpu, long (*fn) (void *, void * arg)

in driver-api/basics.html is missing a ')' separating the
"void *" of the 'fn' arguments from the ", void * arg" which
is an argument to work_on_cpu().

Add the missing close-paren, so that we render the prototype
correctly:

 long work_on_cpu(int cpu, long (*fn)(void *), void * arg)

(Note that Sphinx stops rendering a space between the '(fn*)' and the
'(void *)' once it gets something that's syntactically valid.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I noticed this first in the copy of kernel-doc that QEMU is using for
its Sphinx documentation.  Older versions of Sphinx don't try to
parse the argument to c:function, so the only effect is incorrect
output, but Sphinx 3.0 does do this and will complain:
  Invalid C declaration: Expecting "," or ")" in parameters, got "EOF".

It looks like the kernel docs currently won't build at all
with Sphinx 3.0; https://github.com/sphinx-doc/sphinx/issues/7421
so I don't have an example of the error for the kernel docs.

QEMU is currently carrying another patch to our kernel-doc:
 https://patchew.org/QEMU/20200411182934.28678-1-peter.maydell@linaro.org/20200411182934.28678-4-peter.maydell@linaro.org/
which makes it use the new-in-3.0 "c:struct::" directive now
that "c:type::" no longer accepts "struct foo". Does anybody
have a plan for how the kernel kernel-doc is going to deal with
that non-back-compatible Sphinx change?
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index f2d73f04e71d..f746ca8fa403 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -853,7 +853,7 @@ sub output_function_rst(%) {
 
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
-	    print $1 . $parameter . ") (" . $2;
+	    print $1 . $parameter . ") (" . $2 . ")";
 	} else {
 	    print $type . " " . $parameter;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts/kernel-doc: Add missing close-paren in c:function directives
  2020-04-14 14:37 [PATCH] scripts/kernel-doc: Add missing close-paren in c:function directives Peter Maydell
@ 2020-04-15 21:11 ` Jonathan Corbet
  2020-04-16  8:55   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Corbet @ 2020-04-15 21:11 UTC (permalink / raw)
  To: Peter Maydell; +Cc: linux-doc, linux-kernel, Paolo Bonzini

On Tue, 14 Apr 2020 15:37:43 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:

> When kernel-doc generates a 'c:function' directive for a function
> one of whose arguments is a function pointer, it fails to print
> the close-paren after the argument list of the function pointer
> argument. For instance:
> 
>  long work_on_cpu(int cpu, long (*fn) (void *, void * arg)
> 
> in driver-api/basics.html is missing a ')' separating the
> "void *" of the 'fn' arguments from the ", void * arg" which
> is an argument to work_on_cpu().
> 
> Add the missing close-paren, so that we render the prototype
> correctly:
> 
>  long work_on_cpu(int cpu, long (*fn)(void *), void * arg)
> 
> (Note that Sphinx stops rendering a space between the '(fn*)' and the
> '(void *)' once it gets something that's syntactically valid.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Interesting.  This appears to have affected well over 100 function
definitions in the docs, and nobody ever noticed.  Good to know we're all
reading it closely :)

Applied, thanks.

> I noticed this first in the copy of kernel-doc that QEMU is using for
> its Sphinx documentation.  Older versions of Sphinx don't try to
> parse the argument to c:function, so the only effect is incorrect
> output, but Sphinx 3.0 does do this and will complain:
>   Invalid C declaration: Expecting "," or ")" in parameters, got "EOF".
> 
> It looks like the kernel docs currently won't build at all
> with Sphinx 3.0; https://github.com/sphinx-doc/sphinx/issues/7421
> so I don't have an example of the error for the kernel docs.
> 
> QEMU is currently carrying another patch to our kernel-doc:
>  https://patchew.org/QEMU/20200411182934.28678-1-peter.maydell@linaro.org/20200411182934.28678-4-peter.maydell@linaro.org/
> which makes it use the new-in-3.0 "c:struct::" directive now
> that "c:type::" no longer accepts "struct foo". Does anybody
> have a plan for how the kernel kernel-doc is going to deal with
> that non-back-compatible Sphinx change?

Thinking about 3.0 is on my list, but I've not gotten there yet.  I really
wish they wouldn't break things like that...

Thanks,

jon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts/kernel-doc: Add missing close-paren in c:function directives
  2020-04-15 21:11 ` Jonathan Corbet
@ 2020-04-16  8:55   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-04-16  8:55 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: open list:DOCUMENTATION, lkml - Kernel Mailing List, Paolo Bonzini

On Wed, 15 Apr 2020 at 22:11, Jonathan Corbet <corbet@lwn.net> wrote:
>
> On Tue, 14 Apr 2020 15:37:43 +0100
> Peter Maydell <peter.maydell@linaro.org> wrote:
> > When kernel-doc generates a 'c:function' directive for a function
> > one of whose arguments is a function pointer, it fails to print
> > the close-paren after the argument list of the function pointer
> > argument. For instance:
> >
> >  long work_on_cpu(int cpu, long (*fn) (void *, void * arg)

> Interesting.  This appears to have affected well over 100 function
> definitions in the docs, and nobody ever noticed.  Good to know we're all
> reading it closely :)

Heh; I think my conclusion is "function signatures for APIs which
don't provide and use a typedef for function-pointer-arguments are
sufficiently hard to read that people don't notice simple errors
in them", but then I prefer the with-typedef style to start with :-)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-16  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 14:37 [PATCH] scripts/kernel-doc: Add missing close-paren in c:function directives Peter Maydell
2020-04-15 21:11 ` Jonathan Corbet
2020-04-16  8:55   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.