Fix some Clang warnings I saw in Clang 22 - #1
Open
evantypanski wants to merge 3 commits into
Open
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Prototypes for get_page_size/fiber_stack_alignment, unreserve _probe_stack_weak_dummy, cast via void * in push/probe_stack, and restrict is_stack_aligned to assert builds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
evantypanski
force-pushed
the
topic/etyp/clang22-warnings
branch
from
August 25, 2026 19:41
34d64dd to
427a64d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude did all of this, I checked to make sure it makes sense. Does to me, at least. These are all minor so I am not going to make a fuss about them.
Looks unresponsive upstream so I'll only open here unless some signs of life show up.
Here are the warnings for the curious:
output
$ ninja [3/13] Building C object CMakeFiles/fiber.dir/src/fiber.c.o In file included from /Users/etyp/src/fiber/src/fiber.c:1: In file included from /Users/etyp/src/fiber/include/fiber/fiber.h:27: /Users/etyp/src/fiber/include/fiber/fiber_mach.h:134:20: warning: extra ';' inside a struct [-Wextra-semi] 134 | FIBER_ARCH_REGS; | ^ /Users/etyp/src/fiber/src/fiber.c:71:6: warning: cast from 'char *' to 'void **' increases required alignment from 1 to 8 [-Wcast-align] 71 | *(void **) *sp = val; | ^~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:89:15: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] 89 | uintptr_t sp = | ^ /Users/etyp/src/fiber/src/fiber.c:150:14: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] 150 | get_page_size() | ^ | void /Users/etyp/src/fiber/src/fiber.c:195:18: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] 195 | const size_t stack_size = size; | ^ /Users/etyp/src/fiber/src/fiber.c:288:1: warning: identifier '_probe_stack_weak_dummy' is reserved because it starts with '_' at global scope [-Wreserved-identifier] 288 | _probe_stack_weak_dummy(volatile char *sp, size_t sz); | ^ /Users/etyp/src/fiber/src/fiber.c:308:10: warning: cast from 'volatile char *' to 'volatile uintptr_t *' (aka 'volatile unsigned long *') increases required alignment from 1 to 8 [-Wcast-align] 308 | *(volatile uintptr_t *) sp |= (uintptr_t) 0; | ^~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:306:12: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] 306 | size_t i = 0; | ^ /Users/etyp/src/fiber/src/fiber.c:327:16: warning: implicit conversion when initializing 'char *' with an expression of type 'void *' is not permitted in C++ [-Wimplicit-void-ptr-cast] 327 | char *sp = hu_cxx_static_cast(char *, fbr->regs.sp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/deps/cxx-header-utils/include/hu/lang.h:62:42: note: expanded from macro 'hu_cxx_static_cast' 62 | # define hu_cxx_static_cast(T, x) hu_c_implicit_cast(T, x) | ^~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/deps/cxx-header-utils/include/hu/lang.h:57:17: note: expanded from macro 'hu_c_implicit_cast' 57 | hu_c_implicit_cast_(T, x, __COUNTER__) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/deps/cxx-header-utils/include/hu/lang.h:53:23: note: expanded from macro 'hu_c_implicit_cast_' 53 | T hu_c_implicit_cast_val##cnt = (x); \ | ^ ~~~ <scratch space>:452:1: note: expanded from here 452 | hu_c_implicit_cast_val__COUNTER__ | ^ /Users/etyp/src/fiber/src/fiber.c:337:12: warning: 'is_stack_aligned' was marked unused but was used [-Wused-but-marked-unused] 337 | assert(is_stack_aligned(sp)); | ^ /Users/etyp/src/fiber/src/fiber.c:344:12: warning: 'is_stack_aligned' was marked unused but was used [-Wused-but-marked-unused] 344 | assert(is_stack_aligned(sp)); | ^ /Users/etyp/src/fiber/src/fiber.c:327:11: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] 327 | char *sp = hu_cxx_static_cast(char *, fbr->regs.sp); | ^ /Users/etyp/src/fiber/src/fiber.c:371:22: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] 371 | fiber_stack_alignment() | ^ | void /Users/etyp/src/fiber/src/fiber.c:70:5: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 70 | *sp -= WORD_SIZE; | ^~~ /Users/etyp/src/fiber/src/fiber.c:90:40: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 90 | (uintptr_t) ((char *) fbr->stack + fbr->stack_size - WORD_SIZE); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:90:20: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 90 | (uintptr_t) ((char *) fbr->stack + fbr->stack_size - WORD_SIZE); | ^~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:218:19: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 218 | (char *) fbr->alloc_stack + (npages - 1) * pgsz, false))) | ^~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/deps/cxx-header-utils/include/hu/annotations.h:481:62: note: expanded from macro 'hu_unlikely' 481 | # define hu_unlikely(x) (__builtin_expect(HU_BOOL_CONTEXT(x), HU_BOOL_FALSE)) | ^ /Users/etyp/src/fiber/deps/cxx-header-utils/include/hu/annotations.h:21:32: note: expanded from macro 'HU_BOOL_CONTEXT' 21 | #define HU_BOOL_CONTEXT(p) (!!(p)) | ^ /Users/etyp/src/fiber/src/fiber.c:221:26: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 221 | fbr->stack = (char *) fbr->alloc_stack + pgsz; | ^~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:254:26: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 254 | protect_page((char *) fbr->alloc_stack + npages * pgsz, true); | ^~~~~~~~~~~~~~~~~~~~~~~~~ /Users/etyp/src/fiber/src/fiber.c:310:9: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 310 | sp -= pgsz; | ^~ /Users/etyp/src/fiber/src/fiber.c:330:24: warning: unsafe pointer arithmetic [-Wunsafe-buffer-usage] 330 | sp = stack_align_n(sp - args_size, arg_align); | ^~ 21 warnings generated.