Skip to content

Fix kernel warnings and memory-safety issues#45

Merged
pradosh-arduino merged 1 commit into
mainfrom
codex/conduct-thorough-code-audit-for-frostwing-os
Jun 28, 2026
Merged

Fix kernel warnings and memory-safety issues#45
pradosh-arduino merged 1 commit into
mainfrom
codex/conduct-thorough-code-audit-for-frostwing-os

Conversation

@pradosh-arduino

Copy link
Copy Markdown
Collaborator

Motivation

  • Reduce a large class of compiler warnings and eliminate obvious memory-safety problems discovered while building the kernel under strict warning flags.
  • Make APIs and headers strictly prototyped to satisfy -Wstrict-prototypes and related pedantic checks.
  • Prevent duplicated header-owned storage and uninitialized DMA/bounce-buffer use that could lead to crashes or UB.

Description

  • Move AHCI per-port storage out of the header by changing static ahci_port_mem_t port_mem[32]; to extern in includes/ahci.h and define ahci_port_mem_t port_mem[32]; once in kernel/C/ahci.c to avoid duplicate definitions and unused-variable warnings.
  • Harden DMA and temporary-buffer handling by initializing DMA pointers to NULL, only copying from DMA buffers on successful operations, and guarding frees in ahci.c/nvme.c/gpt.c/mbr.c to avoid uninitialized use and double-free/copy-on-failure paths.
  • Add missing standard headers and prototypes (<string.h>/<memory.h>, strdup, memcpy usages) and convert many no-argument function declarations/definitions to strict prototypes (void) across headers and C files to fix -Wstrict-prototypes and missing-prototype diagnostics.
  • Fix varargs/ promotion bugs and integer-width/sign issues by adjusting va_arg types in debugger.c, providing a local 64-bit-to-hex helper, and adding explicit casts/unsigned suffixes where arithmetic could change sign/width (AHCI/NVMe/TSS/GDT/paging/etc.).
  • Fix packed-member access in acpi.c by copying the acpi_gas before using it and mark OEM string const to avoid discarded-qualifiers.
  • Add small API cleanups and missing declarations (e.g. remove_mount, list_all_mounts, io_wait_us/io_wait_ms) and add a non-executable .note.GNU-stack section to the syscall ASM to silence linker executable-stack warnings.

Testing

  • Ran a full build (make -C source) which completes and links wing_kernel.elf successfully after the changes.
  • Performed iterative strict-warning builds using the requested CFLAGS/-Wall -Wextra -Wpedantic ... -Werror and triaged/fixed many issues; the strict build was run repeatedly and the majority of warnings were eliminated but one remaining strict-blocker was observed in kernel/C/image/targa.c (narrowing/prototype issues) and left for a follow-up.
  • Ran git diff --check and a pre-commit check and committed the changes (commit present) with the working-tree passing the make invocation used for CI above.

Codex Task

@pradosh-arduino pradosh-arduino merged commit bb7fcf0 into main Jun 28, 2026
2 checks passed
@pradosh-arduino pradosh-arduino deleted the codex/conduct-thorough-code-audit-for-frostwing-os branch June 28, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant