Skip to content

Clamp, instead of roll over, analog sensor byte #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Krellan
Copy link

@Krellan Krellan commented Jan 26, 2021

When converting a double value to an integer byte, in the IPMI SDR,
there was previously no bounds-checking, causing the byte to
roll over when an out-of-range value was passed in.

Instead of rolling over, clamp the byte to the appropriate minimum
or maximum, based on the type (signed versus unsigned) of the
byte. This behavior, to me, seems safer and more correct.

Signed-off-by: Josh Lehan krellan@google.com

When convering a double value to an integer byte, in the IPMI SDR,
there was previously no bounds-checking, causing the byte to
roll over when an out-of-range value was passed in.

Instead of rolling over, clamp the byte to the appropriate minimum
or maximum, based on the type (signed versus unsigned) of the
byte. This behavior, to me, seems safer and more correct.

Signed-off-by: Josh Lehan <krellan@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant