Skip to content

Constify error_desc and perror #3

New issue

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

Merged
merged 1 commit into from
Jun 29, 2025
Merged

Conversation

visitorckw
Copy link
Collaborator

The error_desc array and the perror pointer are never modified after initialization. Marking them as const moves the data to the read-only section, improving safety.

Before:
$ riscv-none-elf-size ./build/kernel/error.o
text data bss dec hex filename
398 172 0 570 23a ./build/kernel/error.o

After:
$ riscv-none-elf-size ./build/kernel/error.o
text data bss dec hex filename
570 0 0 570 23a ./build/kernel/error.o

The error_desc array and the perror pointer are never modified after
initialization. Marking them as const moves the data to the read-only
section, improving safety.

Before:
$ riscv-none-elf-size ./build/kernel/error.o
   text    data     bss     dec     hex filename
    398     172       0     570     23a ./build/kernel/error.o

After:
$ riscv-none-elf-size ./build/kernel/error.o
   text    data     bss     dec     hex filename
    570       0       0     570     23a ./build/kernel/error.o
@jserv jserv merged commit 7af2982 into sysprog21:main Jun 29, 2025
@jserv
Copy link
Contributor

jserv commented Jun 29, 2025

Thank @visitorckw for contributing!

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.

2 participants