From 0d157ff16828b2f9534a776af602bdab771e7e13 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 17 Oct 2026 15:36:39 -0700 Subject: [PATCH] tcmu-runner: Fix build on 32-bit targets with clang tcmu_lba_to_byte() returns uint64_t while size_t is 32-bit on ILP32 targets, so the type-checking min() macro fails with -Werror,-Wcompare-distinct-pointer-types. Compare in 64 bits; the result never exceeds length, so it still fits in size_t. Build-tested for qemuriscv32 (musl, clang). Signed-off-by: Khem Raj --- ...dler-fix-min-type-mismatch-on-32-bit.patch | 34 +++++++++++++++++++ .../tcmu-runner/tcmu-runner_1.6.2.bb | 1 + 2 files changed, 35 insertions(+) create mode 100644 meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner/0004-tcmur_cmd_handler-fix-min-type-mismatch-on-32-bit.patch diff --git a/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner/0004-tcmur_cmd_handler-fix-min-type-mismatch-on-32-bit.patch b/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner/0004-tcmur_cmd_handler-fix-min-type-mismatch-on-32-bit.patch new file mode 100644 index 0000000000..3feb06d77c --- /dev/null +++ b/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner/0004-tcmur_cmd_handler-fix-min-type-mismatch-on-32-bit.patch @@ -0,0 +1,34 @@ +From: Khem Raj +Date: Sat, 17 Oct 2026 00:00:00 -0700 +Subject: [PATCH] tcmur_cmd_handler: Fix min() type mismatch on 32-bit targets + +tcmu_lba_to_byte() returns uint64_t while length is size_t, which is +32-bit on ILP32 targets. The type-checking min() macro then compares +pointers to distinct types and clang errors out with + + error: comparison of distinct pointer types ('typeof (length) *' + (aka 'unsigned int *') and 'typeof (tcmu_lba_to_byte(dev, lba_cnt)) *' + (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types] + +Do the comparison in 64 bits; the result never exceeds length, so it +still fits in size_t. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + tcmur_cmd_handler.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tcmur_cmd_handler.c b/tcmur_cmd_handler.c +index 01d6a10..c676e84 100644 +--- a/tcmur_cmd_handler.c ++++ b/tcmur_cmd_handler.c +@@ -768,7 +768,7 @@ static int handle_writesame(struct tcmu_device *dev, struct tcmulib_cmd *cmd) + + max_xfer_length = tcmu_dev_get_max_xfer_len(dev) * block_size; + length = round_up(length, max_xfer_length); +- length = min(length, tcmu_lba_to_byte(dev, lba_cnt)); ++ length = min((uint64_t)length, tcmu_lba_to_byte(dev, lba_cnt)); + + if (tcmur_cmd_state_init(tcmur_cmd, sizeof(*write_same), length)) { + tcmu_dev_err(dev, "Failed to calloc write_same data!\n"); diff --git a/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner_1.6.2.bb b/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner_1.6.2.bb index 3a61b92630..0256a433cb 100644 --- a/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner_1.6.2.bb +++ b/meta-filesystems/recipes-utils/tcmu-runner/tcmu-runner_1.6.2.bb @@ -11,6 +11,7 @@ SRC_URI = "git://github.com/open-iscsi/tcmu-runner.git;protocol=https;branch=mai file://0001-CMakeLists-generate-gdbus-code-with-a-relative-path.patch \ file://0002-qcow-fix-cache-count-reset-loops.patch \ file://0003-target-alua-initialize-list_for_each-iterator-variables.patch \ + file://0004-tcmur_cmd_handler-fix-min-type-mismatch-on-32-bit.patch \ " inherit cmake pkgconfig systemd