From b7999b6bf31eefc80312f144aa07f6b7dbd8efc8 Mon Sep 17 00:00:00 2001 From: reyk Date: Tue, 19 Jul 2016 18:11:08 +0000 Subject: [PATCH] Correctly use ssize_t instead of size_t for read/write return values. Pointed out by David Hill and clang. --- usr.sbin/switchd/ofcconn.c | 7 ++++--- usr.sbin/switchd/ofp.c | 4 ++-- usr.sbin/switchd/ofp10.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/usr.sbin/switchd/ofcconn.c b/usr.sbin/switchd/ofcconn.c index c08d21fb9ad..4583d17c2e3 100644 --- a/usr.sbin/switchd/ofcconn.c +++ b/usr.sbin/switchd/ofcconn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofcconn.c,v 1.3 2016/07/19 18:04:04 reyk Exp $ */ +/* $OpenBSD: ofcconn.c,v 1.4 2016/07/19 18:11:08 reyk Exp $ */ /* * Copyright (c) 2016 YASUOKA Masahiko @@ -311,7 +311,7 @@ ofcconn_on_devfio(int fd, short evmask, void *ctx) { struct ofcconn *oc = ctx; static char buf[65536];/* max size of OpenFlow message */ - size_t sz, sz2; + ssize_t sz, sz2; struct ofp_header *hdr; if (evmask & EV_WRITE) { @@ -500,7 +500,8 @@ ofcconn_send_hello(struct ofcconn *oc) hdr.oh_length = htons(sizeof(hdr)); hdr.oh_xid = htonl(0xffffffffUL); - if ((sz = write(oc->oc_sock, &hdr, sizeof(hdr))) != sz) { + sz = sizeof(hdr); + if (write(oc->oc_sock, &hdr, sz) != sz) { log_warn("%s: %s write", __func__, oc->oc_device); ofcconn_close(oc); ofcconn_connect_again(oc); diff --git a/usr.sbin/switchd/ofp.c b/usr.sbin/switchd/ofp.c index 1efe9c8ff64..eeb72357839 100644 --- a/usr.sbin/switchd/ofp.c +++ b/usr.sbin/switchd/ofp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */ +/* $OpenBSD: ofp.c,v 1.2 2016/07/19 18:11:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter @@ -208,7 +208,7 @@ ofp_send(struct switch_connection *con, struct ofp_header *oh, struct iovec iov[2]; int cnt = 0; void *data; - size_t len; + ssize_t len; if (oh != NULL) { iov[cnt].iov_base = oh; diff --git a/usr.sbin/switchd/ofp10.c b/usr.sbin/switchd/ofp10.c index 2a27e061f06..bd89686b2df 100644 --- a/usr.sbin/switchd/ofp10.c +++ b/usr.sbin/switchd/ofp10.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp10.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */ +/* $OpenBSD: ofp10.c,v 1.2 2016/07/19 18:11:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter @@ -170,7 +170,7 @@ ofp10_debug_packet_out(struct switchd *sc, off += sizeof(*pout); while ((ah = ibuf_seek(ibuf, off, len)) != NULL && - ntohs(ah->ah_len) >= sizeof(*ah)) { + ntohs(ah->ah_len) >= (uint16_t)sizeof(*ah)) { switch (ntohs(ah->ah_type)) { case OFP10_ACTION_OUTPUT: ao = (struct ofp10_action_output *)ah; -- 2.20.1