Skip to content

Conversation

knottnt
Copy link
Contributor

@knottnt knottnt commented May 19, 2025

Issue #, if available:

Description of changes:

  • Update set_sdk.go setSDKForScalar() to allow zero and negative values for float32 in bounds check

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from michaelhtm and rushmash91 May 19, 2025 15:42
@ack-prow ack-prow bot added the approved label May 19, 2025
- Update generated bounds check for float32 values to permit zero and negative values.
Copy link
Member

@michaelhtm michaelhtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch @knottnt!
left a few nits

use positional arguments for Int bounds check.
@knottnt knottnt force-pushed the allow-zero-and-negative-float32 branch from 7627169 to 66ba150 Compare May 19, 2025 18:16
@knottnt knottnt requested a review from michaelhtm May 19, 2025 18:36
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it, thank Trevor! 🚀

@knottnt
Copy link
Contributor Author

knottnt commented May 19, 2025

/retest

@michaelhtm
Copy link
Member

/lgtm
/hold

@ack-prow ack-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 19, 2025
@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2025
@knottnt knottnt requested a review from a-hilaly May 19, 2025 23:29
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
/lgtm

@knottnt
Copy link
Contributor Author

knottnt commented May 20, 2025

@michaelhtm @a-hilaly

Example of the new output shown below. The new check is quite a bit larger. Assuming we want to prevent float64 values smaller than math.SmallestNonzeroFloat32 from being silently changed to zero we could reduce the size of the generated bounds check by adding a new function to the runtime package. Then in code-gen we simply call the new function.

if temperatureCopy0 > math.MaxFloat32 || temperatureCopy0 < -math.MaxFloat32 || (temperatureCopy0 < math.SmallestNonzeroFloat32 && !(temperatureCopy0 <= 0)) || (temperatureCopy0 > -math.SmallestNonzeroFloat32 && !(temperatureCopy0 >= 0)) {
	return nil, fmt.Errorf("error: field temperature is of type float32")
}

This is replacing the below check which does not allow zero or negative values.

if temperatureCopy0 > math.MaxFloat32 || temperatureCopy0 < math.SmallestNonzeroFloat32 {
	return nil, fmt.Errorf("error: field temperature is of type float32")
}

@ack-prow ack-prow bot removed the lgtm Indicates that a PR is ready to be merged. label May 20, 2025
@@ -0,0 +1,132 @@
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to use a new file since the existing set_sdk_test.go has a circular dependency with the code package due to testutils.

Copy link

ack-prow bot commented May 20, 2025

@knottnt: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
verify-attribution ed4695d link false /test verify-attribution
s3-olm-test ed4695d link false /test s3-olm-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@knottnt
Copy link
Contributor Author

knottnt commented May 20, 2025

/test ec2-controller-test

@knottnt
Copy link
Contributor Author

knottnt commented May 21, 2025

/unhold

@ack-prow ack-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 21, 2025
@knottnt knottnt requested a review from a-hilaly May 21, 2025 15:54
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@a-hilaly
Copy link
Member

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 21, 2025
Copy link

ack-prow bot commented May 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, knottnt, michaelhtm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [a-hilaly,knottnt,michaelhtm]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot merged commit ed3e8af into aws-controllers-k8s:main May 21, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants