We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
umem 1.0.1 does not build with Apple clang 16 from Xcode 16 on macOS 15. The error is:
vmem_sbrk.c:137:14: error: incompatible pointer to integer conversion assigning to 'int' from 'void *' [-Wint-conversion] 137 | brk_result = brk((void *)new_brk); | ^ ~~~~~~~~~~~~~~~~~~~~
This was reported to MacPorts here: https://trac.macports.org/ticket/71087
You define brk_result as an int:
brk_result
int
portableumem/vmem_sbrk.c
Line 112 in 3fc772c
and assign the return value of brk to it:
brk
Line 141 in 3fc772c
But brk is documented to return a void *, not an int.
void *
You then compare the result to 0:
0
Lines 144 to 145 in 3fc772c
But the manpage for brk says:
brk returns a pointer to the new end of memory if successful; otherwise -1 with errno set to indicate why the allocation failed.
errno
so comparing to 0 does not seem correct.
The text was updated successfully, but these errors were encountered:
Huh. This appears to be a platform difference.
On macOS, brk returns a void *: the new end of memory if successful or -1 on failure.
However the Open Group says brk returns an int: 0 on success or -1 on failure.
Sorry, something went wrong.
This is the fix I've added to MacPorts:
--- vmem_sbrk.c.orig 2009-03-05 18:56:48.000000000 -0600 +++ vmem_sbrk.c 2024-10-11 10:55:35.000000000 -0500 @@ -108,7 +108,7 @@ uintptr_t ret_brk; uintptr_t high_brk; uintptr_t new_brk; - int brk_result; + intptr_t brk_result; #define ALIGNSZ 16 #define BRKALIGN(x) (caddr_t)P2ROUNDUP((uintptr_t)(x), ALIGNSZ) @@ -134,9 +134,9 @@ return ((void *)-1); } - brk_result = brk((void *)new_brk); + brk_result = (intptr_t)brk((void *)new_brk); - if (brk_result != 0) + if (brk_result == (intptr_t)-1) return ((void *)-1); if (actual_size != NULL)
Another option that I've seen some other programs use is to check brk's return type at configure time.
Finally, brk is obsolete and should not be used at all.
No branches or pull requests
umem 1.0.1 does not build with Apple clang 16 from Xcode 16 on macOS 15. The error is:
This was reported to MacPorts here: https://trac.macports.org/ticket/71087
You define
brk_result
as anint
:portableumem/vmem_sbrk.c
Line 112 in 3fc772c
and assign the return value of
brk
to it:portableumem/vmem_sbrk.c
Line 141 in 3fc772c
But
brk
is documented to return avoid *
, not anint
.You then compare the result to
0
:portableumem/vmem_sbrk.c
Lines 144 to 145 in 3fc772c
But the manpage for
brk
says:so comparing to
0
does not seem correct.The text was updated successfully, but these errors were encountered: