Fix cast from pointer to integer in armv7

A pointer may not fit in a off_t type, so we first cast it to intptr_t
which must be able to hold it, then compute the diff which should fit in
a off_t and perform the cast.

Reported-by: Miquel Vidal Piñol <miquel.vidal@bsc.es>
This commit is contained in:
Rodrigo Arias 2025-03-18 12:33:13 +01:00
parent 9826879bcd
commit c3248cf0c4

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
/* Copyright (c) 2021-2025 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
/* This program is a really bad idea. It attempts to sort streams by using a
@ -268,7 +268,7 @@ static void
write_stream(int fd, void *base, void *dst, const void *src, size_t size)
{
while (size > 0) {
off_t offset = (off_t) dst - (off_t) base;
off_t offset = (off_t) ((intptr_t) dst - (intptr_t) base);
ssize_t written = pwrite(fd, src, size, offset);
if (written < 0)