History

overflow.h: Add comment documenting __ab_c_size()

__ab_c_size() is a somewhat opaque name. Document its purpose, and while at it, rename the parameters to actually match the abc naming. [ bp: glued a complete patch from chunks on LKML. ]

Rasmus Villemoes committed 7 years ago

Commit e0478541 parent 79a3aaa1 file · +6 −2Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/overflow.h+6−2
@@ -278,11 +278,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c) · 277 unmodified lines
278278 return bytes;
279279 }
280280
281−static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c)
281+/*
282+ * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
283+ * struct_size() below.
284+ */
285+static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
282286 {
283287 size_t bytes;
284288
285− if (check_mul_overflow(n, size, &bytes))
289+ if (check_mul_overflow(a, b, &bytes))
286290 return SIZE_MAX;
287291 if (check_add_overflow(bytes, c, &bytes))
288292 return SIZE_MAX;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t