From cf6f58ceece4c85760c82b78c4872dba331ddfc6 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 21 Aug 2013 06:06:10 +0200 Subject: More code cleanups --- src/DownloadEngineFactory.cc | 60 +++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 32 deletions(-) (limited to 'src/DownloadEngineFactory.cc') diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 2cfef18a..1dd6aaa3 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -91,58 +91,54 @@ std::unique_ptr createEventPoll(Option* op) #ifdef HAVE_LIBUV if (pollMethod == V_LIBUV) { auto ep = make_unique(); - if(ep->good()) { - return std::move(ep); - } else { + if(!ep->good()) { throw DL_ABORT_EX("Initializing LibuvEventPoll failed." " Try --event-poll=select"); } + return std::move(ep); } else #endif // HAVE_LIBUV #ifdef HAVE_EPOLL if(pollMethod == V_EPOLL) { auto ep = make_unique(); - if(ep->good()) { - return std::move(ep); - } else { + if(!ep->good()) { throw DL_ABORT_EX("Initializing EpollEventPoll failed." " Try --event-poll=select"); } + return std::move(ep); } else #endif // HAVE_EPLL #ifdef HAVE_KQUEUE - if(pollMethod == V_KQUEUE) { - auto kp = make_unique(); - if(kp->good()) { - return std::move(kp); - } else { - throw DL_ABORT_EX("Initializing KqueueEventPoll failed." - " Try --event-poll=select"); - } - } else + if(pollMethod == V_KQUEUE) { + auto kp = make_unique(); + if(!kp->good()) { + throw DL_ABORT_EX("Initializing KqueueEventPoll failed." + " Try --event-poll=select"); + } + return std::move(kp); + } else #endif // HAVE_KQUEUE #ifdef HAVE_PORT_ASSOCIATE - if(pollMethod == V_PORT) { - auto pp = make_unique(); - if(pp->good()) { - return std::move(pp); - } else { - throw DL_ABORT_EX("Initializing PortEventPoll failed." - " Try --event-poll=select"); - } - } else + if(pollMethod == V_PORT) { + auto pp = make_unique(); + if(!pp->good()) { + throw DL_ABORT_EX("Initializing PortEventPoll failed." + " Try --event-poll=select"); + } + return std::move(pp); + } else #endif // HAVE_PORT_ASSOCIATE #ifdef HAVE_POLL - if(pollMethod == V_POLL) { - return make_unique(); - } else + if(pollMethod == V_POLL) { + return make_unique(); + } else #endif // HAVE_POLL - if(pollMethod == V_SELECT) { - return make_unique(); - } else { - assert(0); - } + if(pollMethod == V_SELECT) { + return make_unique(); + } + assert(0); + return nullptr; } } // namespace -- cgit