diff --git a/srtcore/api.cpp b/srtcore/api.cpp index b096ae84b..ca613e9f8 100644 --- a/srtcore/api.cpp +++ b/srtcore/api.cpp @@ -1968,17 +1968,17 @@ SRTSOCKET CUDT::socket(int af, int, int) { return s_UDTUnited.newSocket(af, 0); } - catch (CUDTException& e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return INVALID_SOCK; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return INVALID_SOCK; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "socket: UNEXPECTED EXCEPTION: " << typeid(ee).name() @@ -1994,17 +1994,17 @@ int CUDT::bind(SRTSOCKET u, const sockaddr* name, int namelen) { return s_UDTUnited.bind(u, name, namelen); } - catch (CUDTException& e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "bind: UNEXPECTED EXCEPTION: " << typeid(ee).name() @@ -2020,17 +2020,17 @@ int CUDT::bind(SRTSOCKET u, UDPSOCKET udpsock) { return s_UDTUnited.bind(u, udpsock); } - catch (CUDTException& e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "bind/udp: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2045,17 +2045,17 @@ int CUDT::listen(SRTSOCKET u, int backlog) { return s_UDTUnited.listen(u, backlog); } - catch (CUDTException& e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "listen: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2070,12 +2070,12 @@ SRTSOCKET CUDT::accept(SRTSOCKET u, sockaddr* addr, int* addrlen) { return s_UDTUnited.accept(u, addr, addrlen); } - catch (CUDTException& e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return INVALID_SOCK; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "accept: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2091,17 +2091,17 @@ int CUDT::connect( { return s_UDTUnited.connect(u, name, namelen, forced_isn); } - catch (CUDTException e) + catch (const CUDTException e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "connect: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2116,12 +2116,12 @@ int CUDT::close(SRTSOCKET u) { return s_UDTUnited.close(u); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "close: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2136,12 +2136,12 @@ int CUDT::getpeername(SRTSOCKET u, sockaddr* name, int* namelen) { return s_UDTUnited.getpeername(u, name, namelen); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "getpeername: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2156,12 +2156,12 @@ int CUDT::getsockname(SRTSOCKET u, sockaddr* name, int* namelen) { return s_UDTUnited.getsockname(u, name, namelen);; } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "getsockname: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2179,12 +2179,12 @@ int CUDT::getsockopt( udt->getOpt(optname, optval, *optlen); return 0; } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "getsockopt: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2201,12 +2201,12 @@ int CUDT::setsockopt(SRTSOCKET u, int, SRT_SOCKOPT optname, const void* optval, udt->setOpt(optname, optval, optlen); return 0; } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "setsockopt: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2222,17 +2222,17 @@ int CUDT::send(SRTSOCKET u, const char* buf, int len, int) CUDT* udt = s_UDTUnited.lookup(u); return udt->send(buf, len); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "send: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2248,12 +2248,12 @@ int CUDT::recv(SRTSOCKET u, char* buf, int len, int) CUDT* udt = s_UDTUnited.lookup(u); return udt->recv(buf, len); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "recv: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2271,17 +2271,17 @@ int CUDT::sendmsg( CUDT* udt = s_UDTUnited.lookup(u); return udt->sendmsg(buf, len, ttl, inorder, srctime); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "sendmsg: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2298,17 +2298,17 @@ int CUDT::sendmsg2( CUDT* udt = s_UDTUnited.lookup(u); return udt->sendmsg2(buf, len, r_m); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "sendmsg: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2324,12 +2324,12 @@ int CUDT::recvmsg(SRTSOCKET u, char* buf, int len, uint64_t& srctime) CUDT* udt = s_UDTUnited.lookup(u); return udt->recvmsg(buf, len, srctime); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "recvmsg: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2345,12 +2345,12 @@ int CUDT::recvmsg2(SRTSOCKET u, char* buf, int len, ref_t r_m) CUDT* udt = s_UDTUnited.lookup(u); return udt->recvmsg2(buf, len, r_m); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "recvmsg: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2366,17 +2366,17 @@ int64_t CUDT::sendfile( CUDT* udt = s_UDTUnited.lookup(u); return udt->sendfile(ifs, offset, size, block); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "sendfile: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2393,12 +2393,12 @@ int64_t CUDT::recvfile( CUDT* udt = s_UDTUnited.lookup(u); return udt->recvfile(ofs, offset, size, block); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "recvfile: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2424,17 +2424,17 @@ int CUDT::select( { return s_UDTUnited.select(readfds, writefds, exceptfds, timeout); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "select: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2460,17 +2460,17 @@ int CUDT::selectEx( { return s_UDTUnited.selectEx(fds, readfds, writefds, exceptfds, msTimeOut); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (bad_alloc&) + catch (bad_alloc) { s_UDTUnited.setError(new CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "selectEx: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2485,12 +2485,12 @@ int CUDT::epoll_create() { return s_UDTUnited.epoll_create(); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_create: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2505,12 +2505,12 @@ int CUDT::epoll_add_usock(const int eid, const SRTSOCKET u, const int* events) { return s_UDTUnited.epoll_add_usock(eid, u, events); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_add_usock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2525,12 +2525,12 @@ int CUDT::epoll_add_ssock(const int eid, const SYSSOCKET s, const int* events) { return s_UDTUnited.epoll_add_ssock(eid, s, events); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_add_ssock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2546,12 +2546,12 @@ int CUDT::epoll_update_usock( { return s_UDTUnited.epoll_update_usock(eid, u, events); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_update_usock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2567,12 +2567,12 @@ int CUDT::epoll_update_ssock( { return s_UDTUnited.epoll_update_ssock(eid, s, events); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_update_ssock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2588,12 +2588,12 @@ int CUDT::epoll_remove_usock(const int eid, const SRTSOCKET u) { return s_UDTUnited.epoll_remove_usock(eid, u); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_remove_usock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2608,12 +2608,12 @@ int CUDT::epoll_remove_ssock(const int eid, const SYSSOCKET s) { return s_UDTUnited.epoll_remove_ssock(eid, s); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_remove_ssock: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2635,12 +2635,12 @@ int CUDT::epoll_wait( return s_UDTUnited.epoll_wait( eid, readfds, writefds, msTimeOut, lrfds, lwfds); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_wait: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2655,12 +2655,12 @@ int CUDT::epoll_release(const int eid) { return s_UDTUnited.epoll_release(eid); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "epoll_release: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2682,12 +2682,12 @@ int CUDT::perfmon(SRTSOCKET u, CPerfMon* perf, bool clear) udt->sample(perf, clear); return 0; } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "perfmon: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2704,12 +2704,12 @@ int CUDT::bstats(SRTSOCKET u, CBytePerfMon* perf, bool clear, bool instantaneous udt->bstats(perf, clear, instantaneous); return 0; } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return ERROR; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "bstats: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2724,12 +2724,12 @@ CUDT* CUDT::getUDTHandle(SRTSOCKET u) { return s_UDTUnited.lookup(u); } - catch (CUDTException e) + catch (const CUDTException& e) { s_UDTUnited.setError(new CUDTException(e)); return NULL; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "getUDTHandle: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); @@ -2756,12 +2756,12 @@ SRT_SOCKSTATUS CUDT::getsockstate(SRTSOCKET u) { return s_UDTUnited.getStatus(u); } - catch (CUDTException &e) + catch (const CUDTException &e) { s_UDTUnited.setError(new CUDTException(e)); return SRTS_NONEXIST; } - catch (std::exception& ee) + catch (const std::exception& ee) { LOGC(mglog.Fatal, log << "getsockstate: UNEXPECTED EXCEPTION: " << typeid(ee).name() << ": " << ee.what()); diff --git a/srtcore/common.h b/srtcore/common.h index a866ab096..89d77686a 100644 --- a/srtcore/common.h +++ b/srtcore/common.h @@ -798,11 +798,9 @@ inline int32_t SrtParseVersion(const char* v) int major, minor, patch; int result = sscanf(v, "%d.%d.%d", &major, &minor, &patch); - if ( result != 3 ) + if (result != 3) { return 0; - fprintf(stderr, "Invalid version format for HAISRT_VERSION: %s - use m.n.p\n", v); - throw v; // Throwing exception, as this function will be run before main() } return major*0x10000 + minor*0x100 + patch; diff --git a/srtcore/core.cpp b/srtcore/core.cpp index 3bae9b233..d1860739a 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -135,7 +135,7 @@ const int UDT::ERROR = CUDT::ERROR; #define SRT_VERSION_MIN(v) (0x00FF00 & (v)) #define SRT_VERSION_PCH(v) (0x0000FF & (v)) -// NOTE: HAISRT_VERSION is primarily defined in the build file. +// NOTE: SRT_VERSION is primarily defined in the build file. const int32_t SRT_DEF_VERSION = SrtParseVersion(SRT_VERSION); diff --git a/srtcore/utilities.h b/srtcore/utilities.h index ef89e0c2b..93321807c 100755 --- a/srtcore/utilities.h +++ b/srtcore/utilities.h @@ -299,8 +299,8 @@ struct BitsetMask template struct Bits { - // DID YOU GET kind-of error: ‘mask’ is not a member of ‘Bits<3u, 5u, false>’ ? - // See the the above declaration of 'correct' ! + // DID YOU GET a kind-of error: 'mask' is not a member of 'Bits<3u, 5u, false>'? + // See the the above declaration of 'correct'! static const uint32_t mask = BitsetMask::value; static const uint32_t offset = R; static const size_t size = L - R + 1;