From 225b90eefdeaac9073348b4f014544f60ebffbe6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 10 Oct 2014 22:52:47 +0900 Subject: [PATCH] Use switch-case instead of if --- src/shrpx_listen_handler.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/shrpx_listen_handler.cc b/src/shrpx_listen_handler.cc index c65adfd4..e5f33200 100644 --- a/src/shrpx_listen_handler.cc +++ b/src/shrpx_listen_handler.cc @@ -370,17 +370,18 @@ void perform_accept_pending_connection(ListenHandler *listener_handler, auto fd = accept(server_fd, &sockaddr.sa, &addrlen); if(fd == -1) { - if(errno == EINTR || - errno == ENETDOWN || - errno == EPROTO || - errno == ENOPROTOOPT || - errno == EHOSTDOWN || + switch(errno) { + case EINTR: + case ENETDOWN: + case EPROTO: + case ENOPROTOOPT: + case EHOSTDOWN: #ifdef ENONET - errno == ENONET || + case ENONET: #endif // ENONET - errno == EHOSTUNREACH || - errno == EOPNOTSUPP || - errno == ENETUNREACH) { + case EHOSTUNREACH: + case EOPNOTSUPP: + case ENETUNREACH: continue; }