-
Notifications
You must be signed in to change notification settings - Fork 30
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
Enable build flags and fix compilation warnings (gcc 14.1.0) #66
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPP_COMPILE is an option, a cache variable, thus regular unset() is not working for it since it tries to unset the scope variable. This causing cmake to skip compilation of rpc. Unset CPP_COMPILE from CACHE to make it work as intended.
Currently tests, soak and examples are build without extra flags, because add_compile_options is specified after defining build targets. From add_compile_options() docs: Adds options to the compiler command line for targets in the current directory and below that are added *after* this command is invoked.
Fixes: warning: ISO C forbids conversion of function pointer to object pointer type
Nb net could be included multiple times, to prevent creation of global variables in each file move them under NBNET_IMPL. Also use designated initializer to initiate a driver structure to remove warnings about partial initialization. Designated initializer would initialize other members to zero.
Cast unused function arguments to (void) to suspend warnings.
Remove unnecessary lt 0 checks and sync types to remove signed vs unsigned warnings.
Fixes: nbnet/tests/string_tests.c:18:9: error: ‘strncpy’ output truncated before terminating nul copying 5 bytes from a string of the same length [-Werror=stringop-truncation] 18 | strncpy(res + pos, b, len_b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ nbnet/tests/string_tests.c:24:9: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-truncation]
Mark GameServer_GetClientCount() as inline.
In case when value in unsigned type and min is 0, this commit just obfuscates types, maybe there's better solution. Fixes: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
In release mode(-DCMAKE_BUILD_TYPE=Release) tests returning following error: nbnet/tests/../nbnet.h:2272:9: error: ‘memcpy’ forming offset [4, 7] is out of the bound s [0, 4] of object ‘word’ with type ‘Word’ {aka ‘unsigned int’} [-Werror=array-bounds=] 2272 | memcpy(bytes, &word, length); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Add check to verify that length is less than Word size.
@f0rget-the-sad thank you for your contribution. According to the pipeline, it seems that the code does not compile on Windows anymore. |
nathhB
approved these changes
Aug 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current
add_compile_options()
in tests and examples are not taken into account, due to that any warnings are simply ignored.This patch series moves add
add_compile_options()
before target creation to resolve this issue.Also, I tried to group warnings fixes into categories as separate patches, so it should be possible to rearrange/replace part of them.