Hello,

Found this typo in macro name :)

BTW, in mqtt.c mqtt_read_varint(), "off" is initialized to 0, but 
initialized again in the for loop, which results in a dead assignment.

I believe this is done on purpose, as some sort of defensive
programming, so I didn't touch it, but wanted to bring attention to it, 
in case it is not something wanted.

Cheers,
~Nicolas
>From 1c7694831f5d0a89d3250e6c9872b68ddc170a72 Mon Sep 17 00:00:00 2001
From: Nicolas CARPi <[email protected]>
Date: Tue, 27 Aug 2024 21:51:26 +0200
Subject: [PATCH] CLEANUP: mqtt: fix typo in MQTT_REMAINING_LENGHT_MAX_SIZE

There was a typo in the macro name, where LENGTH was incorrectly
written. This didn't cause any issue because the typo appeared in all
occurrences in the codebase.
---
 include/haproxy/mqtt-t.h | 2 +-
 src/mqtt.c               | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/haproxy/mqtt-t.h b/include/haproxy/mqtt-t.h
index 3af2d1158..030a29b74 100644
--- a/include/haproxy/mqtt-t.h
+++ b/include/haproxy/mqtt-t.h
@@ -118,7 +118,7 @@ enum {
 
 /* MQTT minimal packet size */
 #define MQTT_MIN_PKT_SIZE              2
-#define MQTT_REMAINING_LENGHT_MAX_SIZE 4
+#define MQTT_REMAINING_LENGTH_MAX_SIZE 4
 
 /* list of supported capturable Field Names and configuration file string */
 enum {
diff --git a/src/mqtt.c b/src/mqtt.c
index 5688296e5..7abbbbf0c 100644
--- a/src/mqtt.c
+++ b/src/mqtt.c
@@ -238,7 +238,7 @@ static inline struct ist mqtt_read_4byte_int(struct ist 
parser, uint32_t *i)
  * Thus each byte encodes 128 values and a "continuation bit".
  *
  * The maximum number of bytes in the Remaining Length field is four
- * (MQTT_REMAINING_LENGHT_MAX_SIZE).
+ * (MQTT_REMAINING_LENGTH_MAX_SIZE).
  *
  * <parser> is supposed to point to the first byte of the integer. On success
  * the integer is stored in <*i> and the new parser state is returned. On
@@ -251,7 +251,7 @@ static inline struct ist mqtt_read_varint(struct ist 
parser, uint32_t *i)
        off = m = 0;
        if (i)
                *i = 0;
-       for (off = 0; off < MQTT_REMAINING_LENGHT_MAX_SIZE && istlen(parser); 
off++) {
+       for (off = 0; off < MQTT_REMAINING_LENGTH_MAX_SIZE && istlen(parser); 
off++) {
                uint8_t byte = (uint8_t)*istptr(parser);
 
                if (i) {
@@ -265,7 +265,7 @@ static inline struct ist mqtt_read_varint(struct ist 
parser, uint32_t *i)
                        break;
        }
 
-       if (off == MQTT_REMAINING_LENGHT_MAX_SIZE)
+       if (off == MQTT_REMAINING_LENGTH_MAX_SIZE)
                return IST_NULL;
        return parser;
 }
-- 
2.46.0

Reply via email to