1
0
mirror of https://git.tukaani.org/xz.git synced 2025-11-14 04:04:33 +00:00

xz: Silence a warning from Clang on glibc systems

Fixes: e8838b2f5922 ("xz: Look at resource limits when determining the default memlimit")
This commit is contained in:
Lasse Collin 2025-11-02 17:45:20 +02:00
parent 3e394278ed
commit beca015891
No known key found for this signature in database
GPG Key ID: 38EE757D69184620

View File

@ -351,6 +351,16 @@ hardware_init(void)
const rlim_t margin = 64 << 20; const rlim_t margin = 64 << 20;
for (size_t i = 0; i < ARRAY_SIZE(resources); ++i) { for (size_t i = 0; i < ARRAY_SIZE(resources); ++i) {
// glibc: When GNU extensions are enabled, <sys/resource.h>
// declares getrlimit() so that the first argument is an enum
// instead of int as in POSIX. GCC and Clang use unsigned int
// for enums when possible, so a sign conversion occurs when
// resources[i] is convert to the enum type. Clang warns about
// this with -Wsign-conversion but GCC doesn't.
#ifdef __clang__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
// RLIM_SAVED_* might be used on some 32-bit OSes // RLIM_SAVED_* might be used on some 32-bit OSes
// (AIX at least) when the limit doesn't fit in a 32-bit // (AIX at least) when the limit doesn't fit in a 32-bit
// unsigned integer. Thus, for us these are the same thing // unsigned integer. Thus, for us these are the same thing
@ -360,6 +370,9 @@ hardware_init(void)
&& rl.rlim_cur != RLIM_INFINITY && rl.rlim_cur != RLIM_INFINITY
&& rl.rlim_cur != RLIM_SAVED_CUR && rl.rlim_cur != RLIM_SAVED_CUR
&& rl.rlim_cur != RLIM_SAVED_MAX) { && rl.rlim_cur != RLIM_SAVED_MAX) {
#ifdef __clang__
# pragma GCC diagnostic pop
#endif
// Subtract the margin from the current resource // Subtract the margin from the current resource
// limit, but avoid negative results. Avoid also 0 // limit, but avoid negative results. Avoid also 0
// because hardware_memlimit_show() (--info-memory) // because hardware_memlimit_show() (--info-memory)