Skip to content

Fix some Clang warnings I saw in Clang 22 - #1

Open
evantypanski wants to merge 3 commits into
topic/bbannier/patchesfrom
topic/etyp/clang22-warnings
Open

Fix some Clang warnings I saw in Clang 22#1
evantypanski wants to merge 3 commits into
topic/bbannier/patchesfrom
topic/etyp/clang22-warnings

Conversation

@evantypanski

Copy link
Copy Markdown
Member

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.

evantypanski and others added 3 commits August 25, 2026 15:41
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant