Merge branch 'mainstream'
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 26 Nov 2013 15:56:56 +0000 (16:56 +0100)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 26 Nov 2013 15:56:56 +0000 (16:56 +0100)
48 files changed:
AUTHORS
CodingStyle
Makefile.am
include/sparse/sys/socket.h
lib/bfd.c
lib/bond.c
lib/bundle.c
lib/coverage.c
lib/dpif-linux.c
lib/dynamic-string.c
lib/hmap.c
lib/multipath.c
lib/netdev-bsd.c
lib/netdev-linux.c
lib/netlink-socket.c
lib/netlink.c
lib/nx-match.c
lib/odp-util.c
lib/ofp-actions.c
lib/ofp-print.c
lib/ofp-util.c
lib/ofpbuf.c
lib/ovsdb-data.c
lib/ovsdb-idl.c
lib/ovsdb-parser.c
lib/pcap-file.c
lib/socket-util.c
lib/stp.c
lib/stream-ssl.c
lib/util.c
lib/util.h
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif.c
ofproto/ofproto.c
ovsdb/execution.c
ovsdb/jsonrpc-server.c
ovsdb/log.c
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
ovsdb/transaction.c
tests/test-aes128.c
tests/test-hindex.c
tests/test-hmap.c
tests/test-netflow.c
tests/test-odp.c
tests/test-ovsdb.c
tests/test-stp.c
utilities/ovs-ofctl.c

diff --git a/AUTHORS b/AUTHORS
index 76951e7..1c2d9ea 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,6 +7,7 @@ Alexei Starovoitov      ast@plumgrid.com
 Alexey I. Froloff       raorn@altlinux.org
 Alex Wang               alexw@nicira.com
 Alfredo Finelli         alf@computationes.de
+Alin Serdean            aserdean@cloudbasesolutions.com
 Andrew Evans            aevans@nicira.com
 Andrew Lambeth          wal@nicira.com
 Andy Hill               hillad@gmail.com
index 2f24ee3..c6e1a61 100644 (file)
@@ -394,7 +394,21 @@ 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().
+  For compatibility with antique printf() implementations:
+
+    - Instead of "%zu", use "%"PRIuSIZE.
+
+    - Instead of "%td", use "%"PRIdPTR.
+
+    - Instead of "%ju", use "%"PRIuMAX.
+
+Other variants exist for different radixes.  For example, use
+"%"PRIxSIZE instead of "%zx" or "%x" instead of "%hhx".
+
+  Also, instead of "%hhd", use "%d".  Be cautious substituting "%u",
+"%x", and "%o" for the corresponding versions with "hh": cast the
+argument to unsigned char if necessary, because printf("%hhu", -1)
+prints 255 but printf("%u", -1) prints 4294967295.
 
   Use bit-fields sparingly.  Do not use bit-fields for layout of
 network protocol fields or in other circumstances where the exact
index 135e58f..adb901b 100644 (file)
@@ -196,6 +196,19 @@ config-h-check:
        fi
 .PHONY: config-h-check
 
+# Check for printf() type modifiers that MSVC doesn't support.
+ALL_LOCAL += printf-check
+printf-check:
+       @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
+          git --no-pager grep -n -E -e '%[-+ #0-9.*]*([ztj]|hh)' --and --not -e 'ovs_scan' `git ls-files $(srcdir) | grep '\.[ch]$$'`; \
+       then \
+           echo "See above for list of violations of the rule that"; \
+           echo "'z', 't', 'j', 'hh' printf() type modifiers are"; \
+           echo "forbidden.  See CodingStyle for replacements."; \
+           exit 1; \
+       fi
+.PHONY: printf-check
+
 # Check that certain data structures are always declared "static".
 ALL_LOCAL += static-check
 static-check:
index 64b905e..75ee43c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "openvswitch/types.h"
 #include <sys/uio.h>
+#include <stddef.h>
 
 typedef unsigned short int sa_family_t;
 typedef __socklen_t socklen_t;
index 4582f2e..25129c9 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -646,7 +646,7 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow,
     msg = ofpbuf_at(p, (uint8_t *)p->l7 - (uint8_t *)p->data, BFD_PACKET_LEN);
     if (!msg) {
         VLOG_INFO_RL(&rl, "%s: Received too-short BFD control message (only "
-                     "%td bytes long, at least %d required).",
+                     "%"PRIdPTR" bytes long, at least %d required).",
                      bfd->name, (uint8_t *) ofpbuf_tail(p) - (uint8_t *) p->l7,
                      BFD_PACKET_LEN);
         goto out;
index 90ac243..dc0d76b 100644 (file)
@@ -735,7 +735,7 @@ log_bals(struct bond *bond, const struct list *bals)
                     if (&e->list_node != list_front(&slave->entries)) {
                         ds_put_cstr(&ds, " + ");
                     }
-                    ds_put_format(&ds, "h%td: %"PRIu64"kB",
+                    ds_put_format(&ds, "h%"PRIdPTR": %"PRIu64"kB",
                                   e - bond->hash, e->tx_bytes / 1024);
                 }
                 ds_put_cstr(&ds, ")");
@@ -754,7 +754,7 @@ bond_shift_load(struct bond_entry *hash, struct bond_slave *to)
     struct bond *bond = from->bond;
     uint64_t delta = hash->tx_bytes;
 
-    VLOG_INFO("bond %s: shift %"PRIu64"kB of load (with hash %td) "
+    VLOG_INFO("bond %s: shift %"PRIu64"kB of load (with hash %"PRIdPTR") "
               "from %s to %s (now carrying %"PRIu64"kB and "
               "%"PRIu64"kB load, respectively)",
               bond->name, delta / 1024, hash - bond->hash,
index 7d00f87..9aec8c9 100644 (file)
@@ -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" bytes "
+                     "allocated for slaves.  %"PRIuSIZE" bytes are required for "
                      "%"PRIu16" slaves.", subtype, slaves_size,
                      bundle->n_slaves * sizeof(ovs_be16), bundle->n_slaves);
         error = OFPERR_OFPBAC_BAD_LEN;
index 80316ef..aae9937 100644 (file)
@@ -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" events never hit", n_never_hit));
     free(totals);
 }
 
index 0442f77..25715f4 100644 (file)
@@ -2097,7 +2097,7 @@ report_loss(struct dpif *dpif_, struct dpif_channel *ch)
                       time_msec() - ch->last_poll);
     }
 
-    VLOG_WARN("%s: lost packet on channel %td%s",
+    VLOG_WARN("%s: lost packet on channel %"PRIdPTR"%s",
               dpif_name(dpif_), ch - dpif->channels, ds_cstr(&s));
     ds_destroy(&s);
 }
index 5137d9f..914af64 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <config.h>
 #include "dynamic-string.h"
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -383,12 +384,13 @@ ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size,
         n = end - start;
 
         /* Print line. */
-        ds_put_format(ds, "%08jx  ", (uintmax_t) ROUND_DOWN(ofs, per_line));
+        ds_put_format(ds, "%08"PRIxMAX"  ",
+                      (uintmax_t) ROUND_DOWN(ofs, per_line));
         for (i = 0; i < start; i++) {
             ds_put_format(ds, "   ");
         }
         for (; i < end; i++) {
-            ds_put_format(ds, "%02hhx%c",
+            ds_put_format(ds, "%02x%c",
                           buf[i - start], i == per_line / 2 - 1? '-' : ' ');
         }
         if (ascii) {
index a559a77..ec1de67 100644 (file)
@@ -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" nodes, %"PRIuSIZE" buckets)",
                         where, count, hmap->n, hmap->mask + 1);
         }
     }
index 4b9e4af..d611008 100644 (file)
@@ -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" bits for "
                      "%"PRIu32" links", min_n_bits, n_links);
         return OFPERR_OFPBAC_BAD_ARGUMENT;
     }
index 3eb29ea..dd27d2d 100644 (file)
@@ -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") on %s", retval, size, name);
             error = EMSGSIZE;
         } else {
             break;
index ae0e5a0..3e0da48 100644 (file)
@@ -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") on %s", retval, size, netdev_get_name(netdev_));
             return EMSGSIZE;
         } else {
             return 0;
index 3420503..4bd6d36 100644 (file)
@@ -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" 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")",
                     retval, sizeof *nlmsghdr);
         return EPROTO;
     }
index 680c676..aea1f29 100644 (file)
@@ -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" not in "
+                    "allowed range %"PRIuSIZE"...%"PRIuSIZE, 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" missing", i);
             return false;
         }
     }
index 72fc00f..983fd7d 100644 (file)
@@ -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")", 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")", match_len, b->size);
         return OFPERR_OFPBMC_BAD_LEN;
     }
 
index 62cc638..0fd1c51 100644 (file)
@@ -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", 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", 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", 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" but should have "
                         "length %d", ovs_key_attr_to_string(type, namebuf,
                                                             sizeof namebuf),
                         len, expected_len);
index e07ea1d..a02f842 100644 (file)
@@ -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" bytes "
+                     "allocated for controller ids.  %"PRIuSIZE" bytes are required for "
                      "%"PRIu16" controllers.", ids_size,
                      ids->n_controllers * sizeof(ovs_be16), ids->n_controllers);
         return OFPERR_OFPBAC_BAD_LEN;
@@ -638,7 +638,7 @@ log_bad_action(const union ofp_action *actions, size_t max_actions,
 
         ds_init(&s);
         ds_put_hex_dump(&s, actions, max_actions * OFP_ACTION_ALIGN, 0, false);
-        VLOG_WARN("bad action at offset %#tx (%s):\n%s",
+        VLOG_WARN("bad action at offset %#"PRIxPTR" (%s):\n%s",
                   (char *)bad_action - (char *)actions,
                   ofperr_get_name(error), ds_cstr(&s));
         ds_destroy(&s);
@@ -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")",
                      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,
                      (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")",
                      instructions_len, openflow->size);
         error = OFPERR_OFPBIC_BAD_LEN;
         goto exit;
index 37e1f4f..13705d0 100644 (file)
@@ -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" 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, 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, 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" 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" 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" 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" 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" 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" 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" 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" 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" 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"***)\n",
                       ntohs(oh->length), len);
     } else {
         enum ofperr error;
index d8a9754..92e0767 100644 (file)
@@ -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" 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" 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" 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, 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" 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, 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" 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" "
+                         "claims invalid length %"PRIuSIZE, 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" "
                      "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" "
                  "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" 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" 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,
                      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" 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" 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" 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" exceeds remaining buckets data size %"PRIuSIZE,
                          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" "
                      "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, 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" leftover "
                  "bytes at end", msg->size);
     return OFPERR_OFPBRC_BAD_LEN;
 }
index d578ab5..30ae12e 100644 (file)
@@ -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", allocated=%"PRIuSIZE", head=%"PRIuSIZE", tail=%"PRIuSIZE"\n",
                   b->size, b->allocated,
                   ofpbuf_headroom(b), ofpbuf_tailroom(b));
     ds_put_hex_dump(&s, b->data, MIN(b->size, maxbytes), 0, false);
index ade1971..4e918a6 100644 (file)
@@ -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" 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" 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" are present",
                                       class, type->n_min, type->n_max, n);
         }
 
index 3366523..a509c24 100644 (file)
@@ -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", 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" 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", needs %u)",
                      results->n, insert->op_index);
         return false;
     }
index 77460a8..f4642ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2011, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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" other member%s "
                             "are present but not allowed here.",
                             node->name, n_unused - 1, n_unused > 2 ? "s" : "");
                     } else {
index 700cdea..9091a72 100644 (file)
@@ -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" or %"PRIu32" "
                       "reading pcap file",
                       len, swapped_len);
             return EPROTO;
index cd0affc..bb48ade 100644 (file)
@@ -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" 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")",
                     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" fds received but only %d supported",
                          n_fds, SOUTIL_MAX_FDS);
                 for (i = 0; i < n_fds; i++) {
                     close(fds_data[i]);
index 6e1efd0..725bfff 100644 (file)
--- 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"-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,
                       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,
                       stp->name, bpdu_size);
             p->error_count++;
             goto out;
index 1e748c0..f2bd513 100644 (file)
@@ -1212,7 +1212,7 @@ log_ca_cert(const char *file_name, X509 *cert)
             if (i) {
                 ds_put_char(&fp, ':');
             }
-            ds_put_format(&fp, "%02hhx", digest[i]);
+            ds_put_format(&fp, "%02x", digest[i]);
         }
     }
     subject = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0);
@@ -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" 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" bytes)",
              sslv->type == CLIENT ? "client" : "server",
              sslv->session_nr, write_p ? "-->" : "<--",
              stream_get_name(&sslv->stream), ds_cstr(&details), len);
index c2ffab2..faa2cab 100644 (file)
@@ -346,7 +346,7 @@ ovs_strerror(int error)
          * is too short).  We don't check the actual failure reason because
          * POSIX requires strerror_r() to return the error but old glibc
          * (before 2.13) returns -1 and sets errno. */
-        snprintf(buffer, BUFSIZE, "Unknown error %d", error);
+        snprintf(buffer, BUFSIZE, "Unknown error %"PRIuSIZE, error);
     }
 #endif
 
@@ -473,11 +473,11 @@ ovs_hex_dump(FILE *stream, const void *buf_, size_t size,
       n = end - start;
 
       /* Print line. */
-      fprintf(stream, "%08jx  ", (uintmax_t) ROUND_DOWN(ofs, per_line));
+      fprintf(stream, "%08"PRIxMAX"  ", (uintmax_t) ROUND_DOWN(ofs, per_line));
       for (i = 0; i < start; i++)
         fprintf(stream, "   ");
       for (; i < end; i++)
-        fprintf(stream, "%02hhx%c",
+        fprintf(stream, "%02x%c",
                 buf[i - start], i == per_line / 2 - 1? '-' : ' ');
       if (ascii)
         {
index acb2d8f..fbab74c 100644 (file)
@@ -212,6 +212,23 @@ 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(). */
+#ifdef _WIN32
+#define PRIdSIZE "Id"
+#define PRIiSIZE "Ii"
+#define PRIoSIZE "Io"
+#define PRIuSIZE "Iu"
+#define PRIxSIZE "Ix"
+#define PRIXSIZE "IX"
+#else
+#define PRIdSIZE "zd"
+#define PRIiSIZE "zi"
+#define PRIoSIZE "zo"
+#define PRIuSIZE "zu"
+#define PRIxSIZE "zx"
+#define PRIXSIZE "zX"
+#endif
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
index dba3d3b..dde6430 100644 (file)
@@ -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,
                      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, cookie.type, userdata_len);
         return BAD_UPCALL;
     }
 }
index c1c206b..7df0450 100644 (file)
@@ -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"=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", 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", ", 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) {
index 5cd6b1e..c4ce8a2 100644 (file)
@@ -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, i);
         ots[i].match = htonll(OFPXMT13_MASK);
         ots[i].wildcards = htonll(OFPXMT13_MASK);
         ots[i].write_actions = htonl(OFPAT11_OUTPUT);
index 027e9e1..7a1db0c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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" of %"PRIuSIZE, i, n_operations);
         op = ovsdb_parser_member(&parser, "op", OP_ID);
         result = json_object_create();
         if (op) {
index 4cba4d9..4758442 100644 (file)
@@ -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" bytes backlogged but a complete replica "
+                      "would only take %"PRIuSIZE" bytes, disconnecting",
                       jsonrpc_session_get_name(s->js),
                       backlog - s->reply_backlog, monitor_length);
             jsonrpc_session_force_reconnect(s->js);
index 1316025..ed72ca4 100644 (file)
@@ -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" "SHA1_FMT"\n",
              magic, length, SHA1_ARGS(sha1));
 
     /* Write. */
index 67d09cb..bfc2653 100644 (file)
@@ -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" 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" 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" 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" elements: %s",
                   n_tables, json_to_string(reply->result, 0));
     }
     for (i = 0; i < n_tables; i++) {
index f64122e..4105a95 100644 (file)
@@ -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".",
                      schema->name, column_name, type_name,
                      ovsdb_atomic_type_to_string(key_type),
                      ovsdb_atomic_type_to_string(value_type),
index 646163a..4cbe9f0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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" 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" rows, greater than the schema-defined "
                                "limit of %u row(s)",
                                t->table->schema->name, n_rows, max_rows);
         }
index 19874b1..642c05e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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" hex digits", input, n * 2);
 }
 
 int
index f0a8b93..eb63d9d 100644 (file)
@@ -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")", e->value, e->node.hash & hindex->mask);
     }
     printf("\n");
 }
index 6102be3..dd79dc9 100644 (file)
@@ -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")", e->value, e->node.hash & hmap->mask);
     }
     printf("\n");
 }
index e995852..b6c3109 100644 (file)
@@ -162,7 +162,7 @@ print_netflow(struct ofpbuf *buf)
     }
 
     if (buf->size) {
-        printf("%zu extra bytes after last record\n", buf->size);
+        printf("%"PRIuSIZE" extra bytes after last record\n", buf->size);
     }
 }
 
index 471851b..a27bf7f 100644 (file)
@@ -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" > %d\n",
                         odp_key.size, ODPUTIL_FLOW_KEY_BYTES);
                 exit_code = 1;
             }
index 10d434e..3b48778 100644 (file)
@@ -831,7 +831,7 @@ do_evaluate_conditions(int argc OVS_UNUSED, char *argv[])
     json_destroy(json);
 
     for (i = 0; i < n_conditions; i++) {
-        printf("condition %2zu:", i);
+        printf("condition %2"PRIuSIZE":", i);
         for (j = 0; j < n_rows; j++) {
             bool result = ovsdb_condition_evaluate(rows[j], &conditions[i]);
             if (j % 5 == 0) {
@@ -937,7 +937,7 @@ do_execute_mutations(int argc OVS_UNUSED, char *argv[])
     json_destroy(json);
 
     for (i = 0; i < n_sets; i++) {
-        printf("mutation %2zu:\n", i);
+        printf("mutation %2"PRIuSIZE":\n", i);
         for (j = 0; j < n_rows; j++) {
             struct ovsdb_error *error;
             struct ovsdb_row *row;
@@ -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": ", j);
             if (error) {
                 print_and_free_ovsdb_error(error);
             } else {
@@ -1069,7 +1069,7 @@ do_query(int argc OVS_UNUSED, char *argv[])
         memset(cbdata.counts, 0, cbdata.n_rows * sizeof *cbdata.counts);
         ovsdb_query(table, &cnd, do_query_cb, &cbdata);
 
-        printf("query %2zu:", i);
+        printf("query %2"PRIuSIZE":", i);
         for (j = 0; j < cbdata.n_rows; j++) {
             if (j % 5 == 0) {
                 putchar(' ');
@@ -1206,7 +1206,7 @@ do_query_distinct(int argc OVS_UNUSED, char *argv[])
         }
         ovsdb_row_set_destroy(&results);
 
-        printf("query %2zu:", i);
+        printf("query %2"PRIuSIZE":", i);
         for (j = 0; j < n_rows; j++) {
             int count = rows[j].class->count;
 
@@ -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"#", *n);
         fprintf(stderr, "%s = "UUID_FMT"\n", name, UUID_ARGS(&uuid));
         ovsdb_symbol_table_put(symtab, name, &uuid, false);
         free(name);
index 28e9a6e..be1b395 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -325,7 +325,7 @@ err(const char *message, ...)
 {
     va_list args;
 
-    fprintf(stderr, "%s:%d:%td: ", file_name, line_number, pos - line);
+    fprintf(stderr, "%s:%d:%"PRIdPTR": ", file_name, line_number, pos - line);
     va_start(args, message);
     vfprintf(stderr, message, args);
     va_end(args);
index 1d1b47f..5eb8cf4 100644 (file)
@@ -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"-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" 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" 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" bytes", max_payload);
     }
     message_size = sizeof(struct ofp_header) + payload_size;
 
@@ -2766,15 +2766,15 @@ print_differences(const char *prefix,
 
     for (i = 0; i < MIN(a_len, b_len); i++) {
         if (a[i] != b[i]) {
-            printf("%s%2zu: %02"PRIx8" -> %02"PRIx8"\n",
+            printf("%s%2"PRIuSIZE": %02"PRIx8" -> %02"PRIx8"\n",
                    prefix, i, a[i], b[i]);
         }
     }
     for (i = a_len; i < b_len; i++) {
-        printf("%s%2zu: (none) -> %02"PRIx8"\n", prefix, i, b[i]);
+        printf("%s%2"PRIuSIZE": (none) -> %02"PRIx8"\n", prefix, i, b[i]);
     }
     for (i = b_len; i < a_len; i++) {
-        printf("%s%2zu: %02"PRIx8" -> (none)\n", prefix, i, a[i]);
+        printf("%s%2"PRIuSIZE": %02"PRIx8" -> (none)\n", prefix, i, a[i]);
     }
 }
 
@@ -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" bytes, expected %"PRIuSIZE,
                       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" bytes, expected %"PRIuSIZE,
                       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" bytes, expected %"PRIuSIZE,
                       match_in.size, sizeof(struct ofp11_match));
         }