Skip to content

Commit f287583

Browse files
maciej-w-rozyckitsbogend
authored andcommitted
div64: Correct inline documentation for `do_div'
Correct inline documentation for `do_div', which is a function-like macro the `n' parameter of which has the semantics of a C++ reference: it is both read and written in the context of the caller without an explicit dereference such as with a pointer. In the C programming language it has no equivalent for proper functions, in terms of which the documentation expresses the semantics of `do_div', but substituting a pointer in documentation is misleading, and using the C++ notation should at least raise the reader's attention and encourage to seek explanation even if the C++ semantics is not readily understood. While at it observe that "semantics" is an uncountable noun, so refer to it with a singular rather than plural verb. Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent 5086ea4 commit f287583

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

include/asm-generic/div64.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
* Optimization for constant divisors on 32-bit machines:
99
* Copyright (C) 2006-2015 Nicolas Pitre
1010
*
11-
* The semantics of do_div() are:
11+
* The semantics of do_div() is, in C++ notation, observing that the name
12+
* is a function-like macro and the n parameter has the semantics of a C++
13+
* reference:
1214
*
13-
* uint32_t do_div(uint64_t *n, uint32_t base)
15+
* uint32_t do_div(uint64_t &n, uint32_t base)
1416
* {
15-
* uint32_t remainder = *n % base;
16-
* *n = *n / base;
17+
* uint32_t remainder = n % base;
18+
* n = n / base;
1719
* return remainder;
1820
* }
1921
*

0 commit comments

Comments
 (0)