From: Yu Watanabe Date: Mon, 15 Jun 2026 04:03:00 +0000 (+0900) Subject: musl: fix build on 32-bit architecture X-Git-Tag: v261-rc4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da2ed93b654e2a6e4d921547ffc72245c69c2edb;p=thirdparty%2Fsystemd.git musl: fix build on 32-bit architecture ``` ../src/boot/test-efi-string.c: In function 'test_xvasprintf_status': ../src/boot/test-efi-string.c:744:34: error: format '%zi' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Werror=format=] 744 | test_printf_one("%i %i %zi", INT_MIN, INT_MAX, SSIZE_MAX); | ~~^ | | | int | %li cc1: some warnings being treated as errors ninja: subcommand failed ``` --- diff --git a/src/include/musl/limits.h b/src/include/musl/limits.h new file mode 100644 index 00000000000..9620a3b0acc --- /dev/null +++ b/src/include/musl/limits.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include_next /* IWYU pragma: export */ + +#include +#include + +/* musl defines SSIZE_MAX as LONG_MAX, so its type is always long. However, on 32-bit architectures, musl + * defines ssize_t as int. Strictly speaking, this is not a bug in musl. POSIX only requires SSIZE_MAX to + * evaluate to the maximum value representable by ssize_t; it does not require SSIZE_MAX itself to have type + * ssize_t. However, our code assumes that SSIZE_MAX has type ssize_t, as is the case with glibc. Cast the + * value explicitly so that SSIZE_MAX has type ssize_t. */ +static_assert(SSIZE_MAX == LONG_MAX, ""); +#undef SSIZE_MAX +#define SSIZE_MAX ((ssize_t) LONG_MAX)