fix negative percentage and corrupt pgrogress par on large builds#535
Closed
jp-embedded wants to merge 3 commits into
Closed
fix negative percentage and corrupt pgrogress par on large builds#535jp-embedded wants to merge 3 commits into
jp-embedded wants to merge 3 commits into
Conversation
Owner
|
I merged the fix in, but the test case doesn't seem to be working correctly (it passes even before the change). I'm getting this for .tup/progress-output: And this for .tup/progress-lines: (which is obviously wrong!) Your patch fixes it so the numbers are positive, but the test case doesn't seem to be verifying that. |
Author
|
ok thanks. Sorry for that. I will have a closer look at the test. |
…tput because the behave differently
Author
|
Fixed the test. Also added a test for color mode because it behaves differently |
Owner
|
Merged, thanks for the fixes! |
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.
Progress bar overflow fix
Problem:
Large builds could make the progress percentage negative and corrupt the
progress bar output. The progress code calculated percentages with int
arithmetic, for example sum * 100 / total. Once the completed job count was
large enough, sum * 100 could overflow a signed int before the division. The
overflowed negative percentage was then used to calculate the filled portion of
the progress bar. That could produce a negative fill width and an invalid buffer
offset in the printf call that renders the bar, causing garbled characters.
Fix:
The percentage calculation now uses wider arithmetic for count-based progress
and stores time-based progress totals in time_t, matching the graph's total
mtime type. The computed percentage is clamped to the display range 0..100.
The rendered progress bar fill length is also clamped to 0..max before it is
used as a printf precision or buffer offset.
Result:
The progress percentage no longer wraps negative on large projects, and the
progress bar cannot render with negative widths or out-of-range buffer offsets
even if the completed count temporarily exceeds the expected total.