1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-09-06 16:06:36 +03:00

chore(clang): format

This commit is contained in:
tyeth
2025-08-29 23:59:02 +01:00
parent 7c81ab32c0
commit a38e837d42

View File

@@ -564,21 +564,23 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::handleSubscriptionPacket(uint16_t len) {
// Parse MQTT Remaining Length field (variable length encoding). // Parse MQTT Remaining Length field (variable length encoding).
// This field can be 1-4 bytes, so we must parse it byte-by-byte. // This field can be 1-4 bytes, so we must parse it byte-by-byte.
// Each byte uses the lower 7 bits for data, and the MSB as a continuation flag. // Each byte uses the lower 7 bits for data, and the MSB as a continuation
// This loop advances 'offset' to the first byte after the remaining length field. // flag. This loop advances 'offset' to the first byte after the remaining
// length field.
uint32_t multiplier = 1; uint32_t multiplier = 1;
uint32_t value = 0; uint32_t value = 0;
uint8_t encodedByte; uint8_t encodedByte;
uint8_t offset = 1; // Start after the fixed header byte uint8_t offset = 1; // Start after the fixed header byte
do { do {
encodedByte = buffer[offset++]; encodedByte = buffer[offset++];
value += (encodedByte & 127) * multiplier; value += (encodedByte & 127) * multiplier;
multiplier *= 128; multiplier *= 128;
// Infinite loop protection: MQTT spec allows max 4 bytes for this field // Infinite loop protection: MQTT spec allows max 4 bytes for this field
if (offset > 5) { // 1 (header) + 4 (max length bytes) if (offset > 5) { // 1 (header) + 4 (max length bytes)
DEBUG_PRINTLN(F("Bad MQTT packet: Remaining Length field too long / malformed")); DEBUG_PRINTLN(
return NULL; F("Bad MQTT packet: Remaining Length field too long / malformed"));
} return NULL;
}
} while ((encodedByte & 128) != 0); } while ((encodedByte & 128) != 0);
// Now 'offset' points to the first byte of the topic length field. // Now 'offset' points to the first byte of the topic length field.