From 73148fa4a4ff4e0a60c18a8f1204b582ef83c7fe Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 19 Jul 2017 07:57:52 +1000 Subject: [PATCH] Remove unused server flags CLOSE_PENDING and CLOSING_SERVER, rename LOGGED_IN to SF_LOGGED_IN CLOSING_SERVER was never referenced outside of server.h where it's defined, and CLOSE_PENDING was cleared but never set by any code. Rename LOGGED_IN to namespace it (in anticipation of other flag variables in the server struct being consolidated into a set of server flags). Also put correct parantheses around the definition of SF_LOGGED_IN. --- include/server.h | 4 +--- source/server.c | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/server.h b/include/server.h index c70b471..3ed9f22 100644 --- a/include/server.h +++ b/include/server.h @@ -415,9 +415,7 @@ struct sockaddr_foobar get_server_uh_addr (int); #define USER_MODE_Y USER_MODE << 24 #define USER_MODE_Z USER_MODE << 25 -#define LOGGED_IN USER_MODE << 29 -#define CLOSE_PENDING USER_MODE << 30 -#define CLOSING_SERVER USER_MODE << 31 +#define SF_LOGGED_IN (USER_MODE << 29) extern const char *umodes; #define IMMED_SEND 0 diff --git a/source/server.c b/source/server.c index 36e2313..08c34dc 100644 --- a/source/server.c +++ b/source/server.c @@ -266,7 +266,7 @@ void set_server_bits (fd_set *rd, fd_set *wr, struct timeval *wake_time) if (server_list[i].read > -1) FD_SET(server_list[i].read, rd); #ifdef NON_BLOCKING_CONNECTS - if (!(server_list[i].login_flags & (LOGGED_IN|CLOSE_PENDING)) && + if (!(server_list[i].login_flags & SF_LOGGED_IN) && server_list[i].write > -1) FD_SET(server_list[i].write, wr); #endif @@ -409,7 +409,7 @@ static void scan_nonblocking(void) { if (((server_list[i].read > -1) || (server_list[i].write > -1)) && - !(server_list[i].login_flags & LOGGED_IN) && + !(server_list[i].login_flags & SF_LOGGED_IN) && time_since(&server_list[i].connect_time) > connect_timeout) { if (server_list[i].read > -1) new_close(server_list[i].read); @@ -491,7 +491,7 @@ void do_server (fd_set *rd, fd_set *wr) for (i = 0; i < number_of_servers; i++) { #ifdef NON_BLOCKING_CONNECTS - if (((des = server_list[i].write) > -1) && FD_ISSET(des, wr) && !(server_list[i].login_flags & LOGGED_IN)) + if (((des = server_list[i].write) > -1) && FD_ISSET(des, wr) && !(server_list[i].login_flags & SF_LOGGED_IN)) { struct sockaddr_in sa; socklen_t salen = sizeof(struct sockaddr_in); @@ -526,7 +526,7 @@ void do_server (fd_set *rd, fd_set *wr) { #ifdef NON_BLOCKING_CONNECTS /* If we get here before getting above we have problems. */ - if(!(server_list[i].login_flags & LOGGED_IN)) + if(!(server_list[i].login_flags & SF_LOGGED_IN)) { if(!server_list[i].ctx || server_list[i].ssl_error == SSL_ERROR_WANT_READ) { @@ -2307,15 +2307,14 @@ void register_server (int ssn_index, char *nick) change_server_nickname(ssn_index, nick); - server_list[ssn_index].login_flags &= ~LOGGED_IN; - server_list[ssn_index].login_flags &= ~CLOSE_PENDING; + server_list[ssn_index].login_flags &= ~SF_LOGGED_IN; server_list[ssn_index].last_msg = now; server_list[ssn_index].eof = 0; /* server_list[ssn_index].connected = 1; XXX: We aren't sure yet */ *server_list[ssn_index].umode = 0; server_list[ssn_index].operator = 0; /* set_umode(ssn_index); */ - server_list[ssn_index].login_flags |= LOGGED_IN; + server_list[ssn_index].login_flags |= SF_LOGGED_IN; server_list[ssn_index].lag_cookie = random_number(0); from_server = old_from_server; check_host();