]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: peers: remove the unused intencode()
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 18 Nov 2026 14:21:21 +0000 (15:21 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 18 Nov 2026 14:53:46 +0000 (15:53 +0100)
All peers message builders now use encode_varint(), which knows the end of
the destination buffer and can fail. intencode() has no caller left, and
its comment still advises callers to ensure the room left after the
pointer, which is exactly what the new code checks explicitly.

Remove it.

src/peers.c

index 6d94125331829448ca377ca40aabc11ac81b7ce2..04996e4a16e373befc9cccd4879597681077e62c 100644 (file)
@@ -536,35 +536,6 @@ static inline const char *peer_applet_state_str(int state)
        }
 }
 
-/* This function encode an uint64 to 'dynamic' length format.
-   The encoded value is written at address *str, and the
-   caller must assure that size after *str is large enough.
-   At return, the *str is set at the next Byte after then
-   encoded integer. The function returns then length of the
-   encoded integer in Bytes */
-int intencode(uint64_t i, char **str) {
-       int idx = 0;
-       unsigned char *msg;
-
-       msg = (unsigned char *)*str;
-       if (i < PEER_ENC_2BYTES_MIN) {
-               msg[0] = (unsigned char)i;
-               *str = (char *)&msg[idx+1];
-               return (idx+1);
-       }
-
-       msg[idx] =(unsigned char)i | PEER_ENC_2BYTES_MIN;
-       i = (i - PEER_ENC_2BYTES_MIN) >> PEER_ENC_2BYTES_MIN_BITS;
-       while (i >= PEER_ENC_STOP_BYTE) {
-               msg[++idx] = (unsigned char)i | PEER_ENC_STOP_BYTE;
-               i = (i - PEER_ENC_STOP_BYTE) >> PEER_ENC_STOP_BIT;
-       }
-       msg[++idx] = (unsigned char)i;
-       *str = (char *)&msg[idx+1];
-       return (idx+1);
-}
-
-
 /* This function returns a decoded 64bits unsigned integer
  * from a varint
  *