[ovs-dev] Windows port status

Alin Serdean aserdean at cloudbasesolutions.com
Mon Nov 25 22:19:11 UTC 2013


Sure :).

Signed-off-by: Alin Serdean <aserdean at cloudbasesolutions.com>
---
 CodingStyle                   |    2 +-
 Makefile.am                   |   13 ++++++++++++
 lib/bundle.c                  |    4 +-
 lib/coverage.c                |    2 +-
 lib/hmap.c                    |    2 +-
 lib/multipath.c               |    2 +-
 lib/netdev-bsd.c              |    4 +-
 lib/netdev-linux.c            |    4 +-
 lib/netlink-socket.c          |    4 +-
 lib/netlink.c                 |    8 +++---
 lib/nx-match.c                |    4 +-
 lib/odp-util.c                |    8 +++---
 lib/ofp-actions.c             |   10 ++++----
 lib/ofp-print.c               |   26 ++++++++++++------------
 lib/ofp-util.c                |   42 ++++++++++++++++++++--------------------
 lib/ofpbuf.c                  |    2 +-
 lib/ovsdb-data.c              |    6 ++--
 lib/ovsdb-idl.c               |    6 ++--
 lib/ovsdb-parser.c            |    2 +-
 lib/pcap-file.c               |    2 +-
 lib/socket-util.c             |    6 ++--
 lib/stp.c                     |    6 ++--
 lib/stream-ssl.c              |    4 +-
 lib/util.h                    |   10 +++++++++
 ofproto/ofproto-dpif-upcall.c |    4 +-
 ofproto/ofproto-dpif.c        |    6 ++--
 ofproto/ofproto.c             |    2 +-
 ovsdb/execution.c             |    2 +-
 ovsdb/jsonrpc-server.c        |    4 +-
 ovsdb/log.c                   |    2 +-
 ovsdb/ovsdb-client.c          |    8 +++---
 ovsdb/ovsdb-server.c          |    2 +-
 ovsdb/transaction.c           |    4 +-
 tests/test-aes128.c           |    2 +-
 tests/test-hindex.c           |    2 +-
 tests/test-hmap.c             |    2 +-
 tests/test-netflow.c          |    2 +-
 tests/test-odp.c              |    2 +-
 tests/test-ovsdb.c            |    4 +-
 tests/test-util.c             |   24 +++++++++++-----------
 utilities/ovs-ofctl.c         |   14 ++++++------
 41 files changed, 144 insertions(+), 121 deletions(-)

diff --git a/CodingStyle b/CodingStyle
index 2f24ee3..1597302 100644
--- a/CodingStyle
+++ b/CodingStyle
@@ -394,7 +394,7 @@ from <stdint.h>.
 integer types.  Use the PRId<N>, PRIu<N>, and PRIx<N> macros from
 <inttypes.h> for formatting them with printf() and related functions.
 
-  Use %zu to format size_t with printf().
+  Use "%"PRIuSIZE to format size_t with printf().
 
   Use bit-fields sparingly.  Do not use bit-fields for layout of
 network protocol fields or in other circumstances where the exact
diff --git a/Makefile.am b/Makefile.am
index 08ccb8d..d8e5bca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -195,6 +195,19 @@ config-h-check:
         fi
 .PHONY: config-h-check
 
+# Check for %zu, %zd, %zo, %zx, %zX presence
+ALL_LOCAL += zu-presence-check
+zu-presence-check:
+       @cd $(srcdir); \
+       if test -e .git && (git --version) >/dev/null 2>&1 && \
+          git --no-pager grep -l -E '\%zu|\%zd|\%zo|\%zx|\%zX' `git ls-files | grep '\.c$$'`; \
+       then \
+           echo "See above for list of violations of the rule that"; \
+           echo "Please replace %z size_t modifier with PRIuSIZE."; \
+           exit 1; \
+       fi
+.PHONY: zu-presence-check
+
 # Check that certain data structures are always declared "static".
 ALL_LOCAL += static-check
 static-check:
diff --git a/lib/bundle.c b/lib/bundle.c
index 7d00f87..1c792b6 100644
--- a/lib/bundle.c
+++ b/lib/bundle.c
@@ -165,8 +165,8 @@ bundle_from_openflow(const struct nx_action_bundle *nab,
     }
 
     if (slaves_size < bundle->n_slaves * sizeof(ovs_be16)) {
-        VLOG_WARN_RL(&rl, "Nicira action %"PRIu16" only has %zu bytes "
-                     "allocated for slaves.  %zu bytes are required for "
+        VLOG_WARN_RL(&rl, "Nicira action %"PRIu16" only has %"PRIuSIZE"u bytes "
+                     "allocated for slaves.  %"PRIuSIZE"u bytes are required for "
                      "%"PRIu16" slaves.", subtype, slaves_size,
                      bundle->n_slaves * sizeof(ovs_be16), bundle->n_slaves);
         error = OFPERR_OFPBAC_BAD_LEN;
diff --git a/lib/coverage.c b/lib/coverage.c
index 80316ef..6f24c84 100644
--- a/lib/coverage.c
+++ b/lib/coverage.c
@@ -255,7 +255,7 @@ coverage_read(struct svec *lines)
         }
     }
 
-    svec_add_nocopy(lines, xasprintf("%zu events never hit", n_never_hit));
+    svec_add_nocopy(lines, xasprintf("%"PRIuSIZE"u events never hit", n_never_hit));
     free(totals);
 }
 
diff --git a/lib/hmap.c b/lib/hmap.c
index a559a77..864f8b8 100644
--- a/lib/hmap.c
+++ b/lib/hmap.c
@@ -114,7 +114,7 @@ resize(struct hmap *hmap, size_t new_mask, const char *where)
         if (count > 5) {
             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10);
             COVERAGE_INC(hmap_pathological);
-            VLOG_DBG_RL(&rl, "%s: %d nodes in bucket (%zu nodes, %zu buckets)",
+            VLOG_DBG_RL(&rl, "%s: %d nodes in bucket (%"PRIuSIZE"u nodes, %"PRIuSIZE"u buckets)",
                         where, count, hmap->n, hmap->mask + 1);
         }
     }
diff --git a/lib/multipath.c b/lib/multipath.c
index 4b9e4af..ccaa556 100644
--- a/lib/multipath.c
+++ b/lib/multipath.c
@@ -63,7 +63,7 @@ multipath_from_openflow(const struct nx_action_multipath *nam,
         VLOG_WARN_RL(&rl, "unsupported algorithm %d", (int) mp->algorithm);
         return OFPERR_OFPBAC_BAD_ARGUMENT;
     } else if (mp->dst.n_bits < min_n_bits) {
-        VLOG_WARN_RL(&rl, "multipath action requires at least %zu bits for "
+        VLOG_WARN_RL(&rl, "multipath action requires at least %"PRIuSIZE"u bits for "
                      "%"PRIu32" links", min_n_bits, n_links);
         return OFPERR_OFPBAC_BAD_ARGUMENT;
     }
diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
index 3eb29ea..bd71161 100644
--- a/lib/netdev-bsd.c
+++ b/lib/netdev-bsd.c
@@ -702,8 +702,8 @@ netdev_bsd_send(struct netdev *netdev_, const void *data, size_t size)
                 }
             }
         } else if (retval != size) {
-            VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%zd bytes of "
-                         "%zu) on %s", retval, size, name);
+            VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%"PRIuSIZE"d bytes of "
+                         "%"PRIuSIZE"u) on %s", retval, size, name);
             error = EMSGSIZE;
         } else {
             break;
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index ae0e5a0..0024db9 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -975,8 +975,8 @@ netdev_linux_send(struct netdev *netdev_, const void *data, size_t size)
             }
             return errno;
         } else if (retval != size) {
-            VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%zd bytes of "
-                         "%zu) on %s", retval, size, netdev_get_name(netdev_));
+            VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%"PRIuSIZE"d bytes of "
+                         "%"PRIuSIZE"u) on %s", retval, size, netdev_get_name(netdev_));
             return EMSGSIZE;
         } else {
             return 0;
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index 3420503..ad7f3c9 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -337,7 +337,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait)
     }
 
     if (msg.msg_flags & MSG_TRUNC) {
-        VLOG_ERR_RL(&rl, "truncated message (longer than %zu bytes)",
+        VLOG_ERR_RL(&rl, "truncated message (longer than %"PRIuSIZE"u bytes)",
                     sizeof tail);
         return E2BIG;
     }
@@ -346,7 +346,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait)
     if (retval < sizeof *nlmsghdr
         || nlmsghdr->nlmsg_len < sizeof *nlmsghdr
         || nlmsghdr->nlmsg_len > retval) {
-        VLOG_ERR_RL(&rl, "received invalid nlmsg (%zd bytes < %zu)",
+        VLOG_ERR_RL(&rl, "received invalid nlmsg (%"PRIuSIZE"d bytes < %"PRIuSIZE"u)",
                     retval, sizeof *nlmsghdr);
         return EPROTO;
     }
diff --git a/lib/netlink.c b/lib/netlink.c
index 680c676..965c738 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -66,7 +66,7 @@ nl_msg_nlmsgerr(const struct ofpbuf *msg, int *errorp)
         struct nlmsgerr *err = ofpbuf_at(msg, NLMSG_HDRLEN, sizeof *err);
         int code = EPROTO;
         if (!err) {
-            VLOG_ERR_RL(&rl, "received invalid nlmsgerr (%zd bytes < %zd)",
+            VLOG_ERR_RL(&rl, "received invalid nlmsgerr (%"PRIuSIZE"d bytes < %"PRIuSIZE"d)",
                         msg->size, NLMSG_HDRLEN + sizeof *err);
         } else if (err->error <= 0 && err->error > INT_MIN) {
             code = -err->error;
@@ -690,8 +690,8 @@ nl_attr_validate(const struct nlattr *nla, const struct nl_policy *policy)
     /* Verify length. */
     len = nl_attr_get_size(nla);
     if (len < min_len || len > max_len) {
-        VLOG_DBG_RL(&rl, "attr %"PRIu16" length %zu not in "
-                    "allowed range %zu...%zu", type, len, min_len, max_len);
+        VLOG_DBG_RL(&rl, "attr %"PRIu16" length %"PRIuSIZE"u not in "
+                    "allowed range %"PRIuSIZE"u...%"PRIuSIZE"u", type, len, min_len, max_len);
         return false;
     }
 
@@ -756,7 +756,7 @@ nl_policy_parse(const struct ofpbuf *msg, size_t nla_offset,
     for (i = 0; i < n_attrs; i++) {
         const struct nl_policy *e = &policy[i];
         if (!e->optional && e->type != NL_A_NO_ATTR && !attrs[i]) {
-            VLOG_DBG_RL(&rl, "required attr %zu missing", i);
+            VLOG_DBG_RL(&rl, "required attr %"PRIuSIZE"u missing", i);
             return false;
         }
     }
diff --git a/lib/nx-match.c b/lib/nx-match.c
index 72fc00f..d11863c 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -215,7 +215,7 @@ nx_pull_match__(struct ofpbuf *b, unsigned int match_len, bool strict,
         if (!p) {
             VLOG_DBG_RL(&rl, "nx_match length %u, rounded up to a "
                         "multiple of 8, is longer than space in message (max "
-                        "length %zu)", match_len, b->size);
+                        "length %"PRIuSIZE"u)", match_len, b->size);
             return OFPERR_OFPBMC_BAD_LEN;
         }
     }
@@ -272,7 +272,7 @@ oxm_pull_match__(struct ofpbuf *b, bool strict, struct match *match)
     if (!p) {
         VLOG_DBG_RL(&rl, "oxm length %u, rounded up to a "
                     "multiple of 8, is longer than space in message (max "
-                    "length %zu)", match_len, b->size);
+                    "length %"PRIuSIZE"u)", match_len, b->size);
         return OFPERR_OFPBMC_BAD_LEN;
     }
 
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 62cc638..a777376 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -378,7 +378,7 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
 
     expected_len = odp_action_len(nl_attr_type(a));
     if (expected_len != -2 && nl_attr_get_size(a) != expected_len) {
-        ds_put_format(ds, "bad length %zu, expected %d for: ",
+        ds_put_format(ds, "bad length %"PRIuSIZE"u, expected %d for: ",
                       nl_attr_get_size(a), expected_len);
         format_generic_odp_action(ds, a);
         return;
@@ -977,14 +977,14 @@ format_odp_key_attr(const struct nlattr *a, const struct nlattr *ma,
 
             if (bad_key_len || bad_mask_len) {
                 if (bad_key_len) {
-                    ds_put_format(ds, "(bad key length %zu, expected %d)(",
+                    ds_put_format(ds, "(bad key length %"PRIuSIZE"u, expected %d)(",
                                   nl_attr_get_size(a),
                                   odp_flow_key_attr_len(nl_attr_type(a)));
                 }
                 format_generic_odp_key(a, ds);
                 if (bad_mask_len) {
                     ds_put_char(ds, '/');
-                    ds_put_format(ds, "(bad mask length %zu, expected %d)(",
+                    ds_put_format(ds, "(bad mask length %"PRIuSIZE"u, expected %d)(",
                                   nl_attr_get_size(ma),
                                   odp_flow_key_attr_len(nl_attr_type(ma)));
                 }
@@ -2676,7 +2676,7 @@ parse_flow_nlattrs(const struct nlattr *key, size_t key_len,
         if (len != expected_len && expected_len >= 0) {
             char namebuf[OVS_KEY_ATTR_BUFSIZE];
 
-            VLOG_ERR_RL(&rl, "attribute %s has length %zu but should have "
+            VLOG_ERR_RL(&rl, "attribute %s has length %"PRIuSIZE"u but should have "
                         "length %d", ovs_key_attr_to_string(type, namebuf,
                                                             sizeof namebuf),
                         len, expected_len);
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index e07ea1d..d1793e5 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -248,8 +248,8 @@ dec_ttl_cnt_ids_from_openflow(const struct nx_action_cnt_ids *nac_ids,
     }
 
     if (ids_size < ids->n_controllers * sizeof(ovs_be16)) {
-        VLOG_WARN_RL(&rl, "Nicira action dec_ttl_cnt_ids only has %zu bytes "
-                     "allocated for controller ids.  %zu bytes are required for "
+        VLOG_WARN_RL(&rl, "Nicira action dec_ttl_cnt_ids only has %"PRIuSIZE"u bytes "
+                     "allocated for controller ids.  %"PRIuSIZE"u bytes are required for "
                      "%"PRIu16" controllers.", ids_size,
                      ids->n_controllers * sizeof(ovs_be16), ids->n_controllers);
         return OFPERR_OFPBAC_BAD_LEN;
@@ -711,7 +711,7 @@ ofpacts_pull_openflow_actions(struct ofpbuf *openflow,
     actions = ofpbuf_try_pull(openflow, actions_len);
     if (actions == NULL) {
         VLOG_WARN_RL(&rl, "OpenFlow message actions length %u exceeds "
-                     "remaining message length (%zu)",
+                     "remaining message length (%"PRIuSIZE"u)",
                      actions_len, openflow->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -1715,7 +1715,7 @@ decode_openflow11_instructions(const struct ofp11_instruction insts[],
     }
 
     if (left) {
-        VLOG_WARN_RL(&rl, "bad instruction format at offset %zu",
+        VLOG_WARN_RL(&rl, "bad instruction format at offset %"PRIuSIZE"u",
                      (n_insts - left) * sizeof *inst);
         return OFPERR_OFPBIC_BAD_LEN;
     }
@@ -1754,7 +1754,7 @@ ofpacts_pull_openflow_instructions(struct ofpbuf *openflow,
     instructions = ofpbuf_try_pull(openflow, instructions_len);
     if (instructions == NULL) {
         VLOG_WARN_RL(&rl, "OpenFlow message instructions length %u exceeds "
-                     "remaining message length (%zu)",
+                     "remaining message length (%"PRIuSIZE"u)",
                      instructions_len, openflow->size);
         error = OFPERR_OFPBIC_BAD_LEN;
         goto exit;
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 37e1f4f..9f81326 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -109,7 +109,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
         ds_put_format(string, " cookie=0x%"PRIx64, ntohll(pin.cookie));
     }
 
-    ds_put_format(string, " total_len=%zu in_port=", pin.total_len);
+    ds_put_format(string, " total_len=%"PRIuSIZE"u in_port=", pin.total_len);
     ofputil_format_port(pin.fmd.in_port, string);
 
     if (pin.fmd.tun_id != htonll(0)) {
@@ -142,7 +142,7 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
                   ofputil_packet_in_reason_to_string(pin.reason, reasonbuf,
                                                      sizeof reasonbuf));
 
-    ds_put_format(string, " data_len=%zu", pin.packet_len);
+    ds_put_format(string, " data_len=%"PRIuSIZE"u", pin.packet_len);
     if (pin.buffer_id == UINT32_MAX) {
         ds_put_format(string, " (unbuffered)");
         if (pin.total_len != pin.packet_len) {
@@ -189,7 +189,7 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh,
     ofpacts_format(po.ofpacts, po.ofpacts_len, string);
 
     if (po.buffer_id == UINT32_MAX) {
-        ds_put_format(string, " data_len=%zu", po.packet_len);
+        ds_put_format(string, " data_len=%"PRIuSIZE"u", po.packet_len);
         if (verbosity > 0 && po.packet_len > 0) {
             char *packet = ofp_packet_to_string(po.packet, po.packet_len);
             ds_put_char(string, '\n');
@@ -1533,7 +1533,7 @@ ofp_print_ofpst_port_reply(struct ds *string, const struct ofp_header *oh,
 {
     struct ofpbuf b;
 
-    ds_put_format(string, " %zu ports\n", ofputil_count_port_stats(oh));
+    ds_put_format(string, " %"PRIuSIZE"u ports\n", ofputil_count_port_stats(oh));
     if (verbosity < 1) {
         return;
     }
@@ -1647,7 +1647,7 @@ ofp_print_ofpst_table_reply13(struct ds *string, const struct ofp_header *oh,
     ofpraw_pull_assert(&b);
 
     n = b.size / sizeof *ts;
-    ds_put_format(string, " %zu tables\n", n);
+    ds_put_format(string, " %"PRIuSIZE"u tables\n", n);
     if (verbosity < 1) {
         return;
     }
@@ -1677,7 +1677,7 @@ ofp_print_ofpst_table_reply12(struct ds *string, const struct ofp_header *oh,
     ofpraw_pull_assert(&b);
 
     n = b.size / sizeof *ts;
-    ds_put_format(string, " %zu tables\n", n);
+    ds_put_format(string, " %"PRIuSIZE"u tables\n", n);
     if (verbosity < 1) {
         return;
     }
@@ -1704,7 +1704,7 @@ ofp_print_ofpst_table_reply11(struct ds *string, const struct ofp_header *oh,
     ofpraw_pull_assert(&b);
 
     n = b.size / sizeof *ts;
-    ds_put_format(string, " %zu tables\n", n);
+    ds_put_format(string, " %"PRIuSIZE"u tables\n", n);
     if (verbosity < 1) {
         return;
     }
@@ -1744,7 +1744,7 @@ ofp_print_ofpst_table_reply10(struct ds *string, const struct ofp_header *oh,
     ofpraw_pull_assert(&b);
 
     n = b.size / sizeof *ts;
-    ds_put_format(string, " %zu tables\n", n);
+    ds_put_format(string, " %"PRIuSIZE"u tables\n", n);
     if (verbosity < 1) {
         return;
     }
@@ -1828,7 +1828,7 @@ ofp_print_ofpst_queue_reply(struct ds *string, const struct ofp_header *oh,
 {
     struct ofpbuf b;
 
-    ds_put_format(string, " %zu queues\n", ofputil_count_queue_stats(oh));
+    ds_put_format(string, " %"PRIuSIZE"u queues\n", ofputil_count_queue_stats(oh));
     if (verbosity < 1) {
         return;
     }
@@ -1911,7 +1911,7 @@ ofp_print_echo(struct ds *string, const struct ofp_header *oh, int verbosity)
 {
     size_t len = ntohs(oh->length);
 
-    ds_put_format(string, " %zu bytes of payload\n", len - sizeof *oh);
+    ds_put_format(string, " %"PRIuSIZE"u bytes of payload\n", len - sizeof *oh);
     if (verbosity > 1) {
         ds_put_hex_dump(string, oh + 1, len - sizeof *oh, 0, true);
     }
@@ -2746,7 +2746,7 @@ ofp_to_string(const void *oh_, size_t len, int verbosity)
     if (!len) {
         ds_put_cstr(&string, "OpenFlow message is empty\n");
     } else if (len < sizeof(struct ofp_header)) {
-        ds_put_format(&string, "OpenFlow packet too short (only %zu bytes):\n",
+        ds_put_format(&string, "OpenFlow packet too short (only %"PRIuSIZE"u bytes):\n",
                       len);
     } else if (ntohs(oh->length) > len) {
         enum ofperr error;
@@ -2759,11 +2759,11 @@ ofp_to_string(const void *oh_, size_t len, int verbosity)
         }
 
         ds_put_format(&string,
-                      "(***truncated to %zu bytes from %"PRIu16"***)\n",
+                      "(***truncated to %"PRIuSIZE"u bytes from %"PRIu16"***)\n",
                       len, ntohs(oh->length));
     } else if (ntohs(oh->length) < len) {
         ds_put_format(&string,
-                      "(***only uses %"PRIu16" bytes out of %zu***)\n",
+                      "(***only uses %"PRIu16" bytes out of %"PRIuSIZE"u***)\n",
                       ntohs(oh->length), len);
     } else {
         enum ofperr error;
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index d8a9754..747bbee 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1901,7 +1901,7 @@ ofputil_decode_meter_config(struct ofpbuf *msg,
     omc = ofpbuf_try_pull(msg, sizeof *omc);
     if (!omc) {
         VLOG_WARN_RL(&bad_ofmsg_rl,
-                     "OFPMP_METER_CONFIG reply has %zu leftover bytes at end",
+                     "OFPMP_METER_CONFIG reply has %"PRIuSIZE"u leftover bytes at end",
                      msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -1977,7 +1977,7 @@ ofputil_decode_meter_stats(struct ofpbuf *msg,
     oms = ofpbuf_try_pull(msg, sizeof *oms);
     if (!oms) {
         VLOG_WARN_RL(&bad_ofmsg_rl,
-                     "OFPMP_METER reply has %zu leftover bytes at end",
+                     "OFPMP_METER reply has %"PRIuSIZE"u leftover bytes at end",
                      msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -2668,7 +2668,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
 
         ofs = ofpbuf_try_pull(msg, sizeof *ofs);
         if (!ofs) {
-            VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %zu leftover "
+            VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %"PRIuSIZE"u leftover "
                          "bytes at end", msg->size);
             return EINVAL;
         }
@@ -2676,7 +2676,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         length = ntohs(ofs->length);
         if (length < sizeof *ofs) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply claims invalid "
-                         "length %zu", length);
+                         "length %"PRIuSIZE"u", length);
             return EINVAL;
         }
 
@@ -2718,7 +2718,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
 
         ofs = ofpbuf_try_pull(msg, sizeof *ofs);
         if (!ofs) {
-            VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %zu leftover "
+            VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %"PRIuSIZE"u leftover "
                          "bytes at end", msg->size);
             return EINVAL;
         }
@@ -2726,7 +2726,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         length = ntohs(ofs->length);
         if (length < sizeof *ofs) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply claims invalid "
-                         "length %zu", length);
+                         "length %"PRIuSIZE"u", length);
             return EINVAL;
         }
 
@@ -2754,7 +2754,7 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
 
         nfs = ofpbuf_try_pull(msg, sizeof *nfs);
         if (!nfs) {
-            VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW reply has %zu leftover "
+            VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW reply has %"PRIuSIZE"u leftover "
                          "bytes at end", msg->size);
             return EINVAL;
         }
@@ -2762,8 +2762,8 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
         length = ntohs(nfs->length);
         match_len = ntohs(nfs->match_len);
         if (length < sizeof *nfs + ROUND_UP(match_len, 8)) {
-            VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW reply with match_len=%zu "
-                         "claims invalid length %zu", match_len, length);
+            VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW reply with match_len=%"PRIuSIZE"u "
+                         "claims invalid length %"PRIuSIZE"u", match_len, length);
             return EINVAL;
         }
         if (nx_pull_match(msg, match_len, &fs->match, NULL, NULL)) {
@@ -4478,7 +4478,7 @@ ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
 
     nfmr = ofpbuf_try_pull(msg, sizeof *nfmr);
     if (!nfmr) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR request has %zu "
+        VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR request has %"PRIuSIZE"u "
                      "leftover bytes at end", msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -4632,7 +4632,7 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
     }
 
 bad_len:
-    VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR reply has %zu "
+    VLOG_WARN_RL(&bad_ofmsg_rl, "NXST_FLOW_MONITOR reply has %"PRIuSIZE"u "
                  "leftover bytes at end", msg->size);
     return OFPERR_OFPBRC_BAD_LEN;
 }
@@ -5656,7 +5656,7 @@ ofputil_decode_port_stats(struct ofputil_port_stats *ps, struct ofpbuf *msg)
     }
 
  bad_len:
-    VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_PORT reply has %zu leftover "
+    VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_PORT reply has %"PRIuSIZE"u leftover "
                  "bytes at end", msg->size);
     return OFPERR_OFPBRC_BAD_LEN;
 }
@@ -5966,13 +5966,13 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
     }
 
     if (!ogs11) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %zu leftover bytes at end",
+        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %"PRIuSIZE"u leftover bytes at end",
                      ofpraw_get_name(raw), msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
     length = ntohs(ogs11->length);
     if (length < sizeof base_len) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply claims invalid length %zu",
+        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply claims invalid length %"PRIuSIZE"u",
                      ofpraw_get_name(raw), length);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -5985,7 +5985,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
     gs->n_buckets = (length - base_len) / sizeof *obc;
     obc = ofpbuf_try_pull(msg, gs->n_buckets * sizeof *obc);
     if (!obc) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %zu leftover bytes at end",
+        VLOG_WARN_RL(&bad_ofmsg_rl, "%s reply has %"PRIuSIZE"u leftover bytes at end",
                      ofpraw_get_name(raw), msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -6054,18 +6054,18 @@ ofputil_pull_buckets(struct ofpbuf *msg, size_t buckets_length,
               ? ofpbuf_try_pull(msg, sizeof *ob)
               : NULL);
         if (!ob) {
-            VLOG_WARN_RL(&bad_ofmsg_rl, "buckets end with %zu leftover bytes",
+            VLOG_WARN_RL(&bad_ofmsg_rl, "buckets end with %"PRIuSIZE"u leftover bytes",
                          buckets_length);
         }
 
         ob_len = ntohs(ob->len);
         if (ob_len < sizeof *ob) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message bucket length "
-                         "%zu is not valid", ob_len);
+                         "%"PRIuSIZE"u is not valid", ob_len);
             return OFPERR_OFPGMFC_BAD_BUCKET;
         } else if (ob_len > buckets_length) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message bucket length "
-                         "%zu exceeds remaining buckets data size %zu",
+                         "%"PRIuSIZE"u exceeds remaining buckets data size %"PRIuSIZE"u",
                          ob_len, buckets_length);
             return OFPERR_OFPGMFC_BAD_BUCKET;
         }
@@ -6124,7 +6124,7 @@ ofputil_decode_group_desc_reply(struct ofputil_group_desc *gd,
 
     ogds = ofpbuf_try_pull(msg, sizeof *ogds);
     if (!ogds) {
-        VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST11_GROUP_DESC reply has %zu "
+        VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST11_GROUP_DESC reply has %"PRIuSIZE"u "
                      "leftover bytes at end", msg->size);
         return OFPERR_OFPBRC_BAD_LEN;
     }
@@ -6134,7 +6134,7 @@ ofputil_decode_group_desc_reply(struct ofputil_group_desc *gd,
     length = ntohs(ogds->length);
     if (length < sizeof *ogds || length - sizeof *ogds > msg->size) {
         VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST11_GROUP_DESC reply claims invalid "
-                     "length %zu", length);
+                     "length %"PRIuSIZE"u", length);
         return OFPERR_OFPBRC_BAD_LEN;
     }
 
@@ -6450,7 +6450,7 @@ ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg)
     }
 
  bad_len:
-    VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_QUEUE reply has %zu leftover "
+    VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_QUEUE reply has %"PRIuSIZE"u leftover "
                  "bytes at end", msg->size);
     return OFPERR_OFPBRC_BAD_LEN;
 }
diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
index d578ab5..443b406 100644
--- a/lib/ofpbuf.c
+++ b/lib/ofpbuf.c
@@ -553,7 +553,7 @@ ofpbuf_to_string(const struct ofpbuf *b, size_t maxbytes)
     struct ds s;
 
     ds_init(&s);
-    ds_put_format(&s, "size=%zu, allocated=%zu, head=%zu, tail=%zu\n",
+    ds_put_format(&s, "size=%"PRIuSIZE"u, allocated=%"PRIuSIZE"u, head=%"PRIuSIZE"u, tail=%"PRIuSIZE"u\n",
                   b->size, b->allocated,
                   ofpbuf_headroom(b), ofpbuf_tailroom(b));
     ds_put_hex_dump(&s, b->data, MIN(b->size, maxbytes), 0, false);
diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
index ade1971..8b5bcd3 100644
--- a/lib/ovsdb-data.c
+++ b/lib/ovsdb-data.c
@@ -741,12 +741,12 @@ check_string_constraints(const char *s,
     if (n_chars < c->minLen) {
         return ovsdb_error(
             "constraint violation",
-            "\"%s\" length %zu is less than minimum allowed "
+            "\"%s\" length %"PRIuSIZE"u is less than minimum allowed "
             "length %u", s, n_chars, c->minLen);
     } else if (n_chars > c->maxLen) {
         return ovsdb_error(
             "constraint violation",
-            "\"%s\" length %zu is greater than maximum allowed "
+            "\"%s\" length %"PRIuSIZE"u is greater than maximum allowed "
             "length %u", s, n_chars, c->maxLen);
     }
 
@@ -1224,7 +1224,7 @@ ovsdb_datum_from_json__(struct ovsdb_datum *datum,
         n = inner->u.array.n;
         if (n < type->n_min || n > type->n_max) {
             return ovsdb_syntax_error(json, NULL, "%s must have %u to "
-                                      "%u members but %zu are present",
+                                      "%u members but %"PRIuSIZE"u are present",
                                       class, type->n_min, type->n_max, n);
         }
 
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 3366523..29036e5 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -2105,7 +2105,7 @@ ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn,
 
     if (txn->inc_index + 2 > results->n) {
         VLOG_WARN_RL(&syntax_rl, "reply does not contain enough operations "
-                     "for increment (has %zu, needs %u)",
+                     "for increment (has %"PRIuSIZE"u, needs %u)",
                      results->n, txn->inc_index + 2);
         return false;
     }
@@ -2130,7 +2130,7 @@ ovsdb_idl_txn_process_inc_reply(struct ovsdb_idl_txn *txn,
         return false;
     }
     if (rows->u.array.n != 1) {
-        VLOG_WARN_RL(&syntax_rl, "\"select\" reply \"rows\" has %zu elements "
+        VLOG_WARN_RL(&syntax_rl, "\"select\" reply \"rows\" has %"PRIuSIZE"u elements "
                      "instead of 1",
                      rows->u.array.n);
         return false;
@@ -2160,7 +2160,7 @@ ovsdb_idl_txn_process_insert_reply(struct ovsdb_idl_txn_insert *insert,
 
     if (insert->op_index >= results->n) {
         VLOG_WARN_RL(&syntax_rl, "reply does not contain enough operations "
-                     "for insert (has %zu, needs %u)",
+                     "for insert (has %"PRIuSIZE"u, needs %u)",
                      results->n, insert->op_index);
         return false;
     }
diff --git a/lib/ovsdb-parser.c b/lib/ovsdb-parser.c
index 77460a8..d98f56c 100644
--- a/lib/ovsdb-parser.c
+++ b/lib/ovsdb-parser.c
@@ -142,7 +142,7 @@ ovsdb_parser_finish(struct ovsdb_parser *parser)
                     if (n_unused > 1) {
                         ovsdb_parser_raise_error(
                             parser,
-                            "Member '%s' and %zu other member%s "
+                            "Member '%s' and %"PRIuSIZE"u other member%s "
                             "are present but not allowed here.",
                             node->name, n_unused - 1, n_unused > 2 ? "s" : "");
                     } else {
diff --git a/lib/pcap-file.c b/lib/pcap-file.c
index 700cdea..9c4167b 100644
--- a/lib/pcap-file.c
+++ b/lib/pcap-file.c
@@ -156,7 +156,7 @@ pcap_read(FILE *file, struct ofpbuf **bufp)
                                 ((len & 0x0000ff00) <<  8) |
                                 ((len & 0x000000ff) << 24));
         if (swapped_len > 0xffff) {
-            VLOG_WARN("bad packet length %zu or %"PRIu32" "
+            VLOG_WARN("bad packet length %"PRIuSIZE"u or %"PRIu32" "
                       "reading pcap file",
                       len, swapped_len);
             return EPROTO;
diff --git a/lib/socket-util.c b/lib/socket-util.c
index cd0affc..e1c87cc 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -473,7 +473,7 @@ make_sockaddr_un(const char *name, struct sockaddr_un *un, socklen_t *un_len,
             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
 
             VLOG_WARN_RL(&rl, "Unix socket name %s is longer than maximum "
-                         "%zu bytes", name, MAX_UN_LEN);
+                         "%"PRIuSIZE"u bytes", name, MAX_UN_LEN);
             return error;
         }
 
@@ -1050,7 +1050,7 @@ getsockopt_int(int fd, int level, int option, const char *optname, int *valuep)
         VLOG_ERR_RL(&rl, "getsockopt(%s): %s", optname, ovs_strerror(error));
     } else if (len != sizeof value) {
         error = EINVAL;
-        VLOG_ERR_RL(&rl, "getsockopt(%s): value is %u bytes (expected %zu)",
+        VLOG_ERR_RL(&rl, "getsockopt(%s): value is %u bytes (expected %"PRIuSIZE"u)",
                     optname, (unsigned int) len, sizeof value);
     } else {
         error = 0;
@@ -1419,7 +1419,7 @@ recv_data_and_fds(int sock,
 
             ovs_assert(n_fds > 0);
             if (n_fds > SOUTIL_MAX_FDS) {
-                VLOG_ERR("%zu fds received but only %d supported",
+                VLOG_ERR("%"PRIuSIZE"u fds received but only %d supported",
                          n_fds, SOUTIL_MAX_FDS);
                 for (i = 0; i < n_fds; i++) {
                     close(fds_data[i]);
diff --git a/lib/stp.c b/lib/stp.c
index 6e1efd0..492954e 100644
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -727,7 +727,7 @@ stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size)
     }
 
     if (bpdu_size < sizeof(struct stp_bpdu_header)) {
-        VLOG_WARN("%s: received runt %zu-byte BPDU", stp->name, bpdu_size);
+        VLOG_WARN("%s: received runt %"PRIuSIZE"u-byte BPDU", stp->name, bpdu_size);
         p->error_count++;
         goto out;
     }
@@ -747,7 +747,7 @@ stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size)
     switch (header->bpdu_type) {
     case STP_TYPE_CONFIG:
         if (bpdu_size < sizeof(struct stp_config_bpdu)) {
-            VLOG_WARN("%s: received config BPDU with invalid size %zu",
+            VLOG_WARN("%s: received config BPDU with invalid size %"PRIuSIZE"u",
                       stp->name, bpdu_size);
             p->error_count++;
             goto out;
@@ -757,7 +757,7 @@ stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size)
 
     case STP_TYPE_TCN:
         if (bpdu_size != sizeof(struct stp_tcn_bpdu)) {
-            VLOG_WARN("%s: received TCN BPDU with invalid size %zu",
+            VLOG_WARN("%s: received TCN BPDU with invalid size %"PRIuSIZE"u",
                       stp->name, bpdu_size);
             p->error_count++;
             goto out;
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 1e748c0..b3622ae 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -1247,7 +1247,7 @@ stream_ssl_set_ca_cert_file__(const char *file_name,
         for (i = 0; i < n_certs; i++) {
             /* SSL_CTX_add_client_CA makes a copy of the relevant data. */
             if (SSL_CTX_add_client_CA(ctx, certs[i]) != 1) {
-                VLOG_ERR("failed to add client certificate %zu from %s: %s",
+                VLOG_ERR("failed to add client certificate %"PRIuSIZE"u from %s: %s",
                          i, file_name,
                          ERR_error_string(ERR_get_error(), NULL));
             } else {
@@ -1369,7 +1369,7 @@ ssl_protocol_cb(int write_p, int version OVS_UNUSED, int content_type,
         ds_put_format(&details, "type %d", content_type);
     }
 
-    VLOG_DBG("%s%u%s%s %s (%zu bytes)",
+    VLOG_DBG("%s%u%s%s %s (%"PRIuSIZE"u bytes)",
              sslv->type == CLIENT ? "client" : "server",
              sslv->session_nr, write_p ? "-->" : "<--",
              stream_get_name(&sslv->stream), ds_cstr(&details), len);
diff --git a/lib/util.h b/lib/util.h
index acb2d8f..457b7b7 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -212,6 +212,16 @@ is_pow2(uintmax_t x)
  * (void *). This is to suppress the alignment warning issued by clang. */
 #define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR))
 
+/*
+ * Use "%"PRIuSIZE to format size_t with printf().
+ * size_t specification if compiling on WIN32 for more information see
+ * http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. */
+#ifdef _WIN32
+#define PRIuSIZE "I"
+#else
+#define PRIuSIZE "z"
+#endif
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index dba3d3b..828ae13 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -462,7 +462,7 @@ classify_upcall(const struct upcall *upcall)
     userdata_len = nl_attr_get_size(dpif_upcall->userdata);
     if (userdata_len < sizeof cookie.type
         || userdata_len > sizeof cookie) {
-        VLOG_WARN_RL(&rl, "action upcall cookie has unexpected size %zu",
+        VLOG_WARN_RL(&rl, "action upcall cookie has unexpected size %"PRIuSIZE"u",
                      userdata_len);
         return BAD_UPCALL;
     }
@@ -482,7 +482,7 @@ classify_upcall(const struct upcall *upcall)
         return IPFIX_UPCALL;
     } else {
         VLOG_WARN_RL(&rl, "invalid user cookie of type %"PRIu16
-                     " and size %zu", cookie.type, userdata_len);
+                     " and size %"PRIuSIZE"u", cookie.type, userdata_len);
         return BAD_UPCALL;
     }
 }
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c1c206b..c3d5195 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5241,7 +5241,7 @@ trace_format_regs(struct ds *result, int level, const char *title,
     ds_put_char_multiple(result, '\t', level);
     ds_put_format(result, "%s:", title);
     for (i = 0; i < FLOW_N_REGS; i++) {
-        ds_put_format(result, " reg%zu=0x%"PRIx32, i, trace->flow.regs[i]);
+        ds_put_format(result, " reg%"PRIuSIZE"u=0x%"PRIx32, i, trace->flow.regs[i]);
     }
     ds_put_char(result, '\n');
 }
@@ -5734,7 +5734,7 @@ dpif_show_backer(const struct dpif_backer *backer, struct ds *ds)
 
     ds_put_format(ds, "%s: hit:%"PRIu64" missed:%"PRIu64"\n",
                   dpif_name(backer->dpif), n_hit, n_missed);
-    ds_put_format(ds, "\tflows: cur: %zu, avg: %u, max: %u,"
+    ds_put_format(ds, "\tflows: cur: %"PRIuSIZE"u, avg: %u, max: %u,"
                   " life span: %lldms\n", hmap_count(&backer->subfacets),
                   backer->avg_n_subfacet, backer->max_n_subfacet,
                   backer->avg_subfacet_life);
@@ -5845,7 +5845,7 @@ ofproto_unixctl_dpif_dump_megaflows(struct unixctl_conn *conn,
     CLS_CURSOR_FOR_EACH (facet, cr, &cursor) {
         cls_rule_format(&facet->cr, &ds);
         ds_put_cstr(&ds, ", ");
-        ds_put_format(&ds, "n_subfacets:%zu, ", list_size(&facet->subfacets));
+        ds_put_format(&ds, "n_subfacets:%"PRIuSIZE"u, ", list_size(&facet->subfacets));
         ds_put_format(&ds, "used:%.3fs, ", (now - facet->used) / 1000.0);
         ds_put_cstr(&ds, "Datapath actions: ");
         if (facet->xout.slow) {
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 5cd6b1e..8aa11d6 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3061,7 +3061,7 @@ handle_table_stats_request(struct ofconn *ofconn,
     ots = xcalloc(p->n_tables, sizeof *ots);
     for (i = 0; i < p->n_tables; i++) {
         ots[i].table_id = i;
-        sprintf(ots[i].name, "table%zu", i);
+        sprintf(ots[i].name, "table%"PRIuSIZE"u", i);
         ots[i].match = htonll(OFPXMT13_MASK);
         ots[i].wildcards = htonll(OFPXMT13_MASK);
         ots[i].write_actions = htonl(OFPAT11_OUTPUT);
diff --git a/ovsdb/execution.c b/ovsdb/execution.c
index 027e9e1..eaa760c 100644
--- a/ovsdb/execution.c
+++ b/ovsdb/execution.c
@@ -140,7 +140,7 @@ ovsdb_execute(struct ovsdb *db, const struct ovsdb_session *session,
 
         /* Parse and execute operation. */
         ovsdb_parser_init(&parser, operation,
-                          "ovsdb operation %zu of %zu", i, n_operations);
+                          "ovsdb operation %"PRIuSIZE"u of %"PRIuSIZE"u", i, n_operations);
         op = ovsdb_parser_member(&parser, "op", OP_ID);
         result = json_object_create();
         if (op) {
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 4cba4d9..9a3e01f 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -482,8 +482,8 @@ ovsdb_jsonrpc_session_run(struct ovsdb_jsonrpc_session *s)
 
         monitor_length = ovsdb_jsonrpc_monitor_json_length_all(s);
         if (backlog > s->reply_backlog + monitor_length * 2) {
-            VLOG_INFO("%s: %zu bytes backlogged but a complete replica "
-                      "would only take %zu bytes, disconnecting",
+            VLOG_INFO("%s: %"PRIuSIZE"u bytes backlogged but a complete replica "
+                      "would only take %"PRIuSIZE"u bytes, disconnecting",
                       jsonrpc_session_get_name(s->js),
                       backlog - s->reply_backlog, monitor_length);
             jsonrpc_session_force_reconnect(s->js);
diff --git a/ovsdb/log.c b/ovsdb/log.c
index 1316025..7804c05 100644
--- a/ovsdb/log.c
+++ b/ovsdb/log.c
@@ -356,7 +356,7 @@ ovsdb_log_write(struct ovsdb_log *file, struct json *json)
 
     /* Compose header. */
     sha1_bytes(json_string, length, sha1);
-    snprintf(header, sizeof header, "%s%zu "SHA1_FMT"\n",
+    snprintf(header, sizeof header, "%s%"PRIuSIZE"u "SHA1_FMT"\n",
              magic, length, SHA1_ARGS(sha1));
 
     /* Write. */
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 67d09cb..af24cb6 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -387,7 +387,7 @@ fetch_dbs(struct jsonrpc *rpc, struct svec *dbs)
         const struct json *name = reply->result->u.array.elems[i];
 
         if (name->type != JSON_STRING) {
-            ovs_fatal(0, "list_dbs response %zu is not string", i);
+            ovs_fatal(0, "list_dbs response %"PRIuSIZE"u is not string", i);
         }
         svec_add(dbs, name->u.string);
     }
@@ -847,7 +847,7 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows)
         struct shash *row;
 
         if (rows->elems[y]->type != JSON_OBJECT) {
-            ovs_fatal(0,  "row %zu in table %s response is not a JSON object: "
+            ovs_fatal(0,  "row %"PRIuSIZE"u in table %s response is not a JSON object: "
                       "%s", y, ts->name, json_to_string(rows->elems[y], 0));
         }
         row = json_object(rows->elems[y]);
@@ -856,7 +856,7 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows)
         for (x = 0; x < n_columns; x++) {
             const struct json *json = shash_find_data(row, columns[x]->name);
             if (!json) {
-                ovs_fatal(0, "row %zu in table %s response lacks %s column",
+                ovs_fatal(0, "row %"PRIuSIZE"u in table %s response lacks %s column",
                           y, ts->name, columns[x]->name);
             }
 
@@ -945,7 +945,7 @@ do_dump(struct jsonrpc *rpc, const char *database,
     /* Print database contents. */
     if (reply->result->type != JSON_ARRAY
         || reply->result->u.array.n != n_tables) {
-        ovs_fatal(0, "reply is not array of %zu elements: %s",
+        ovs_fatal(0, "reply is not array of %"PRIuSIZE"u elements: %s",
                   n_tables, json_to_string(reply->result, 0));
     }
     for (i = 0; i < n_tables; i++) {
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index f64122e..6a5a421 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -530,7 +530,7 @@ get_datum(struct ovsdb_row *row, const char *column_name,
         if (!VLOG_DROP_DBG(&rl)) {
             char *type_name = ovsdb_type_to_english(&column->type);
             VLOG_DBG("Table `%s' column `%s' has type %s, not expected "
-                     "key type %s, value type %s, max elements %zd.",
+                     "key type %s, value type %s, max elements %"PRIuSIZE"d.",
                      schema->name, column_name, type_name,
                      ovsdb_atomic_type_to_string(key_type),
                      ovsdb_atomic_type_to_string(value_type),
diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index 646163a..3d6bd18 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -295,7 +295,7 @@ check_ref_count(struct ovsdb_txn *txn OVS_UNUSED, struct ovsdb_txn_row *r)
     } else {
         return ovsdb_error("referential integrity violation",
                            "cannot delete %s row "UUID_FMT" because "
-                           "of %zu remaining reference(s)",
+                           "of %"PRIuSIZE"u remaining reference(s)",
                            r->table->schema->name, UUID_ARGS(&r->uuid),
                            r->n_refs);
     }
@@ -614,7 +614,7 @@ check_max_rows(struct ovsdb_txn *txn)
         if (n_rows > max_rows) {
             return ovsdb_error("constraint violation",
                                "transaction causes \"%s\" table to contain "
-                               "%zu rows, greater than the schema-defined "
+                               "%"PRIuSIZE"u rows, greater than the schema-defined "
                                "limit of %u row(s)",
                                t->table->schema->name, n_rows, max_rows);
         }
diff --git a/tests/test-aes128.c b/tests/test-aes128.c
index 19874b1..566a471 100644
--- a/tests/test-aes128.c
+++ b/tests/test-aes128.c
@@ -38,7 +38,7 @@ hex_to_uint8(const char *input, uint8_t *output, size_t n)
     return;
 
 error:
-    ovs_fatal(0, "\"%s\" is not exactly %zu hex digits", input, n * 2);
+    ovs_fatal(0, "\"%s\" is not exactly %"PRIuSIZE"u hex digits", input, n * 2);
 }
 
 int
diff --git a/tests/test-hindex.c b/tests/test-hindex.c
index f0a8b93..f5adaf5 100644
--- a/tests/test-hindex.c
+++ b/tests/test-hindex.c
@@ -137,7 +137,7 @@ print_hindex(const char *name, struct hindex *hindex)
 
     printf("%s:", name);
     HINDEX_FOR_EACH (e, node, hindex) {
-        printf(" %d(%zu)", e->value, e->node.hash & hindex->mask);
+        printf(" %d(%"PRIuSIZE"u)", e->value, e->node.hash & hindex->mask);
     }
     printf("\n");
 }
diff --git a/tests/test-hmap.c b/tests/test-hmap.c
index 6102be3..18b6d07 100644
--- a/tests/test-hmap.c
+++ b/tests/test-hmap.c
@@ -125,7 +125,7 @@ print_hmap(const char *name, struct hmap *hmap)
 
     printf("%s:", name);
     HMAP_FOR_EACH (e, node, hmap) {
-        printf(" %d(%zu)", e->value, e->node.hash & hmap->mask);
+        printf(" %d("%"PRIuSIZE"u)", e->value, e->node.hash & hmap->mask);
     }
     printf("\n");
 }
diff --git a/tests/test-netflow.c b/tests/test-netflow.c
index e995852..b9b5412 100644
--- a/tests/test-netflow.c
+++ b/tests/test-netflow.c
@@ -162,7 +162,7 @@ print_netflow(struct ofpbuf *buf)
     }
 
     if (buf->size) {
-        printf("%zu extra bytes after last record\n", buf->size);
+        printf("%"PRIuSIZE"u extra bytes after last record\n", buf->size);
     }
 }
 
diff --git a/tests/test-odp.c b/tests/test-odp.c
index 471851b..0d26ffd 100644
--- a/tests/test-odp.c
+++ b/tests/test-odp.c
@@ -78,7 +78,7 @@ parse_keys(bool wc_keys)
             odp_flow_key_from_flow(&odp_key, &flow, flow.in_port.odp_port);
 
             if (odp_key.size > ODPUTIL_FLOW_KEY_BYTES) {
-                printf ("too long: %zu > %d\n",
+                printf ("too long: %"PRIuSIZE"u > %d\n",
                         odp_key.size, ODPUTIL_FLOW_KEY_BYTES);
                 exit_code = 1;
             }
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 10d434e..d95e86a 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -945,7 +945,7 @@ do_execute_mutations(int argc OVS_UNUSED, char *argv[])
             row = ovsdb_row_clone(rows[j]);
             error = ovsdb_mutation_set_execute(row, &sets[i]);
 
-            printf("row %zu: ", j);
+            printf("row %"PRIuSIZE"u: ", j);
             if (error) {
                 print_and_free_ovsdb_error(error);
             } else {
@@ -1680,7 +1680,7 @@ parse_uuids(const struct json *json, struct ovsdb_symbol_table *symtab,
     struct uuid uuid;
 
     if (json->type == JSON_STRING && uuid_from_string(&uuid, json->u.string)) {
-        char *name = xasprintf("#%zu#", *n);
+        char *name = xasprintf("#%"PRIuSIZE"u#", *n);
         fprintf(stderr, "%s = "UUID_FMT"\n", name, UUID_ARGS(&uuid));
         ovsdb_symbol_table_put(symtab, name, &uuid, false);
         free(name);
diff --git a/tests/test-util.c b/tests/test-util.c
index 7183f46..f606dc0 100644
--- a/tests/test-util.c
+++ b/tests/test-util.c
@@ -794,31 +794,31 @@ test_ovs_scan(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     ovs_assert(pd == 1);
     ovs_assert(pd2 == 23);
 
-    ovs_assert(ovs_scan("123", "%zd", &sz));
+    ovs_assert(ovs_scan("123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 123);
-    ovs_assert(ovs_scan("0", "%zd", &sz));
+    ovs_assert(ovs_scan("0", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 0);
-    ovs_assert(!ovs_scan("123", "%zd%zd", &sz, &sz2));
-    ovs_assert(ovs_scan("+123", "%zd", &sz));
+    ovs_assert(!ovs_scan("123", "%"PRIuSIZE"d%"PRIuSIZE"d", &sz, &sz2));
+    ovs_assert(ovs_scan("+123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 123);
-    ovs_assert(ovs_scan("-123", "%zd", &sz));
+    ovs_assert(ovs_scan("-123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == -123);
-    ovs_assert(ovs_scan("0123", "%zd", &sz));
+    ovs_assert(ovs_scan("0123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 123);
-    ovs_assert(ovs_scan(" 123", "%zd", &sz));
+    ovs_assert(ovs_scan(" 123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 123);
-    ovs_assert(ovs_scan("0x123", "%zd", &sz));
+    ovs_assert(ovs_scan("0x123", "%"PRIuSIZE"d", &sz));
     ovs_assert(sz == 0);
-    ovs_assert(ovs_scan("123", "%2zd %zd", &sz, &sz2));
+    ovs_assert(ovs_scan("123", "%2zd %"PRIuSIZE"d", &sz, &sz2));
     ovs_assert(sz == 12);
     ovs_assert(sz2 == 3);
-    ovs_assert(ovs_scan("+123", "%2zd %zd", &sz, &sz2));
+    ovs_assert(ovs_scan("+123", "%2zd %"PRIuSIZE"d", &sz, &sz2));
     ovs_assert(sz == 1);
     ovs_assert(sz2 == 23);
-    ovs_assert(ovs_scan("-123", "%2zd %zd", &sz, &sz2));
+    ovs_assert(ovs_scan("-123", "%2zd %"PRIuSIZE"d", &sz, &sz2));
     ovs_assert(sz == -1);
     ovs_assert(sz2 == 23);
-    ovs_assert(ovs_scan("0123", "%2zd %zd", &sz, &sz2));
+    ovs_assert(ovs_scan("0123", "%2zd %"PRIuSIZE"d", &sz, &sz2));
     ovs_assert(sz == 1);
     ovs_assert(sz2 == 23);
 
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 1d1b47f..d2eb24f 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1805,7 +1805,7 @@ ofctl_ofp_parse(int argc OVS_UNUSED, char *argv[])
 
         length = ntohs(oh->length);
         if (length < sizeof *oh) {
-            ovs_fatal(0, "%s: %zu-byte message is too short for OpenFlow",
+            ovs_fatal(0, "%s: %"PRIuSIZE"u-byte message is too short for OpenFlow",
                       filename, length);
         }
 
@@ -1835,7 +1835,7 @@ ofctl_ping(int argc, char *argv[])
 
     payload = argc > 2 ? atoi(argv[2]) : 64;
     if (payload > max_payload) {
-        ovs_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
+        ovs_fatal(0, "payload must be between 0 and %"PRIuSIZE"u bytes", max_payload);
     }
 
     open_vconn(argv[1], &vconn);
@@ -1863,7 +1863,7 @@ ofctl_ping(int argc, char *argv[])
             printf("Reply:\n");
             ofp_print(stdout, reply, reply->size, verbosity + 2);
         }
-        printf("%zu bytes from %s: xid=%08"PRIx32" time=%.1f ms\n",
+        printf("%"PRIuSIZE"u bytes from %s: xid=%08"PRIx32" time=%.1f ms\n",
                reply->size, argv[1], ntohl(rpy_hdr->xid),
                    (1000*(double)(end.tv_sec - start.tv_sec))
                    + (.001*(end.tv_usec - start.tv_usec)));
@@ -1886,7 +1886,7 @@ ofctl_benchmark(int argc OVS_UNUSED, char *argv[])
 
     payload_size = atoi(argv[2]);
     if (payload_size > max_payload) {
-        ovs_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
+        ovs_fatal(0, "payload must be between 0 and %"PRIuSIZE"u bytes", max_payload);
     }
     message_size = sizeof(struct ofp_header) + payload_size;
 
@@ -2875,7 +2875,7 @@ ofctl_parse_ofp10_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
             ovs_fatal(0, "Trailing garbage in hex data");
         }
         if (match_expout.size != sizeof(struct ofp10_match)) {
-            ovs_fatal(0, "Input is %zu bytes, expected %zu",
+            ovs_fatal(0, "Input is %"PRIuSIZE"u bytes, expected %"PRIuSIZE"u",
                       match_expout.size, sizeof(struct ofp10_match));
         }
 
@@ -2890,7 +2890,7 @@ ofctl_parse_ofp10_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
             ovs_fatal(0, "Trailing garbage in hex data");
         }
         if (match_in.size != sizeof(struct ofp10_match)) {
-            ovs_fatal(0, "Input is %zu bytes, expected %zu",
+            ovs_fatal(0, "Input is %"PRIuSIZE"u bytes, expected %"PRIuSIZE"u",
                       match_in.size, sizeof(struct ofp10_match));
         }
 
@@ -2939,7 +2939,7 @@ ofctl_parse_ofp11_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
             ovs_fatal(0, "Trailing garbage in hex data");
         }
         if (match_in.size != sizeof(struct ofp11_match)) {
-            ovs_fatal(0, "Input is %zu bytes, expected %zu",
+            ovs_fatal(0, "Input is %"PRIuSIZE"u bytes, expected %"PRIuSIZE"u",
                       match_in.size, sizeof(struct ofp11_match));
         }
		 
---

Kind Regards,
Alin.
________________________________________
From: Ben Pfaff [blp at nicira.com]
Sent: Monday, November 25, 2013 10:59 PM
To: Alin Serdean
Cc: Alessandro Pilotti; dev at openvswitch.org
Subject: Re: [ovs-dev] Windows port status

On Sun, Nov 24, 2013 at 09:39:12PM +0000, Alin Serdean wrote:
> Bellow is the patch for the %z modifier.
>
> Please take a closer look over the Makefile and comments (I hope they are inline with your previous ones :) ).

That's much better, thanks.

Can you provide a Signed-off-by line?  SubmittingPatches explains the
meaning and syntax.

Thanks,

Ben.



More information about the dev mailing list