Message ID | b169a04caaee43c7b917a7e48470da6a@AcuMS.aculab.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | minmax: reduce compilation time | expand |
Le 28/07/2024 à 16:18, David Laight a écrit : > The static_assert() wrapper provides the text of the expression as the > error message, this isn't needed here as an explicit message is provided. > If there is an error (quite likely for min/max) the wrapper also adds > two more lines of error output that just make it harder to read. > > Since it gives no benefit and actually makes things worse directly > using _Static_assert() is much better. > > Signed-off-by: David Laight <david.laight@aculab.com> > --- > v2: > - No change. > > include/linux/minmax.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/include/linux/minmax.h b/include/linux/minmax.h > index cea63a8ac80f..ab64b2e73ae5 100644 > --- a/include/linux/minmax.h > +++ b/include/linux/minmax.h > @@ -48,7 +48,7 @@ > #define __cmp_once(op, x, y, unique_x, unique_y) ({ \ > typeof(x) unique_x = (x); \ > typeof(y) unique_y = (y); \ > - static_assert(__types_ok(x, y), \ > + _Static_assert(__types_ok(x, y), \ Nitpick, should there be a v3: a tab can be removed to keep things aligned. > #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ > __cmp(op, unique_x, unique_y); }) CJ
From: Christophe JAILLET > Sent: 28 July 2024 18:52 > > Le 28/07/2024 à 16:18, David Laight a écrit : > > The static_assert() wrapper provides the text of the expression as the > > error message, this isn't needed here as an explicit message is provided. > > If there is an error (quite likely for min/max) the wrapper also adds > > two more lines of error output that just make it harder to read. > > > > Since it gives no benefit and actually makes things worse directly > > using _Static_assert() is much better. > > > > Signed-off-by: David Laight <david.laight@aculab.com> > > --- > > v2: > > - No change. > > > > include/linux/minmax.h | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/minmax.h b/include/linux/minmax.h > > index cea63a8ac80f..ab64b2e73ae5 100644 > > --- a/include/linux/minmax.h > > +++ b/include/linux/minmax.h > > @@ -48,7 +48,7 @@ > > #define __cmp_once(op, x, y, unique_x, unique_y) ({ \ > > typeof(x) unique_x = (x); \ > > typeof(y) unique_y = (y); \ > > - static_assert(__types_ok(x, y), \ > > + _Static_assert(__types_ok(x, y), \ > > Nitpick, should there be a v3: a tab can be removed to keep things aligned. I think that is picked up by a later patch to the same lines. This final file looks ok. David > > > #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op > "_t()"); \ > > __cmp(op, unique_x, unique_y); }) > > CJ - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index cea63a8ac80f..ab64b2e73ae5 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -48,7 +48,7 @@ #define __cmp_once(op, x, y, unique_x, unique_y) ({ \ typeof(x) unique_x = (x); \ typeof(y) unique_y = (y); \ - static_assert(__types_ok(x, y), \ + _Static_assert(__types_ok(x, y), \ #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ __cmp(op, unique_x, unique_y); }) @@ -137,11 +137,11 @@ typeof(val) unique_val = (val); \ typeof(lo) unique_lo = (lo); \ typeof(hi) unique_hi = (hi); \ - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ + _Static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ (lo) <= (hi), true), \ "clamp() low limit " #lo " greater than high limit " #hi); \ - static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ - static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ + _Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ + _Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ __clamp(unique_val, unique_lo, unique_hi); }) #define __careful_clamp(val, lo, hi) ({ \
The static_assert() wrapper provides the text of the expression as the error message, this isn't needed here as an explicit message is provided. If there is an error (quite likely for min/max) the wrapper also adds two more lines of error output that just make it harder to read. Since it gives no benefit and actually makes things worse directly using _Static_assert() is much better. Signed-off-by: David Laight <david.laight@aculab.com> --- v2: - No change. include/linux/minmax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)