]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Avoid format specifier %zu for Windows compatibility
authorSelva Nair <selva.nair@gmail.com>
Thu, 11 Aug 2016 22:58:29 +0000 (18:58 -0400)
committerDavid Sommerseth <davids@openvpn.net>
Fri, 12 Aug 2016 15:23:34 +0000 (17:23 +0200)
- Replace %zu by %u and cast the size_t variable to (unsigned int). The
  cast should be safe as in all instances the number involved is small.

Note: mingw64 targets msvcrt.dll runtime that doesn't support %zu and
      print "zu" instead of the number. With -Wformat the compiler
      does warn that z is an unknown conversion type.

v2: Cast to (unsigned int) instead of (int).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1470956309-31268-1-git-send-email-selva.nair@gmail.com>
URL: https://sourceforge.net/p/openvpn/mailman/message/35274787/
Signed-off-by: David Sommerseth <davids@openvpn.net>
src/openvpn/crypto.c
src/openvpn/options.c
src/openvpn/ssl_mbedtls.c

index d94896ce64c2246ca81bb5a42300872e7bf8b9e2..d6d025122f694a00be10c86c8fc68151fcc8fe19 100644 (file)
@@ -738,8 +738,8 @@ crypto_adjust_frame_parameters(struct frame *frame,
 
   frame_add_to_extra_frame (frame, crypto_overhead);
 
-  msg(D_MTU_DEBUG, "%s: Adjusting frame parameters for crypto by %zu bytes",
-      __func__, crypto_overhead);
+  msg(D_MTU_DEBUG, "%s: Adjusting frame parameters for crypto by %u bytes",
+      __func__, (unsigned int) crypto_overhead);
 }
 
 size_t
index 7e08fcdabb107a2552832e34a142dd2286e25d53..c100d4ca0f1e11d1f1cebdd4deb0a9206e61a86b 100644 (file)
@@ -2992,7 +2992,7 @@ calc_options_string_link_mtu(const struct options *o, const struct frame *frame)
          o->replay, cipher_kt_mode_ofb_cfb (fake_kt.cipher));
       frame_finalize(&fake_frame, o->ce.link_mtu_defined, o->ce.link_mtu,
             o->ce.tun_mtu_defined, o->ce.tun_mtu);
-      msg (D_MTU_DEBUG, "%s: link-mtu %zu -> %d", __func__, link_mtu,
+      msg (D_MTU_DEBUG, "%s: link-mtu %u -> %d", __func__, (unsigned int) link_mtu,
          EXPANDED_SIZE (&fake_frame));
       link_mtu = EXPANDED_SIZE (&fake_frame);
     }
@@ -3061,7 +3061,7 @@ options_string (const struct options *o,
    */
 
   buf_printf (&out, ",dev-type %s", dev_type_string (o->dev, o->dev_type));
-  buf_printf (&out, ",link-mtu %zu", calc_options_string_link_mtu(o, frame));
+  buf_printf (&out, ",link-mtu %u", (unsigned int) calc_options_string_link_mtu(o, frame));
   buf_printf (&out, ",tun-mtu %d", PAYLOAD_SIZE (frame));
   buf_printf (&out, ",proto %s",  proto_remote (o->ce.proto, remote));
 
index e20ec02dd540869df43faff0fc6b7082c2dc78e8..8a761a45a45f0f0cdf468126dad649969fa3438d 100644 (file)
@@ -1111,8 +1111,8 @@ print_details (struct key_state_ssl * ks_ssl, const char *prefix)
   cert = mbedtls_ssl_get_peer_cert (ks_ssl->ctx);
   if (cert != NULL)
     {
-      openvpn_snprintf (s2, sizeof (s2), ", %zu bit key",
-         mbedtls_pk_get_bitlen (&cert->pk));
+      openvpn_snprintf (s2, sizeof (s2), ", %u bit key",
+         (unsigned int) mbedtls_pk_get_bitlen (&cert->pk));
     }
 
   msg (D_HANDSHAKE, "%s%s", s1, s2);