From: Frederic Lecaille Date: Wed, 18 Nov 2026 14:21:21 +0000 (+0100) Subject: CLEANUP: peers: remove the unused intencode() X-Git-Tag: v3.5-dev13~5 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=f79015290ed0b7b2e56968b84c0ae10cbfb35af9;p=haproxy.git CLEANUP: peers: remove the unused intencode() 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. --- diff --git a/src/peers.c b/src/peers.c index 6d9412533..04996e4a1 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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 *