[PATCH 1/4] lib/socket: use proper typed constant UINT32_MAX for uint32_t typed port

Thomas Haller thaller at redhat.com
Wed Apr 9 03:08:50 PDT 2014


This was a bug on architectures with native int type less then 32 bit.

Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/socket.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/socket.c b/lib/socket.c
index 00d8d6a..1c39a12 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -90,14 +90,14 @@ static uint32_t generate_local_port(void)
 
 	/* Out of sockets in our own PID namespace, what to do? FIXME */
 	NL_DBG(1, "Warning: Ran out of unique local port namespace\n");
-	return UINT_MAX;
+	return UINT32_MAX;
 }
 
 static void release_local_port(uint32_t port)
 {
 	int nr;
 
-	if (port == UINT_MAX)
+	if (port == UINT32_MAX)
 		return;
 	
 	nr = port >> 22;
@@ -126,7 +126,7 @@ static struct nl_sock *__alloc_socket(struct nl_cb *cb)
 	sk->s_peer.nl_family = AF_NETLINK;
 	sk->s_seq_expect = sk->s_seq_next = time(0);
 	sk->s_local.nl_pid = generate_local_port();
-	if (sk->s_local.nl_pid == UINT_MAX) {
+	if (sk->s_local.nl_pid == UINT32_MAX) {
 		nl_socket_free(sk);
 		return NULL;
 	}
-- 
1.9.0




More information about the libnl mailing list