lkml.org 
[lkml]   [2024]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec()
On Wed, Feb 7, 2024 at 5:24 PM Kees Cook <keescook@chromium.org> wrote:
>
> This allows replacements of the idioms "var += offset" and "var -= offset"
> with the wrapping_inc() and wrapping_dec() helpers respectively. They
> will avoid wrap-around sanitizer instrumentation.
>
> Add to the selftests to validate behavior and lack of side-effects.

I would expect inc/dec to add/subtract 1. So, to me the terminology is
confusing. The list of the C/C++ operators on Wikipedia describes
above as

+= Assignment by sum
-= Assignment by difference


Hence the proposal is to have

wrapping_sum()
wrapping_diff()

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2024-05-27 14:53    [W:0.070 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site