aboutsummaryrefslogtreecommitdiff
path: root/bootp.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2015-08-29 09:12:35 +0200
committerJason Wang <jasowang@redhat.com>2015-11-12 13:48:36 +0800
commitf75c02cc3f8bd711ddbecaf57aee9b30b50f28c7 (patch)
tree8bf382825e81cf1a74aaa45ecb96b26cd23d5968 /bootp.c
parentc91a2b71b4fd62dfa8ca98b217334b946aa69ee3 (diff)
downloadslirp-2.5.1.1.zip
slirp-2.5.1.1.tar.gz
slirp-2.5.1.1.tar.bz2
slirp: Fix type casts and format strings in debug codev2.5.1.1v2.5.1v2.5.0-rc4v2.5.0-rc3v2.5.0-rc2v2.5.0-rc1v2.5.0-rc0v2.5.0
Casting pointers to long won't work on 64 bit Windows. It is not needed with the right format strings. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'bootp.c')
-rw-r--r--bootp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bootp.c b/bootp.c
index 8b057c1..3af5dc0 100644
--- a/bootp.c
+++ b/bootp.c
@@ -23,6 +23,12 @@
*/
#include <slirp.h>
+#if defined(_WIN32)
+/* Windows ntohl() returns an u_long value.
+ * Add a type cast to match the format strings. */
+#define ntohl(n) ((uint32_t)ntohl(n))
+#endif
+
/* XXX: only DHCP is supported */
#define LEASE_TIME (24 * 3600)
@@ -161,7 +167,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
dhcp_decode(bp, &dhcp_msg_type, &preq_addr);
DPRINTF("bootp packet op=%d msgtype=%d", bp->bp_op, dhcp_msg_type);
if (preq_addr.s_addr != htonl(0L))
- DPRINTF(" req_addr=%08x\n", ntohl(preq_addr.s_addr));
+ DPRINTF(" req_addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr));
else
DPRINTF("\n");
@@ -239,7 +245,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
q += 4;
if (bc) {
- DPRINTF("%s addr=%08x\n",
+ DPRINTF("%s addr=%08" PRIx32 "\n",
(dhcp_msg_type == DHCPDISCOVER) ? "offered" : "ack'ed",
ntohl(daddr.sin_addr.s_addr));
@@ -307,7 +313,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
} else {
static const char nak_msg[] = "requested address not available";
- DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr));
+ DPRINTF("nak'ed addr=%08" PRIx32 "\n", ntohl(preq_addr.s_addr));
*q++ = RFC2132_MSG_TYPE;
*q++ = 1;