Repository navigation
r.horizon: Remove unreachable zero step branch in raster mode - #8148
Open
mallesh-bot wants to merge 1 commit into
Open
mallesh-bot wants to merge 1 commit into
mallesh-bot wants to merge 1 commit into
Conversation
main() replaces a zero step with 360 before calculate_raster_mode() runs, so the step == 0 branch, which called sprintf() on a NULL pointer, was never taken. GCC still warned about it with -Wnonnull and -Wformat-overflow. Fixes OSGeo#4472
This file contains hidden or 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
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.
Description
I removed the
settings->step == 0.0branch fromcalculate_raster_mode(), which calledsprintf()on a NULL pointer. I also removed thesettings->step != 0.0check beforeG_generate_basename()because it was always true. These changes don't affect how the code works for users.Motivation and context
The
stepvalue is already changed from0to360inmain()beforecalculate_raster_mode()is called, so that branch could never actually run. GCC was still showing warnings because it couldn't detect that the branch was unreachable. Also,calculate_raster_mode()is part ofr.horizon, notr.fill.stats.Fixes #4472.
How has this been tested?
I checked the CI build with
-Werrorand ran the existingr.horizontests, which passed. This includestest_raster_mode_one_direction, which runs raster mode withoutstep. I haven't added a new test because the removed code was unreachable.Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.