Skip to content

Fix const-related warnings, and a few others#797

Merged
tmewett merged 1 commit intotmewett:releasefrom
nstoddard:fix-const-warnings
Mar 3, 2026
Merged

Fix const-related warnings, and a few others#797
tmewett merged 1 commit intotmewett:releasefrom
nstoddard:fix-const-warnings

Conversation

@nstoddard
Copy link
Copy Markdown
Contributor

This fixes all warnings related to pointers to consts. It also fixes a few other straightforward-to-fix warnings which didn't seem big enough for a separate commit (though I'm happy to make separate commits for them if that would be helpful).

There's a few cases where there's a type like creature *hitList[8], which seem like they should be able to be const, but doing so requires some ugly casts, so this makes them non-const, for simplicity. In all other cases, this commit adds consts rather than removing them.

After this commit, the vast majority of warnings displayed on my system are along the lines of "output may be truncated copying 299 bytes from a string of length 299 " or "reading 100 bytes from a region of size 10". I intend to look into those later.

Copy link
Copy Markdown
Contributor

@brturn brturn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend some changes.

Also, I'm not getting the buffer warnings you describe when compiling with clang. Which compiler are you using, and what is the buffer warning flag that it is using?

Comment thread src/platform/platformdependent.c Outdated
Comment thread src/platform/platformdependent.c Outdated
This fixes all warnings related to pointers to consts. It also fixes a few other straightforward-to-fix warnings.

There's a few cases where there's a type like `creature *hitList[8]`, which seem like they should be able to be `const`, but doing so requires some ugly casts, so this makes them non-const, for simplicity. In all other cases, this commit adds `const`s rather than removing them.
@nstoddard
Copy link
Copy Markdown
Contributor Author

Also, I'm not getting the buffer warnings you describe when compiling with clang. Which compiler are you using, and what is the buffer warning flag that it is using?

I'm using gcc (version 15.2.0). The github checks also seem to use GCC (see the "Compile" section here), and it looks like many of the warnings are from -Wstringop-truncation, -Wstringop-overread, and -Wstringop-overflow. On my system, clang (version 20.1.8) doesn't seem to support those. Some warnings seem to be from -Wformat-truncation, but enabling that on clang doesn't seem to do anything.

Copy link
Copy Markdown
Owner

@tmewett tmewett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I agree with the rationale for the removal of those consts; I'm not sure consts add huge value to the Brogue architecture

@tmewett tmewett merged commit 45384a0 into tmewett:release Mar 3, 2026
1 check failed
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.

3 participants