girepository: Fix -Wsign-conversion warnings in macOS library code

The members of `struct segment_command` appear to have type `uint32_t`,
so definitely need casting to the machine’s integer pointer type before
doing pointer arithmetic on them.

See https://developer.apple.com/documentation/kernel/segment_command

Tested only on macOS CI as I don’t have access to a macOS machine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall
2025-04-23 00:28:49 +01:00
parent c76b9bc72e
commit d1e28aed1a

View File

@@ -198,13 +198,13 @@ gi_repository_get_library_path_macos (void)
if (cmd->cmd == LC_SEGMENT)
{
struct segment_command *seg = (struct segment_command *) cmd;
if (((intptr_t) ptr >= (seg->vmaddr + offset)) && ((intptr_t) ptr < (seg->vmaddr + offset + seg->vmsize)))
if (((intptr_t) ptr >= ((intptr_t) seg->vmaddr + offset)) && ((intptr_t) ptr < ((intptr_t) seg->vmaddr + offset + (intptr_t) seg->vmsize)))
return _dyld_get_image_name (i);
}
if (cmd->cmd == LC_SEGMENT_64)
{
struct segment_command_64 *seg = (struct segment_command_64 *) cmd;
if (((uintptr_t ) ptr >= (seg->vmaddr + offset)) && ((uintptr_t ) ptr < (seg->vmaddr + offset + seg->vmsize)))
if (((intptr_t) ptr >= ((intptr_t) seg->vmaddr + offset)) && ((intptr_t) ptr < ((intptr_t) seg->vmaddr + offset + (intptr_t) seg->vmsize)))
return _dyld_get_image_name (i);
}
/* Jump to the next command */