]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Make buf_write_u8/16/32 take the type they pretend to take
authorArne Schwabe <arne@rfc2549.org>
Fri, 22 Apr 2022 14:29:44 +0000 (16:29 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 25 Apr 2022 12:14:49 +0000 (14:14 +0200)
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 <frank@lichtenheld.com>
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 <gert@greenie.muc.de>
src/openvpn/buffer.h

index 97cc86241147f587764605ef4d3c6784862fe420..231f1b0d4c12d71c208f29a7d0af2ec4b9a7420c 100644 (file)
@@ -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));
 }