From: Ed Maste Date: Mon, 30 Jul 2012 22:29:40 +0000 (-0700) Subject: Use int type for setsockopt IP_TOS value X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb0cb3161f52bfb8360e48af6a869ba3a5f06add;p=openvswitch Use int type for setsockopt IP_TOS value FreeBSD requires that setsockopt(..., IP_TOS, ...) be passed an int value. Linux accepts either int or char types (and has since at least kernel 2.6.12) so just use int type unconditionally. Signed-off-by: Ed Maste Signed-off-by: Ben Pfaff --- diff --git a/lib/socket-util.c b/lib/socket-util.c index 2c5e6ccb..314761d3 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -94,12 +94,14 @@ xset_nonblocking(int fd) static int set_dscp(int fd, uint8_t dscp) { + int val; + if (dscp > 63) { return EINVAL; } - dscp = dscp << 2; - if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) { + val = dscp << 2; + if (setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val)) { return errno; }