-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fix gcc warnings #842
Merged
georgehansper
merged 4 commits into
hercules-team:master
from
rwmjones:2024-fix-gcc-warnings
Aug 18, 2024
Merged
Fix gcc warnings #842
georgehansper
merged 4 commits into
hercules-team:master
from
rwmjones:2024-fix-gcc-warnings
Aug 18, 2024
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
LGTM |
GCC 14.2.1 gives lots of warnings of this sort about the order of parameters of reallocarray being the wrong way round: augprint.c: In function ‘find_or_create_group’: augprint.c:462:60: error: ‘reallocarray’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 462 | all_groups_realloc = reallocarray(all_groups, sizeof(struct group *), num_groups_newsize); | ^~~~~~ augprint.c:462:60: note: earlier argument should specify number of elements, later size of each element Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
GCC 14.2.1 gives warnings like: In file included from memory.h:26, from augmatch.c:30: In function ‘guess_lens_name’, inlined from ‘main’ at augmatch.c:396:16: internal.h:229:19: error: inlining failed in call to ‘streqv’: call is unlikely and code size would grow [-Werror=inline] 229 | static inline int streqv(const char *a, const char *b) { | ^~~~~~ augmatch.c:294:9: note: called from here 294 | if (streqv(ext, ".json")) { | ^~~~~~~~~~~~~~~~~~~~ These warnings don't seem very useful in Augeas, since we are not so sensitive to code size and don't care about inlining "purity". Rather than attempting to "fix" code which isn't really broken, I chose to disable an unhelpful warning. Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
GCC 14.2.1 doesn't seem to be able to analyze this stack frame code correctly. When compiling augeas with --enable-compile-warnings=error that causes the build to fail with the errors below. Disable the error around this code. In file included from /usr/include/string.h:548, from ../gnulib/lib/string.h:41, from internal.h:31, from get.c:30: In function ‘memset’, inlined from ‘push_frame’ at get.c:1095:5: /usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ offset [0, 31] is out of the bounds [0, 0] [-Werror=array-bounds=] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | __glibc_objsize0 (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ If you disable -Warray-bounds only then you get this instead: In file included from /usr/include/string.h:548, from ../gnulib/lib/string.h:41, from internal.h:31, from get.c:30: In function ‘memset’, inlined from ‘push_frame’ at get.c:1100:5: /usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ writing 32 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | __glibc_objsize0 (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ In function ‘push_frame’: cc1: note: destination object is likely at address zero Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
GCC 14.2.1 gives: test-api.c: In function ‘testAugPreview’: test-api.c:867:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 867 | hosts_txt = calloc(sizeof(char),4096); | ^~~~ test-api.c:867:39: note: earlier argument should specify number of elements, later size of each element Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
rwmjones
force-pushed
the
2024-fix-gcc-warnings
branch
from
August 14, 2024 14:28
f76e133
to
87bbea4
Compare
Thanks for these fixes, @rwmjones |
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.
Fix miscellaneous GCC warnings. In particular this causes the compile to fail when using
configure --enable-compile-warnings=error
and using a recent version of GCC.