diff --git a/ed25519/src/seed.cpp b/ed25519/src/seed.cpp index 2123cc56c..7d03a37a0 100644 --- a/ed25519/src/seed.cpp +++ b/ed25519/src/seed.cpp @@ -46,13 +46,13 @@ void ed25519_create_seed(unsigned char *seed) { FILE *f = fopen("/dev/urandom", "rb"); if (f == NULL) { - throw boost::system::system_error(boost::system::error_code(errno, boost::system::generic_category())); + throw boost::system::system_error(boost::system::error_code(errno, boost::system::system_category())); } int read = fread(seed, 1, 32, f); if (read != 32) { fclose(f); - throw boost::system::system_error(boost::system::error_code(errno, boost::system::generic_category())); + throw boost::system::system_error(boost::system::error_code(errno, boost::system::system_category())); } fclose(f); diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 6b0ca07dc..0a0d00884 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -205,21 +205,21 @@ int load_file(std::string const& filename, std::vector& v FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -233,7 +233,7 @@ int load_file(std::string const& filename, std::vector& v r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -248,7 +248,7 @@ int load_file(std::string const& filename, std::vector& v r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -758,7 +758,7 @@ std::vector list_dir(std::string path DIR* handle = opendir(path.c_str()); if (handle == 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return ret; } diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index ca85df9f6..fa1b155d0 100644 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -44,21 +44,21 @@ int load_file(std::string const& filename, std::vector& v FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -72,7 +72,7 @@ int load_file(std::string const& filename, std::vector& v r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -87,7 +87,7 @@ int load_file(std::string const& filename, std::vector& v r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } diff --git a/examples/make_torrent.cpp b/examples/make_torrent.cpp index 5af2aae8b..e441b1626 100644 --- a/examples/make_torrent.cpp +++ b/examples/make_torrent.cpp @@ -55,21 +55,21 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -83,7 +83,7 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -98,7 +98,7 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index aeff5ddb4..725c0b4f9 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -549,7 +549,7 @@ namespace libtorrent m_cache_fd = open(sett.get_str(settings_pack::mmap_cache).c_str(), O_RDWR | O_CREAT | O_EXLOCK | O_TRUNC, 0700); if (m_cache_fd < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); } else { @@ -561,7 +561,7 @@ namespace libtorrent , MAP_SHARED | MAP_NOCACHE, m_cache_fd, 0)); if (intptr_t(m_cache_pool) == -1) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); m_cache_pool = 0; // attempt to make MacOS not flush this to disk, making close() diff --git a/src/file.cpp b/src/file.cpp index 695fcc71d..e6027e03e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -393,7 +393,7 @@ namespace libtorrent retval = ::stat(f.c_str(), &ret); if (retval < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } @@ -427,7 +427,7 @@ namespace libtorrent if (::rename(f1.c_str(), f2.c_str()) < 0) #endif { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } } @@ -468,7 +468,7 @@ namespace libtorrent std::string n = convert_to_native(f); int ret = mkdir(n.c_str(), 0777); if (ret < 0 && errno != EEXIST) - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); #endif } @@ -527,7 +527,7 @@ namespace libtorrent if (errno != EMLINK || errno != EXDEV) { // some error happened, report up to the caller - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } @@ -594,7 +594,7 @@ namespace libtorrent // this only works on 10.5 copyfile_state_t state = copyfile_state_alloc(); if (copyfile(f1.c_str(), f2.c_str(), state, COPYFILE_ALL) < 0) - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); copyfile_state_free(state); #else std::string f1 = convert_to_native(inf); @@ -603,7 +603,7 @@ namespace libtorrent int infd = ::open(f1.c_str(), O_RDONLY); if (infd < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } @@ -617,7 +617,7 @@ namespace libtorrent if (outfd < 0) { close(infd); - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } char buffer[4096]; @@ -627,13 +627,13 @@ namespace libtorrent if (num_read == 0) break; if (num_read < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); break; } int num_written = write(outfd, buffer, num_read); if (num_written < num_read) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); break; } if (num_read < int(sizeof(buffer))) break; @@ -1042,7 +1042,7 @@ namespace libtorrent std::string const& f = convert_to_native(inf); if (::remove(f.c_str()) < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } #endif // TORRENT_WINDOWS @@ -1137,7 +1137,7 @@ namespace libtorrent m_handle = opendir(p.c_str()); if (m_handle == 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); m_done = true; return; } @@ -1199,7 +1199,7 @@ namespace libtorrent dirent* dummy; if (readdir_r(m_handle, &m_dirent, &dummy) != 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); m_done = true; } if (dummy == 0) m_done = true; @@ -1447,7 +1447,7 @@ namespace libtorrent #endif if (handle == -1) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); TORRENT_ASSERT(ec); return false; } @@ -1693,7 +1693,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #ifdef TORRENT_WINDOWS ec.assign(GetLastError(), system_category()); #else - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); #endif return -1; } @@ -1723,7 +1723,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #ifdef TORRENT_WINDOWS ec.assign(GetLastError(), system_category()); #else - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); #endif return -1; } @@ -1747,7 +1747,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #else if (lseek(fd, file_offset, SEEK_SET) < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return -1; } #endif @@ -1760,7 +1760,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #ifdef TORRENT_WINDOWS ec.assign(GetLastError(), system_category()); #else - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); #endif return -1; } @@ -1786,7 +1786,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #ifdef TORRENT_WINDOWS ec = error_code(ERROR_INVALID_HANDLE, system_category()); #else - ec = error_code(EBADF, generic_category()); + ec = error_code(boost::system::errc::bad_file_descriptor, generic_category()); #endif return -1; } @@ -1834,7 +1834,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #ifdef TORRENT_WINDOWS ec = error_code(ERROR_INVALID_HANDLE, system_category()); #else - ec = error_code(EBADF, generic_category()); + ec = error_code(boost::system::errc::bad_file_descriptor, generic_category()); #endif return -1; } @@ -1878,7 +1878,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { && errno != EINVAL && errno != ENOSYS) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); } } #endif @@ -2073,7 +2073,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { struct stat st; if (fstat(native_handle(), &st) != 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return false; } @@ -2081,7 +2081,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { // have the right size. We don't want to update if (st.st_size != s && ftruncate(native_handle(), s) < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return false; } @@ -2103,14 +2103,14 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { { if (errno != ENOSPC) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return false; } // ok, let's try to allocate non contiguous space then f.fst_flags = F_ALLOCATEALL; if (fcntl(native_handle(), F_PREALLOCATE, &f) < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return false; } } @@ -2123,7 +2123,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { fl64.l_len = s; if (fcntl(native_handle(), F_ALLOCSP64, &fl64) < 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return false; } @@ -2143,7 +2143,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { // filesystem does not support this operation if (ret != 0 && ret != EINVAL) { - ec.assign(ret, generic_category()); + ec.assign(ret, system_category()); return false; } #endif // TORRENT_HAS_FALLOCATE @@ -2166,7 +2166,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { struct stat fs; if (fstat(native_handle(), &fs) != 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return -1; } return fs.st_size; diff --git a/src/torrent.cpp b/src/torrent.cpp index d2d14a75a..3faf51a0a 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -976,7 +976,7 @@ namespace libtorrent { // failed m_ses.alerts().emplace_alert( - get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category())); + get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category())); return; } @@ -1202,7 +1202,7 @@ namespace libtorrent update_gauge(); } - if (j->error.ec == error_code(boost::system::errc::not_enough_memory, generic_category())) + if (j->error.ec == boost::system::errc::not_enough_memory) { if (alerts().should_post()) alerts().emplace_alert(j->error.ec @@ -5107,7 +5107,7 @@ namespace libtorrent if (flags & torrent_handle::alert_when_available) { m_ses.alerts().emplace_alert( - get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category())); + get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category())); } return; } @@ -5243,7 +5243,7 @@ namespace libtorrent { // post an empty read_piece_alert to indicate it failed alerts().emplace_alert( - get_handle(), piece, error_code(boost::system::errc::operation_canceled, system_category())); + get_handle(), piece, error_code(boost::system::errc::operation_canceled, generic_category())); } if (has_picker()) m_picker->set_piece_priority(piece, 1); m_time_critical_pieces.erase(i); @@ -5260,7 +5260,7 @@ namespace libtorrent { // post an empty read_piece_alert to indicate it failed m_ses.alerts().emplace_alert( - get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, system_category())); + get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, generic_category())); } if (has_picker()) m_picker->set_piece_priority(i->piece, 1); i = m_time_critical_pieces.erase(i); @@ -5279,7 +5279,7 @@ namespace libtorrent { // post an empty read_piece_alert to indicate it failed alerts().emplace_alert( - get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, system_category())); + get_handle(), i->piece, error_code(boost::system::errc::operation_canceled, generic_category())); } i = m_time_critical_pieces.erase(i); continue; @@ -5982,7 +5982,7 @@ namespace libtorrent #if BOOST_VERSION < 105400 if (alerts().should_post()) alerts().emplace_alert(get_handle() - , error_code(boost::system::errc::not_supported, system_category()), "[certificate]"); + , error_code(boost::system::errc::not_supported, generic_category()), "[certificate]"); #else boost::asio::const_buffer certificate_buf(certificate.c_str(), certificate.size()); diff --git a/test/bdecode_benchmark.cpp b/test/bdecode_benchmark.cpp index a15f61889..f2195e082 100644 --- a/test/bdecode_benchmark.cpp +++ b/test/bdecode_benchmark.cpp @@ -49,21 +49,21 @@ int load_file(std::string const& filename, std::vector& v FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -77,7 +77,7 @@ int load_file(std::string const& filename, std::vector& v r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -92,7 +92,7 @@ int load_file(std::string const& filename, std::vector& v r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 2cc327ee9..96367e87d 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -170,21 +170,21 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -198,7 +198,7 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -213,7 +213,7 @@ int load_file(std::string const& filename, std::vector& v, libtorrent::err r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } diff --git a/tools/fuzz_torrent.cpp b/tools/fuzz_torrent.cpp index ec4371b28..1a5bb9e61 100644 --- a/tools/fuzz_torrent.cpp +++ b/tools/fuzz_torrent.cpp @@ -293,21 +293,21 @@ int load_file(std::string const& filename, std::vector& v FILE* f = fopen(filename.c_str(), "rb"); if (f == NULL) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); return -1; } int r = fseek(f, 0, SEEK_END); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } long s = ftell(f); if (s < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -321,7 +321,7 @@ int load_file(std::string const& filename, std::vector& v r = fseek(f, 0, SEEK_SET); if (r != 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; } @@ -336,7 +336,7 @@ int load_file(std::string const& filename, std::vector& v r = fread(&v[0], 1, v.size(), f); if (r < 0) { - ec.assign(errno, boost::system::generic_category()); + ec.assign(errno, boost::system::system_category()); fclose(f); return -1; }