diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index 5f21de8..a4e2809 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -275,7 +275,7 @@
     if (buf_forward_capacity(buf) <= 1)
     {
         size_t len = strlen(str) + 1;
-        if (buf_size_valid(len) && (int)len < buf_forward_capacity_total(buf))
+        if (buf_size_valid(len) && len < buf_forward_capacity_total(buf))
         {
             memcpy(buf->data + buf->capacity - len, str, len);
         }
diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index ede3066..ae6dcb7 100644
--- a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h
@@ -1068,7 +1068,7 @@
  *
  * @return Capacity minus offset, or 0 if \c buf is invalid.
  */
-static inline int
+static inline size_t
 buf_forward_capacity_total(const struct buffer *buf)
 {
     if (buf_valid(buf))
@@ -1078,7 +1078,7 @@
         {
             ret = 0;
         }
-        return ret;
+        return (size_t)ret;
     }
     else
     {
diff --git a/tests/unit_tests/openvpn/test_dhcp.c b/tests/unit_tests/openvpn/test_dhcp.c
index e331d3d..3a84e1e 100644
--- a/tests/unit_tests/openvpn/test_dhcp.c
+++ b/tests/unit_tests/openvpn/test_dhcp.c
@@ -50,11 +50,6 @@
     return "dummy";
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
 static void
 test_write_dhcp_search_str(void **state)
 {
@@ -146,10 +141,6 @@
     gc_free(&gc);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 int
 main(void)
 {
