Skip to content

Commit 3197060

Browse files
committed
overflow: Fix kern-doc markup for functions
Fix the kern-doc markings for several of the overflow helpers and move their location into the core kernel API documentation, where it belongs (it's not driver-specific). Cc: Jonathan Corbet <[email protected]> Cc: [email protected] Cc: [email protected] Reviewed-by: Akira Yokosawa <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 9abf231 commit 3197060

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

Documentation/core-api/kernel-api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ Text Searching
118118
CRC and Math Functions in Linux
119119
===============================
120120

121+
Arithmetic Overflow Checking
122+
----------------------------
123+
124+
.. kernel-doc:: include/linux/overflow.h
125+
:internal:
126+
121127
CRC Functions
122128
-------------
123129

Documentation/driver-api/basics.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ Kernel utility functions
107107
.. kernel-doc:: kernel/panic.c
108108
:export:
109109

110-
.. kernel-doc:: include/linux/overflow.h
111-
:internal:
112-
113110
Device Resource Management
114111
--------------------------
115112

include/linux/overflow.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
5151
return unlikely(overflow);
5252
}
5353

54-
/** check_add_overflow() - Calculate addition with overflow checking
55-
*
54+
/**
55+
* check_add_overflow() - Calculate addition with overflow checking
5656
* @a: first addend
5757
* @b: second addend
5858
* @d: pointer to store sum
@@ -66,8 +66,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
6666
#define check_add_overflow(a, b, d) \
6767
__must_check_overflow(__builtin_add_overflow(a, b, d))
6868

69-
/** check_sub_overflow() - Calculate subtraction with overflow checking
70-
*
69+
/**
70+
* check_sub_overflow() - Calculate subtraction with overflow checking
7171
* @a: minuend; value to subtract from
7272
* @b: subtrahend; value to subtract from @a
7373
* @d: pointer to store difference
@@ -81,8 +81,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
8181
#define check_sub_overflow(a, b, d) \
8282
__must_check_overflow(__builtin_sub_overflow(a, b, d))
8383

84-
/** check_mul_overflow() - Calculate multiplication with overflow checking
85-
*
84+
/**
85+
* check_mul_overflow() - Calculate multiplication with overflow checking
8686
* @a: first factor
8787
* @b: second factor
8888
* @d: pointer to store product
@@ -96,23 +96,24 @@ static inline bool __must_check __must_check_overflow(bool overflow)
9696
#define check_mul_overflow(a, b, d) \
9797
__must_check_overflow(__builtin_mul_overflow(a, b, d))
9898

99-
/** check_shl_overflow() - Calculate a left-shifted value and check overflow
100-
*
99+
/**
100+
* check_shl_overflow() - Calculate a left-shifted value and check overflow
101101
* @a: Value to be shifted
102102
* @s: How many bits left to shift
103103
* @d: Pointer to where to store the result
104104
*
105105
* Computes *@d = (@a << @s)
106106
*
107-
* Returns true if '*d' cannot hold the result or when 'a << s' doesn't
107+
* Returns true if '*@d' cannot hold the result or when '@a << @s' doesn't
108108
* make sense. Example conditions:
109-
* - 'a << s' causes bits to be lost when stored in *d.
110-
* - 's' is garbage (e.g. negative) or so large that the result of
111-
* 'a << s' is guaranteed to be 0.
112-
* - 'a' is negative.
113-
* - 'a << s' sets the sign bit, if any, in '*d'.
114109
*
115-
* '*d' will hold the results of the attempted shift, but is not
110+
* - '@a << @s' causes bits to be lost when stored in *@d.
111+
* - '@s' is garbage (e.g. negative) or so large that the result of
112+
* '@a << @s' is guaranteed to be 0.
113+
* - '@a' is negative.
114+
* - '@a << @s' sets the sign bit, if any, in '*@d'.
115+
*
116+
* '*@d' will hold the results of the attempted shift, but is not
116117
* considered "safe for use" if true is returned.
117118
*/
118119
#define check_shl_overflow(a, s, d) __must_check_overflow(({ \
@@ -129,7 +130,6 @@ static inline bool __must_check __must_check_overflow(bool overflow)
129130

130131
/**
131132
* size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX
132-
*
133133
* @factor1: first factor
134134
* @factor2: second factor
135135
*
@@ -149,7 +149,6 @@ static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
149149

150150
/**
151151
* size_add() - Calculate size_t addition with saturation at SIZE_MAX
152-
*
153152
* @addend1: first addend
154153
* @addend2: second addend
155154
*
@@ -169,7 +168,6 @@ static inline size_t __must_check size_add(size_t addend1, size_t addend2)
169168

170169
/**
171170
* size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX
172-
*
173171
* @minuend: value to subtract from
174172
* @subtrahend: value to subtract from @minuend
175173
*
@@ -192,7 +190,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
192190

193191
/**
194192
* array_size() - Calculate size of 2-dimensional array.
195-
*
196193
* @a: dimension one
197194
* @b: dimension two
198195
*
@@ -205,7 +202,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
205202

206203
/**
207204
* array3_size() - Calculate size of 3-dimensional array.
208-
*
209205
* @a: dimension one
210206
* @b: dimension two
211207
* @c: dimension three
@@ -220,7 +216,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
220216
/**
221217
* flex_array_size() - Calculate size of a flexible array member
222218
* within an enclosing structure.
223-
*
224219
* @p: Pointer to the structure.
225220
* @member: Name of the flexible array member.
226221
* @count: Number of elements in the array.
@@ -237,7 +232,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
237232

238233
/**
239234
* struct_size() - Calculate size of structure with trailing flexible array.
240-
*
241235
* @p: Pointer to the structure.
242236
* @member: Name of the array member.
243237
* @count: Number of elements in the array.

0 commit comments

Comments
 (0)