From 1442f8fdedf1a7be41293759572a43e198147fcd Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sun, 10 Mar 2019 19:52:27 +0300 Subject: [PATCH] Fix build break from previous commit on old Clangs Remove static assert altogether: it should have worked everywhere anyway, otherwise there is no point. Add a few casts here and there to ensure proper type for directory handle. --- libtransmission/file-posix.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libtransmission/file-posix.c b/libtransmission/file-posix.c index a24a4da3f..05840e7a5 100644 --- a/libtransmission/file-posix.c +++ b/libtransmission/file-posix.c @@ -1134,18 +1134,17 @@ bool tr_sys_dir_create_temp(char* path_template, tr_error** error) tr_sys_dir_t tr_sys_dir_open(char const* path, tr_error** error) { - TR_STATIC_ASSERT((void*)TR_BAD_SYS_DIR == NULL, "values should match"); - TR_ASSERT(path != NULL); - tr_sys_dir_t ret = opendir(path); + DIR* ret = opendir(path); - if (ret == TR_BAD_SYS_DIR) + if (ret == NULL) { set_system_error(error, errno); + return TR_BAD_SYS_DIR; } - return ret; + return (tr_sys_dir_t)ret; } char const* tr_sys_dir_read_name(tr_sys_dir_t handle, tr_error** error) @@ -1155,7 +1154,7 @@ char const* tr_sys_dir_read_name(tr_sys_dir_t handle, tr_error** error) char const* ret = NULL; errno = 0; - struct dirent* entry = readdir(handle); + struct dirent* entry = readdir((DIR*)handle); if (entry != NULL) { @@ -1173,7 +1172,7 @@ bool tr_sys_dir_close(tr_sys_dir_t handle, tr_error** error) { TR_ASSERT(handle != TR_BAD_SYS_DIR); - bool ret = closedir(handle) != -1; + bool ret = closedir((DIR*)handle) != -1; if (!ret) { -- 2.49.0