linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] div64.h: Fix description of do_div parameter
@ 2019-02-25 14:03 Jonathan Neuschäfer
  2019-02-25 15:19 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Neuschäfer @ 2019-02-25 14:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jonathan Neuschäfer, Arnd Bergmann, linux-arch

Contrary to the description, the first parameter (n) should not be
passed as a pointer, but directly as an lvalue. This is possible because
do_div is a macro.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 include/asm-generic/div64.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index dc9726fdac8f..b2a9c74efa55 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -28,12 +28,12 @@
 
 /**
  * do_div - returns 2 values: calculate remainder and update new dividend
- * @n: pointer to uint64_t dividend (will be updated)
+ * @n: uint64_t dividend (will be updated)
  * @base: uint32_t divisor
  *
  * Summary:
- * ``uint32_t remainder = *n % base;``
- * ``*n = *n / base;``
+ * ``uint32_t remainder = n % base;``
+ * ``n = n / base;``
  *
  * Return: (uint32_t)remainder
  *
-- 
2.20.1


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

* Re: [PATCH] div64.h: Fix description of do_div parameter
  2019-02-25 14:03 [PATCH] div64.h: Fix description of do_div parameter Jonathan Neuschäfer
@ 2019-02-25 15:19 ` Geert Uytterhoeven
  2019-02-25 15:51   ` Jonathan Neuschäfer
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2019-02-25 15:19 UTC (permalink / raw)
  To: Jonathan Neuschäfer
  Cc: Linux Kernel Mailing List, Arnd Bergmann, Linux-Arch

Hi Jonathan,

On Mon, Feb 25, 2019 at 3:05 PM Jonathan Neuschäfer
<j.neuschaefer@gmx.net> wrote:
> Contrary to the description, the first parameter (n) should not be
> passed as a pointer, but directly as an lvalue. This is possible because
> do_div is a macro.
>
> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Shouldn't the "semantics" at the top of include/asm-generic/div64.h be
updated, too?

As this can't be expressed in a C function, perhaps that should be done
using C++ syntax, like

    uint32_t do_div(uint64_t &n, uint32_t base)
    {
        ...
    }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] div64.h: Fix description of do_div parameter
  2019-02-25 15:19 ` Geert Uytterhoeven
@ 2019-02-25 15:51   ` Jonathan Neuschäfer
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Neuschäfer @ 2019-02-25 15:51 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Jonathan Neuschäfer, Linux Kernel Mailing List,
	Arnd Bergmann, Linux-Arch

[-- Attachment #1: Type: text/plain, Size: 1044 bytes --]

On Mon, Feb 25, 2019 at 04:19:02PM +0100, Geert Uytterhoeven wrote:
> Hi Jonathan,
> 
> On Mon, Feb 25, 2019 at 3:05 PM Jonathan Neuschäfer
> <j.neuschaefer@gmx.net> wrote:
> > Contrary to the description, the first parameter (n) should not be
> > passed as a pointer, but directly as an lvalue. This is possible because
> > do_div is a macro.
> >
> > Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> 
> Thanks for your patch!
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Shouldn't the "semantics" at the top of include/asm-generic/div64.h be
> updated, too?

Arguably, it's semantically close enough. I'm not sure.

> As this can't be expressed in a C function, perhaps that should be done
> using C++ syntax, like
> 
>     uint32_t do_div(uint64_t &n, uint32_t base)
>     {
>         ...
>     }

That might confuse some people who aren't expecting C++ syntax.
I'll leave this as is, because I can't decide wether this is an
improvement.


Thanks,
Jonathan Neuschäfer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-02-25 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 14:03 [PATCH] div64.h: Fix description of do_div parameter Jonathan Neuschäfer
2019-02-25 15:19 ` Geert Uytterhoeven
2019-02-25 15:51   ` Jonathan Neuschäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).