diff --git a/include/ircd/exception.h b/include/ircd/exception.h index 1802c514b..ce664d983 100644 --- a/include/ircd/exception.h +++ b/include/ircd/exception.h @@ -40,6 +40,7 @@ namespace ircd std::system_error make_system_error(const std::error_code &); std::system_error make_system_error(const boost::system::error_code &); std::system_error make_system_error(const boost::system::system_error &); + [[noreturn]] void throw_system_error(); template std::exception_ptr make_system_eptr(args&&...); template [[noreturn]] void throw_system_error(args&&...); template std::exception_ptr make_exception_ptr(args&&...); diff --git a/include/ircd/sys.h b/include/ircd/sys.h index f6027ed39..79d364d76 100644 --- a/include/ircd/sys.h +++ b/include/ircd/sys.h @@ -107,10 +107,7 @@ ircd::sys::call(function&& f, }; if(unlikely(!nothrow && ret == -1L)) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); return ret; } diff --git a/ircd/allocator.cc b/ircd/allocator.cc index 0310636f9..3cd52c5a1 100644 --- a/ircd/allocator.cc +++ b/ircd/allocator.cc @@ -63,10 +63,8 @@ ircd::allocator::allocate(const size_t alignment, throw std::bad_alloc{}; default: - throw std::system_error - { - errc, std::system_category() - }; + throw_system_error(); + __builtin_unreachable(); } assert(ret != nullptr); diff --git a/ircd/exception.cc b/ircd/exception.cc index 14f812f5e..160b3879a 100644 --- a/ircd/exception.cc +++ b/ircd/exception.cc @@ -152,6 +152,16 @@ noexcept ec == boost::system::generic_category(); } +[[noreturn]] +void +ircd::throw_system_error() +{ + throw std::system_error + { + errno, std::system_category() + }; +} + std::system_error ircd::make_system_error(const boost::system::system_error &e) { diff --git a/ircd/fs.cc b/ircd/fs.cc index 7ece4ff91..9584e8989 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -1022,10 +1022,7 @@ ircd::fs::_read_preadv(const fd &fd, return 0UL; if(unlikely(ret == -1)) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); return ret; } @@ -1052,10 +1049,7 @@ ircd::fs::_read_preadv2(const fd &fd, return 0UL; if(unlikely(ret == -1)) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); return ret; } @@ -1407,10 +1401,7 @@ ircd::fs::_write_pwritev(const fd &fd, return 0UL; if(unlikely(ret == -1)) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); return ret; } @@ -1440,10 +1431,7 @@ ircd::fs::_write_pwritev2(const fd &fd, return 0UL; if(unlikely(ret == -1)) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); return ret; } diff --git a/ircd/prof_linux.cc b/ircd/prof_linux.cc index a470d61a0..5a9e9d20f 100644 --- a/ircd/prof_linux.cc +++ b/ircd/prof_linux.cc @@ -432,10 +432,7 @@ ircd::prof::event::event(const int &group, }; if(ret == (void *)-1) - throw std::system_error - { - errno, std::system_category() - }; + throw_system_error(); if(map_size && ret == nullptr) throw error