-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
call string.Repeat always with positive int #7104
Conversation
cmd/lotus-miner/sealing.go
Outdated
if ramRepeatSpace < 0 { | ||
ramRepeatSpace = 0 | ||
ramBar = color.RedString(strings.Repeat("|", ramBarsRes)) + | ||
color.GreenString(strings.Repeat("|", ramBarsUsed)) + | ||
strings.Repeat(" ", ramRepeatSpace) | ||
} else { | ||
ramBar = color.YellowString(strings.Repeat("|", ramBarsRes)) + | ||
color.GreenString(strings.Repeat("|", ramBarsUsed)) + | ||
strings.Repeat(" ", ramRepeatSpace) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: populate the variable portion of ramBar
under the condition, then the static version outside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
vmemBar := color.YellowString(strings.Repeat("|", vmemBarsRes)) + | ||
color.GreenString(strings.Repeat("|", vmemBarsUsed)) + | ||
strings.Repeat(" ", int(barCols)-vmemBarsUsed-vmemBarsRes) | ||
strings.Repeat(" ", vmemRepeatSpace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guaranteed to be non-negative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure, so better be safe and keep the same pattern as ramBar
for simplicity.
398433e
to
548865e
Compare
Codecov Report
@@ Coverage Diff @@
## master #7104 +/- ##
==========================================
- Coverage 34.85% 34.79% -0.06%
==========================================
Files 685 685
Lines 80187 80197 +10
==========================================
- Hits 27947 27908 -39
- Misses 46553 46592 +39
- Partials 5687 5697 +10
Continue to review full report at Codecov.
|
We have a report for a panic at:
on tag
m1.3.4
Apparently
int(barCols)-ramBarsUsed-ramBarsRes
somehow gets negative (calling itramRepeatSpace
now).This PR is making sure
ramRepeatSpace
is set to 0, in case it is negative, and changes the colour of the string from yellow to red in this case.