From ab711e6942757d775c08c31a6c32d488feba1dba Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Sun, 17 Feb 2019 11:20:52 +0000 Subject: Codechange: Replaced SmallVector::[Begin|End]() with std alternatives --- src/network/core/tcp_listen.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/network/core/tcp_listen.h') diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h index 55594070b..744f8841f 100644 --- a/src/network/core/tcp_listen.h +++ b/src/network/core/tcp_listen.h @@ -54,13 +54,13 @@ public: /* Check if the client is banned */ bool banned = false; - for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) { - banned = address.IsInNetmask(*iter); + for (char *entry : _network_ban_list) { + banned = address.IsInNetmask(entry); if (banned) { Packet p(Tban_packet); p.PrepareToSend(); - DEBUG(net, 1, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), *iter); + DEBUG(net, 1, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), entry); if (send(s, (const char*)p.buffer, p.size, 0) < 0) { DEBUG(net, 0, "send failed with error %d", GET_LAST_ERROR()); @@ -111,16 +111,16 @@ public: } /* take care of listener port */ - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - FD_SET(s->second, &read_fd); + for (auto &s : sockets) { + FD_SET(s.second, &read_fd); } tv.tv_sec = tv.tv_usec = 0; // don't block at all. if (select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv) < 0) return false; /* accept clients.. */ - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - if (FD_ISSET(s->second, &read_fd)) AcceptClient(s->second); + for (auto &s : sockets) { + if (FD_ISSET(s.second, &read_fd)) AcceptClient(s.second); } /* read stuff from clients */ @@ -145,8 +145,8 @@ public: NetworkAddressList addresses; GetBindAddresses(&addresses, port); - for (NetworkAddress *address = addresses.Begin(); address != addresses.End(); address++) { - address->Listen(SOCK_STREAM, &sockets); + for (NetworkAddress &address : addresses) { + address.Listen(SOCK_STREAM, &sockets); } if (sockets.size() == 0) { @@ -161,8 +161,8 @@ public: /** Close the sockets we're listening on. */ static void CloseListeners() { - for (SocketList::iterator s = sockets.Begin(); s != sockets.End(); s++) { - closesocket(s->second); + for (auto &s : sockets) { + closesocket(s.second); } sockets.clear(); DEBUG(net, 1, "[%s] closed listeners", Tsocket::GetName()); -- cgit v1.2.3-54-g00ecf