1
0
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:
Siddhesh Poyarekar
2021-03-16 18:31:02 +05:30
parent bf6b6243c9
commit d1a3dcabf2
3 changed files with 49 additions and 11 deletions

View File

@ -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