-
Notifications
You must be signed in to change notification settings - Fork 413
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
Dividing variable by itself in loop_handler.go #2026
Comments
Stale issue message |
@darh or @tjerman could you have a look at it?
So to keep the current functionality, just replace if args.First*(args.Step/args.Step) >= args.Last*(args.Step/args.Step) {
return nil, fmt.Errorf("failed to initialize counter iterator with first step greater than last")
} with if args.Step == 0 {
return nil, fmt.Errorf("failed to initialize counter iterator with zero step")
}
if args.First >= args.Last {
return nil, fmt.Errorf("failed to initialize counter iterator with first step greater than last")
} I can imagine it was meant to be a sign check to allow negative steps. If so, it could be like this: func signOf(n int64) int {
if n > 0 {
return 1
} else if n < 0 {
return -1
}
return 0
} and replace if args.First*(args.Step/args.Step) >= args.Last*(args.Step/args.Step) {
return nil, fmt.Errorf("failed to initialize counter iterator with first step greater than last")
} with if args.Step == 0 && args.First != args.Last {
return nil, fmt.Errorf("failed to initialize counter iterator with zero step")
}
sign := signOf(args.Step)
if args.First*sign > args.Last*sign {
return nil, fmt.Errorf("failed to initialize counter iterator with first value greater than last")
} or if zero steps are not allowed, then replace the block with sign := signOf(args.Step)
if args.First*sign >= args.Last*sign {
return nil, fmt.Errorf("failed to initialize counter iterator with first value greater than last")
} |
It should be
If you want, do a pull request so I don't steal your work |
No problem @tjerman I grant you permission to steal this piece of code from me :D I don't have a setup to build go or to run the tests. So I would only feel bad that I can't check all the checkboxes in the PR template. |
Is there an existing issue for this?
Version of Corteza
2024.9.x branch
Current Behavior
In
server/automation/automation/loop_handler.go
there is:corteza/server/automation/automation/loop_handler.go
Line 42 in 31d38a2
Expected Behavior
I believe it is not intended to compute
args.Step/args.Step
.If it is intended, there should be a comment explaining what magic is going on.
Steps To Reproduce
No response
Environment and versions
No response
Anything else?
@darh
The text was updated successfully, but these errors were encountered: