Repository navigation
Remove the toHex overload that takes its length from a pointer's size - #1312
Merged
Merged
Conversation
toHex(uint8_t*) used sizeof(in)*2 as the byte count, which is the size of the pointer, not of the buffer. On the 32-bit ESP targets that is 8, which happens to match the one caller, the 8-byte temperature sensor address in the raw MQTT handler, so the output was right by accident. Pass the length explicitly there, as the other address call sites do, and drop the overload so it cannot be misused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🔧 PR Build ArtifactsVersion: All environments built successfully. Download the zip files:
|
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.
Why
toHex(uint8_t* in)computed its byte count assizeof(in)*2, i.e. the size of the pointer, not the buffer behind it. On ESP8266/ESP32 (32-bit) that is 8. Its only caller,RawMqttHandler::publishTemperatures, passes an 8-byte DS18B20 address (TempSensorData::address[8]), so the published topic was correct by accident. Any other buffer size, or a 64-bit native build, would read the wrong number of bytes.Changes
toHexfromhexutils.h/.cpp.RawMqttHandlercallstoHex(data->address, 8), the same as the address call sites inJsonMqttHandlerandAmsWebServer.No behaviour change on devices: the raw MQTT temperature topic stays the same.
Verification
pio run -e esp32 -e esp8266builds. With the overload removed, any remaining caller would fail to compile.pio test -e native: 25/25 pass.🤖 Generated with Claude Code