Skip to content
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

Fixed assorted compiler warnings #22

Merged
merged 5 commits into from
Aug 3, 2024
Merged

Fixed assorted compiler warnings #22

merged 5 commits into from
Aug 3, 2024

Conversation

tdulcet
Copy link
Member

@tdulcet tdulcet commented Apr 11, 2024

  • Fixed 20 stringop-truncation warnings.
  • Removed use of the snprintf_nowarn macro, which revealed some hidden warnings.
    • Fixed 20 format-truncation warnings by doubling the size of the cbuf array.
  • Fixed 10 discarded-qualifiers warnings.
  • Updated the ASSERT function to (partially) use a macro instead, similar to the C standard library assert macro in assert.h.
    • This should reduce the number of false positive warnings, as compilers and static analyzers can much more easily check if the assert is going to fail.
    • I switched to Ernst's C99 ASSERT function, which shows the function name in error messages and I renamed it to ABORT. I also added the assertion string to the error messages.
    • This allowed removing the HERE argument, which I added to the macro instead. This was a major change, as Ernst had over 4,000 assert statements.
    • This should result in a performance improvement, as it no longer needs to call a function to test the expression.
  • Updated to use the int8_t, int16_t, int32_t and int64_t integer types from stdint.h instead of redefining them.
    • This could help with the Windows issues. Unfortunately, to prevent more compiler warnings it required also updating over 700 of the printf calls to use the defines from inttypes.h.
    • I also used the boolean types from stdbool.h while I was at it.

This pull request is a work in progress, as I am not sure it is the best way to fix some of these warnings. I would recommend reviewing each commit individually. Feedback is welcome!

@tdulcet tdulcet added bug Something isn't working help wanted Extra attention is needed labels Apr 11, 2024
@tdulcet tdulcet requested a review from ldesnogu April 11, 2024 14:01
src/types.h Outdated Show resolved Hide resolved
src/util.h Outdated Show resolved Hide resolved
@xanthe-cat
Copy link
Collaborator

Just a general comment on one particular category you’ve looked at in this PR. Adding the tested condition for the ABORT message should be highly useful; Ernst may have had some idea what was going on but reading his code and the output it generates is often rather obscure to me. As much explanatory information as available is sometimes barely enough.

@tdulcet
Copy link
Member Author

tdulcet commented Apr 13, 2024

Adding the tested condition for the ABORT message should be highly useful

Thanks, that is good to know it would be useful for you. It is a feature of the standard library assert statement from assert.h, which I thought might be useful to add to Ernst's custom implementation. Unfortunately, until someone is able to find a fix for #10, I think I am going to have to rework this PR and remove some of the changes.

@tdulcet tdulcet force-pushed the warnings branch 2 times, most recently from 7ee4f66 to 4efc904 Compare April 13, 2024 14:16
@tdulcet tdulcet marked this pull request as ready for review April 13, 2024 14:47
@tdulcet tdulcet requested a review from xanthe-cat April 13, 2024 14:47
@tdulcet tdulcet removed the help wanted Extra attention is needed label Apr 14, 2024
@ldesnogu
Copy link
Collaborator

ldesnogu commented Aug 1, 2024

Random comments:

  • The last commit of that branch (adding const) introduced new errors when doing a non multi-threaded build.
  • I think we should have an ASSERT_ALWAYS (or some other name such as FATAL); this would allow us to use the gcc/clang noreturn attribute.

Regarding the first comment above, I'm unsure how to proceed: amend or add a patch. My preference is to have bisectable code, which would mean amending the offending git change, instead of adding a new commit after.

For the second comment, this can come as a later patch.

@tdulcet
Copy link
Member Author

tdulcet commented Aug 1, 2024

Regarding the first comment above, I'm unsure how to proceed: amend or add a patch.

Please feel free to amend my commit. I changed the base of your PR, so it should automatically update when this is fixed (might need a quick rebase).

For the second comment, this can come as a later patch.

I previously moved the assert changes to #24, which does add the noreturn attribute, but this is currently blocked on fixing #10. Feel free to make additional changes in the PR if you want.

Introduced some local non const addr_/addi_ variables to prevent some
compilation errors in single thread build.

This affects radix{128,256,384,1024}_main_carry_loop.h.
@ldesnogu
Copy link
Collaborator

ldesnogu commented Aug 2, 2024

Regarding the first comment above, I'm unsure how to proceed: amend or add a patch.

Please feel free to amend my commit. I changed the base of your PR, so it should automatically update when this is fixed (might need a quick rebase).

I force pushed the change. I will use this as a basis to fix other errors for single-thread compilation (if that proves possible at all, which I'm not sure is the case).

Copy link
Collaborator

@ldesnogu ldesnogu left a comment

Choose a reason for hiding this comment

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

-- ignore --

Copy link
Collaborator

@ldesnogu ldesnogu left a comment

Choose a reason for hiding this comment

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

This looks good to me.

The only thing I'd add is the removal of the snprintf_warn macro. This can be taken care of later and should not block the merging.

@tdulcet tdulcet merged commit 0db0c16 into main Aug 3, 2024
19 of 21 checks passed
@tdulcet tdulcet deleted the warnings branch August 3, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants