From 3662b74009c03ca86f285ef3564ec226ebe288b2 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 12 Feb 2025 12:04:44 -0400 Subject: [PATCH] MT#55283 convert tos to bool Change-Id: Icf424a04b79923c239f1ccdbb79115b080a84462 --- lib/socket.c | 12 ++++++------ lib/socket.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index 5372ab2ae..57ce38440 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -42,8 +42,8 @@ static ssize_t __ip4_recvfrom_to(socket_t *s, void *buf, size_t len, endpoint_t static ssize_t __ip6_recvfrom_to(socket_t *s, void *buf, size_t len, endpoint_t *ep, sockaddr_t *to); static ssize_t __ip_sendmsg(socket_t *s, struct msghdr *mh, const endpoint_t *ep); static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpoint_t *ep); -static int __ip4_tos(socket_t *, unsigned int); -static int __ip6_tos(socket_t *, unsigned int); +static bool __ip4_tos(socket_t *, unsigned int); +static bool __ip6_tos(socket_t *, unsigned int); static int __ip_error(socket_t *s); static void __ip4_pmtu_disc(socket_t *, int); static void __ip4_endpoint2kernel(struct re_address *, const endpoint_t *); @@ -387,17 +387,17 @@ static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpo ep->address.family->endpoint2sockaddr(&sin, ep); return sendto(s->fd, buf, len, 0, (void *) &sin, ep->address.family->sockaddr_size); } -static int __ip4_tos(socket_t *s, unsigned int tos) { +static bool __ip4_tos(socket_t *s, unsigned int tos) { unsigned char ctos; ctos = tos; if (setsockopt(s->fd, IPPROTO_IP, IP_TOS, &ctos, sizeof(ctos))) ilog(LOG_ERR, "Failed to set TOS on IPv4 socket: %s", strerror(errno)); - return 0; + return true; } -static int __ip6_tos(socket_t *s, unsigned int tos) { +static bool __ip6_tos(socket_t *s, unsigned int tos) { if (setsockopt(s->fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos))) ilog(LOG_ERR, "Failed to set TOS on IPv6 socket: %s", strerror(errno)); - return 0; + return true; } static int __ip_error(socket_t *s) { int optval; diff --git a/lib/socket.h b/lib/socket.h index 091ac3bb9..99ab59e82 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -80,7 +80,7 @@ struct socket_family { ssize_t (*recvfrom_to)(socket_t *, void *, size_t, endpoint_t *, sockaddr_t *); ssize_t (*sendmsg)(socket_t *, struct msghdr *, const endpoint_t *); ssize_t (*sendto)(socket_t *, const void *, size_t, const endpoint_t *); - int (*tos)(socket_t *, unsigned int); + bool (*tos)(socket_t *, unsigned int); void (*pmtu_disc)(socket_t *, int); int (*error)(socket_t *); void (*endpoint2kernel)(struct re_address *, const endpoint_t *);