From: Arne Schwabe Date: Fri, 22 Apr 2022 14:29:44 +0000 (+0200) Subject: Make buf_write_u8/16/32 take the type they pretend to take X-Git-Tag: v2.6_beta1~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc6e00e2e75eae58bf94bcf384ae2ba68c5c6bd3;p=thirdparty%2Fopenvpn.git Make buf_write_u8/16/32 take the type they pretend to take This functions should accept the type of integer they say to write. Calling the u32 function with an integer that is actually 32 bit unsigned gives compiler warnings. Acked-by: Frank Lichtenheld Message-Id: <20220422142953.3805364-10-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24165.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 97cc86241..231f1b0d4 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -694,23 +694,22 @@ buf_write_prepend(struct buffer *dest, const void *src, int size) } static inline bool -buf_write_u8(struct buffer *dest, int data) +buf_write_u8(struct buffer *dest, uint8_t data) { - uint8_t u8 = (uint8_t) data; - return buf_write(dest, &u8, sizeof(uint8_t)); + return buf_write(dest, &data, sizeof(uint8_t)); } static inline bool -buf_write_u16(struct buffer *dest, int data) +buf_write_u16(struct buffer *dest, uint16_t data) { - uint16_t u16 = htons((uint16_t) data); + uint16_t u16 = htons(data); return buf_write(dest, &u16, sizeof(uint16_t)); } static inline bool -buf_write_u32(struct buffer *dest, int data) +buf_write_u32(struct buffer *dest, uint32_t data) { - uint32_t u32 = htonl((uint32_t) data); + uint32_t u32 = htonl(data); return buf_write(dest, &u32, sizeof(uint32_t)); }