diff --git a/libtransmission/file-posix.cc b/libtransmission/file-posix.cc index 241f28c5a..a91bc3bbb 100644 --- a/libtransmission/file-posix.cc +++ b/libtransmission/file-posix.cc @@ -706,9 +706,9 @@ bool tr_sys_file_get_info(tr_sys_file_t handle, tr_sys_path_info* info, tr_error bool tr_sys_file_seek(tr_sys_file_t handle, int64_t offset, tr_seek_origin_t origin, uint64_t* new_offset, tr_error** error) { - TR_STATIC_ASSERT(TR_SEEK_SET == SEEK_SET, "values should match"); - TR_STATIC_ASSERT(TR_SEEK_CUR == SEEK_CUR, "values should match"); - TR_STATIC_ASSERT(TR_SEEK_END == SEEK_END, "values should match"); + static_assert(TR_SEEK_SET == SEEK_SET, "values should match"); + static_assert(TR_SEEK_CUR == SEEK_CUR, "values should match"); + static_assert(TR_SEEK_END == SEEK_END, "values should match"); TR_ASSERT(handle != TR_BAD_SYS_FILE); TR_ASSERT(origin == TR_SEEK_SET || origin == TR_SEEK_CUR || origin == TR_SEEK_END); @@ -716,7 +716,7 @@ bool tr_sys_file_seek(tr_sys_file_t handle, int64_t offset, tr_seek_origin_t ori bool ret = false; off_t my_new_offset; - TR_STATIC_ASSERT(sizeof(*new_offset) >= sizeof(my_new_offset), ""); + static_assert(sizeof(*new_offset) >= sizeof(my_new_offset), ""); my_new_offset = lseek(handle, offset, origin); @@ -745,7 +745,7 @@ bool tr_sys_file_read(tr_sys_file_t handle, void* buffer, uint64_t size, uint64_ bool ret = false; ssize_t my_bytes_read; - TR_STATIC_ASSERT(sizeof(*bytes_read) >= sizeof(my_bytes_read), ""); + static_assert(sizeof(*bytes_read) >= sizeof(my_bytes_read), ""); my_bytes_read = read(handle, buffer, size); @@ -782,7 +782,7 @@ bool tr_sys_file_read_at( bool ret = false; ssize_t my_bytes_read; - TR_STATIC_ASSERT(sizeof(*bytes_read) >= sizeof(my_bytes_read), ""); + static_assert(sizeof(*bytes_read) >= sizeof(my_bytes_read), ""); #ifdef HAVE_PREAD @@ -826,7 +826,7 @@ bool tr_sys_file_write(tr_sys_file_t handle, void const* buffer, uint64_t size, bool ret = false; ssize_t my_bytes_written; - TR_STATIC_ASSERT(sizeof(*bytes_written) >= sizeof(my_bytes_written), ""); + static_assert(sizeof(*bytes_written) >= sizeof(my_bytes_written), ""); my_bytes_written = write(handle, buffer, size); @@ -863,7 +863,7 @@ bool tr_sys_file_write_at( bool ret = false; ssize_t my_bytes_written; - TR_STATIC_ASSERT(sizeof(*bytes_written) >= sizeof(my_bytes_written), ""); + static_assert(sizeof(*bytes_written) >= sizeof(my_bytes_written), ""); #ifdef HAVE_PWRITE diff --git a/libtransmission/file-win32.cc b/libtransmission/file-win32.cc index 85c69ef70..de2b44697 100644 --- a/libtransmission/file-win32.cc +++ b/libtransmission/file-win32.cc @@ -998,9 +998,9 @@ bool tr_sys_file_get_info(tr_sys_file_t handle, tr_sys_path_info* info, tr_error bool tr_sys_file_seek(tr_sys_file_t handle, int64_t offset, tr_seek_origin_t origin, uint64_t* new_offset, tr_error** error) { - TR_STATIC_ASSERT(TR_SEEK_SET == FILE_BEGIN, "values should match"); - TR_STATIC_ASSERT(TR_SEEK_CUR == FILE_CURRENT, "values should match"); - TR_STATIC_ASSERT(TR_SEEK_END == FILE_END, "values should match"); + static_assert(TR_SEEK_SET == FILE_BEGIN, "values should match"); + static_assert(TR_SEEK_CUR == FILE_CURRENT, "values should match"); + static_assert(TR_SEEK_END == FILE_END, "values should match"); TR_ASSERT(handle != TR_BAD_SYS_FILE); TR_ASSERT(origin == TR_SEEK_SET || origin == TR_SEEK_CUR || origin == TR_SEEK_END); @@ -1387,7 +1387,7 @@ tr_sys_dir_t tr_sys_dir_open(char const* path, tr_error** error) { #ifndef __clang__ /* Clang gives "static_assert expression is not an integral constant expression" error */ - TR_STATIC_ASSERT(TR_BAD_SYS_DIR == nullptr, "values should match"); + static_assert(TR_BAD_SYS_DIR == nullptr, "values should match"); #endif TR_ASSERT(path != nullptr); diff --git a/libtransmission/subprocess-posix.cc b/libtransmission/subprocess-posix.cc index 7ebd33f99..b0b811d97 100644 --- a/libtransmission/subprocess-posix.cc +++ b/libtransmission/subprocess-posix.cc @@ -87,7 +87,7 @@ static bool tr_spawn_async_in_parent(int pipe_fd, tr_error** error) int child_errno; ssize_t count; - TR_STATIC_ASSERT(sizeof(child_errno) == sizeof(errno), ""); + static_assert(sizeof(child_errno) == sizeof(errno), ""); do { diff --git a/libtransmission/tr-lpd.cc b/libtransmission/tr-lpd.cc index b5bae623b..16e4a0984 100644 --- a/libtransmission/tr-lpd.cc +++ b/libtransmission/tr-lpd.cc @@ -296,7 +296,7 @@ int tr_lpdInit(tr_session* ss, [[maybe_unused]] tr_address* tr_addr) * string handling in tr_lpdSendAnnounce() and tr_lpdConsiderAnnounce(). * However, the code should work as long as interfaces to the rest of * libtransmission are compatible with char* strings. */ - TR_STATIC_ASSERT(sizeof(((struct tr_info*)nullptr)->hashString[0]) == sizeof(char), ""); + static_assert(sizeof(((struct tr_info*)nullptr)->hashString[0]) == sizeof(char), ""); struct ip_mreq mcastReq; int const opt_on = 1; diff --git a/libtransmission/tr-macros.h b/libtransmission/tr-macros.h index fb1e96184..9fe2cdf12 100644 --- a/libtransmission/tr-macros.h +++ b/libtransmission/tr-macros.h @@ -114,26 +114,6 @@ **** ***/ -/** - * @def TR_STATIC_ASSERT - * @brief This helper allows to perform static checks at compile time - */ -#if defined(__cplusplus) || defined(static_assert) -#define TR_STATIC_ASSERT static_assert -#elif __has_feature(c_static_assert) || __has_extension(c_static_assert) || TR_GNUC_CHECK_VERSION(4, 6) -#define TR_STATIC_ASSERT _Static_assert -#else -#define TR_STATIC_ASSERT(x, msg) \ - do \ - { \ - ((void)sizeof(x)); \ - } while (0) -#endif - -/*** -**** -***/ - /* Only use this macro to suppress false-positive alignment warnings */ #define TR_DISCARD_ALIGN(ptr, type) ((type)(void*)(ptr))