mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
tunables: Fix comparison of tunable values
The simplification of tunable_set interfaces took care of signed/unsigned conversions while setting values, but comparison with bounds ended up being incorrect; comparing TUNABLE_SIZE_T values for example will fail because SIZE_MAX is seen as -1. Add comparison helpers that take tunable types into account and use them to do comparison instead.
This commit is contained in:
@ -81,4 +81,21 @@ struct _tunable
|
||||
|
||||
typedef struct _tunable tunable_t;
|
||||
|
||||
static __always_inline bool
|
||||
unsigned_tunable_type (tunable_type_code_t t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case TUNABLE_TYPE_INT_32:
|
||||
return false;
|
||||
case TUNABLE_TYPE_UINT_64:
|
||||
case TUNABLE_TYPE_SIZE_T:
|
||||
return true;
|
||||
case TUNABLE_TYPE_STRING:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
__builtin_unreachable ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user