lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 31 Jul 2023 13:26:54 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     "'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>,
        "'Andy Shevchenko'" <andriy.shevchenko@...ux.intel.com>,
        'Andrew Morton' <akpm@...ux-foundation.org>,
        "'Matthew Wilcox (Oracle)'" <willy@...radead.org>,
        'Christoph Hellwig' <hch@...radead.org>,
        "'Jason A. Donenfeld'" <Jason@...c4.com>
CC:     'Nathan Chancellor' <nathan@...nel.org>,
        "llvm@...ts.linux.dev" <llvm@...ts.linux.dev>
Subject: RE: [PATCH next v2 5/5] minmax: Relax check to allow comparison
 between int and small unsigned constants.

By the time I've done:

#define __is_noneg_int(x)					\
	__builtin_choose_expr(!__is_constexpr(x), false, 	\
		((x) >= (typeof(x))0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))

#define __is_signed(x)                                                         \
       __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))),        \
               is_signed_type(typeof(x)), 0)

#define __types_ok(x, y) 					\
	(__is_signed(x) == __is_signed(y) ||			\
		__is_signed((x) + 0) == __is_signed((y) + 0) ||	\
		__is_noneg_int(x) || __is_noneg_int(y))

the error message for

>  	static_assert(__types_ok(x, y),			\
>  		#op "(" #x ", " #y ") signedness error, fix types or consider " #op "_unsigned() before " #op "_t()"); \

generated by clang 8.0.0 and later is similar to (see https://godbolt.org/z/jq613Gnsa):

<source>:49:12: error: static assertion failed due to requirement '__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0) == __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0) || __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0) == __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0) || (__builtin_choose_expr(!(sizeof(int) == sizeof (*(8 ? ((void *)((long)(a) * 0L)) : (int *)8))), 0, __builtin_choose_expr(__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0), a, 0) >= 0 && (a) <= (int)(long)2147483647)) || (__builtin_choose_expr(!(sizeof(int) == sizeof (*(8 ? ((void *)((long)(2147483648U - 0) * 0L)) : (int *)8))), 0, __builtin_choose_expr(__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0), 2147483648U - 0, 0) >= 0 && (2147483648U - 0) <= (unsigned int)(long)2147483647))': min(a, 0x80000000u - 0) signedness error, fix types or consider min_unsigned() before min_t()

Repeating the expression seems somewhat sub-optimal!
Surely it shouldn't be outputting the expansion of the
input when an error message is supplied?

Is there any (sane) way to stop it being that verbose?

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ