Skip to contentSkip to conversation

div64.h: Fix description of do_div parameter

PATCH Superseded Jonathan Neuschäfer 2 participants 3 messages Feb 25, 2019 Generic include/asm header files

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 div64.h: Fix description of do_div parameter

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.

---
 include/asm-generic/div64.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/asm-generic/div64.h +3 -3
index dc9726fdac8f..b2a9c74efa55 100644
@@ -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
  *
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Jonathan,

Quoted 5 lines · Jonathan Neuschäfer

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.

Thanks for your patch!

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

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
#2 lore raw
Quoted 8 lines · Geert Uytterhoeven

Hi Jonathan,

Quoted 4 lines · Jonathan Neuschäfer

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.

Quoted 8 lines
Quoted 1 line

Thanks for your patch!

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.

Quoted 7 lines

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