From 88a386b9c87072787a3b712073cbf19a74b0bd20 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Tue, 26 Apr 2016 21:42:23 +0530 Subject: rpc: fix gf_process_reserved_ports this patch also does minor code cleanups. Change-Id: I0d005bd0f9baaaae498aa1df4faa6fcb65fa7a6e BUG: 1198849 Signed-off-by: Prasanna Kumar Kalever Reviewed-on: http://review.gluster.org/13997 Tested-by: Prasanna Kumar Kalever Smoke: Gluster Build System Reviewed-by: Atin Mukherjee CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy NetBSD-regression: NetBSD Build System --- rpc/rpc-transport/rdma/src/name.c | 8 +------- rpc/rpc-transport/socket/src/name.c | 10 ++-------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c index 93b249855e..d4502e766b 100644 --- a/rpc/rpc-transport/rdma/src/name.c +++ b/rpc/rpc-transport/rdma/src/name.c @@ -56,15 +56,9 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, { int32_t ret = -1; uint16_t port = ceiling - 1; - /* by default assume none of the ports are blocked and all are available */ - gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,}; - int i = 0; + gf_boolean_t ports[GF_PORT_MAX]; ret = gf_process_reserved_ports (ports, ceiling); - if (ret != 0) { - for (i = 0; i < GF_PORT_MAX; i++) - ports[i] = _gf_false; - } while (port) { /* ignore the reserved ports */ diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c index 725a8c1812..12887a72ff 100644 --- a/rpc/rpc-transport/socket/src/name.c +++ b/rpc/rpc-transport/socket/src/name.c @@ -44,19 +44,13 @@ af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr, { int32_t ret = -1; uint16_t port = ceiling - 1; - // by default assume none of the ports are blocked and all are available - gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,}; - int i = 0; + gf_boolean_t ports[GF_PORT_MAX]; ret = gf_process_reserved_ports (ports, ceiling); - if (ret != 0) { - for (i = 0; i < GF_PORT_MAX; i++) - ports[i] = _gf_false; - } while (port) { - // ignore the reserved ports + /* ignore the reserved ports */ if (ports[port] == _gf_true) { port--; continue; -- cgit