diff --git a/cmake/TrMacros.cmake b/cmake/TrMacros.cmake index 3c89782a3..5e439126f 100644 --- a/cmake/TrMacros.cmake +++ b/cmake/TrMacros.cmake @@ -194,5 +194,5 @@ macro(tr_qt_add_resources) endmacro() macro(tr_qt_add_translation) - qt5_add_translation(${ARGN}) + qt5_add_translation(${ARGN} OPTIONS -silent) endmacro() diff --git a/gtk/file-list.c b/gtk/file-list.c index a521f37a6..21250b5f6 100644 --- a/gtk/file-list.c +++ b/gtk/file-list.c @@ -305,7 +305,8 @@ static gboolean refreshModel(gpointer file_data) struct ActiveData { GtkTreeSelection* sel; - GArray* array; + tr_file_index_t* indexBuf; + size_t indexCount; }; static gboolean getSelectedFilesForeach(GtkTreeModel* model, GtkTreePath* path UNUSED, GtkTreeIter* iter, gpointer gdata) @@ -335,27 +336,29 @@ static gboolean getSelectedFilesForeach(GtkTreeModel* model, GtkTreePath* path U { unsigned int i; gtk_tree_model_get(model, iter, FC_INDEX, &i, -1); - g_array_append_val(data->array, i); + data->indexBuf[data->indexCount++] = i; } } return FALSE; /* keep walking */ } -static GArray* getSelectedFilesAndDescendants(GtkTreeView* view) +static size_t getSelectedFilesAndDescendants(GtkTreeView* view, tr_file_index_t* indexBuf) { struct ActiveData data; data.sel = gtk_tree_view_get_selection(view); - data.array = g_array_new(FALSE, FALSE, sizeof(tr_file_index_t)); + data.indexBuf = indexBuf; + data.indexCount = 0; gtk_tree_model_foreach(gtk_tree_view_get_model(view), getSelectedFilesForeach, &data); - return data.array; + return data.indexCount; } struct SubtreeForeachData { - GArray* array; GtkTreePath* path; + tr_file_index_t* indexBuf; + size_t indexCount; }; static gboolean getSubtreeForeach(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer gdata) @@ -370,43 +373,46 @@ static gboolean getSubtreeForeach(GtkTreeModel* model, GtkTreePath* path, GtkTre { unsigned int i; gtk_tree_model_get(model, iter, FC_INDEX, &i, -1); - g_array_append_val(data->array, i); + data->indexBuf[data->indexCount++] = i; } } return FALSE; /* keep walking */ } -static void getSubtree(GtkTreeView* view, GtkTreePath* path, GArray* indices) +static size_t getSubtree(GtkTreeView* view, GtkTreePath* path, tr_file_index_t* indexBuf) { struct SubtreeForeachData tmp; - tmp.array = indices; + tmp.indexBuf = indexBuf; + tmp.indexCount = 0; tmp.path = path; gtk_tree_model_foreach(gtk_tree_view_get_model(view), getSubtreeForeach, &tmp); + return tmp.indexCount; } /* if `path' is a selected row, all selected rows are returned. * otherwise, only the row indicated by `path' is returned. * this is for toggling all the selected rows' states in a batch. + * + * indexBuf should be large enough to hold tr_inf.fileCount files. */ -static GArray* getActiveFilesForPath(GtkTreeView* view, GtkTreePath* path) +static size_t getActiveFilesForPath(GtkTreeView* view, GtkTreePath* path, tr_file_index_t* indexBuf) { - GArray* indices; + size_t indexCount; GtkTreeSelection* sel = gtk_tree_view_get_selection(view); if (gtk_tree_selection_path_is_selected(sel, path)) { /* clicked in a selected row... use the current selection */ - indices = getSelectedFilesAndDescendants(view); + indexCount = getSelectedFilesAndDescendants(view, indexBuf); } else { /* clicked OUTSIDE of the selected row... just use the clicked row */ - indices = g_array_new(FALSE, FALSE, sizeof(tr_file_index_t)); - getSubtree(view, path, indices); + indexCount = getSubtree(view, path, indexBuf); } - return indices; + return indexCount; } /*** @@ -709,7 +715,8 @@ static gboolean onViewPathToggled(GtkTreeView* view, GtkTreeViewColumn* col, Gtk if (tor != NULL && (cid == FC_PRIORITY || cid == FC_ENABLED)) { GtkTreeIter iter; - GArray* indices = getActiveFilesForPath(view, path); + tr_file_index_t* const indexBuf = g_new0(tr_file_index_t, tr_torrentInfo(tor)->fileCount); + size_t const indexCount = getActiveFilesForPath(view, path, indexBuf); GtkTreeModel* model = data->model; gtk_tree_model_get_iter(model, &iter, path); @@ -734,7 +741,7 @@ static gboolean onViewPathToggled(GtkTreeView* view, GtkTreeViewColumn* col, Gtk break; } - tr_torrentSetFilePriorities(tor, (tr_file_index_t*)indices->data, (tr_file_index_t)indices->len, priority); + tr_torrentSetFilePriorities(tor, indexBuf, indexCount, priority); } else { @@ -742,11 +749,11 @@ static gboolean onViewPathToggled(GtkTreeView* view, GtkTreeViewColumn* col, Gtk gtk_tree_model_get(model, &iter, FC_ENABLED, &enabled, -1); enabled = !enabled; - tr_torrentSetFileDLs(tor, (tr_file_index_t*)indices->data, (tr_file_index_t)indices->len, enabled); + tr_torrentSetFileDLs(tor, indexBuf, indexCount, enabled); } refresh(data); - g_array_free(indices, TRUE); + g_free(indexBuf); handled = TRUE; } diff --git a/gtk/main.c b/gtk/main.c index 8f12360a0..d2b522896 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -533,7 +533,7 @@ static void on_startup(GApplication* application, gpointer user_data) win = GTK_WINDOW(gtr_window_new(GTK_APPLICATION(application), ui_manager, cbdata->core)); g_signal_connect(win, "size-allocate", G_CALLBACK(on_main_window_size_allocated), cbdata); g_application_hold(application); - g_object_weak_ref(G_OBJECT(win), (GWeakNotify)g_application_release, application); + g_object_weak_ref(G_OBJECT(win), (GWeakNotify)(GCallback)g_application_release, application); app_setup(win, cbdata); tr_sessionSetRPCCallback(session, on_rpc_changed, cbdata); @@ -848,7 +848,7 @@ static void on_drag_data_received(GtkWidget* widget UNUSED, GdkDragContext* drag open_files(files, gdata); /* cleanup */ - g_slist_foreach(files, (GFunc)g_object_unref, NULL); + g_slist_foreach(files, (GFunc)(GCallback)g_object_unref, NULL); g_slist_free(files); g_strfreev(uris); @@ -885,7 +885,7 @@ static gboolean on_session_closed(gpointer gdata) struct cbdata* cbdata = gdata; tmp = g_slist_copy(cbdata->details); - g_slist_foreach(tmp, (GFunc)gtk_widget_destroy, NULL); + g_slist_foreach(tmp, (GFunc)(GCallback)gtk_widget_destroy, NULL); g_slist_free(tmp); if (cbdata->prefs != NULL) @@ -905,9 +905,9 @@ static gboolean on_session_closed(gpointer gdata) g_object_unref(cbdata->icon); } - g_slist_foreach(cbdata->error_list, (GFunc)g_free, NULL); + g_slist_foreach(cbdata->error_list, (GFunc)(GCallback)g_free, NULL); g_slist_free(cbdata->error_list); - g_slist_foreach(cbdata->duplicates_list, (GFunc)g_free, NULL); + g_slist_foreach(cbdata->duplicates_list, (GFunc)(GCallback)g_free, NULL); g_slist_free(cbdata->duplicates_list); return G_SOURCE_REMOVE; @@ -1031,7 +1031,7 @@ static void show_torrent_errors(GtkWindow* window, char const* primary, GSList** gtk_widget_show(w); g_string_free(s, TRUE); - g_slist_foreach(*files, (GFunc)g_free, NULL); + g_slist_foreach(*files, (GFunc)(GCallback)g_free, NULL); g_slist_free(*files); *files = NULL; } @@ -1488,7 +1488,7 @@ static tr_torrent* get_first_selected_torrent(struct cbdata* data) } } - g_list_foreach(l, (GFunc)gtk_tree_path_free, NULL); + g_list_foreach(l, (GFunc)(GCallback)gtk_tree_path_free, NULL); g_list_free(l); return tor; } diff --git a/gtk/notify.c b/gtk/notify.c index 4b2bf6b77..1a31e102f 100644 --- a/gtk/notify.c +++ b/gtk/notify.c @@ -191,7 +191,8 @@ void gtr_notify_torrent_completed(TrCore* core, int torrent_id) tor = gtr_core_find_torrent(core, torrent_id); n = g_new0(TrNotification, 1); - n->core = g_object_ref(G_OBJECT(core)); + g_object_ref(G_OBJECT(core)); + n->core = core; n->torrent_id = torrent_id; g_variant_builder_init(&actions_builder, G_VARIANT_TYPE("as")); diff --git a/gtk/open-dialog.c b/gtk/open-dialog.c index 01ade6258..93b7b32a1 100644 --- a/gtk/open-dialog.c +++ b/gtk/open-dialog.c @@ -84,7 +84,7 @@ static void save_recent_destination(TrCore* core, char const* dir) gtr_pref_save(gtr_core_session(core)); /* cleanup */ - g_slist_foreach(list, (GFunc)g_free, NULL); + g_slist_foreach(list, (GFunc)(GCallback)g_free, NULL); g_slist_free(list); } @@ -440,7 +440,7 @@ static void onOpenDialogResponse(GtkDialog* dialog, int response, gpointer core) GSList* files = gtk_file_chooser_get_files(chooser); gtr_core_add_files(core, files, do_start, do_prompt, do_notify); - g_slist_foreach(files, (GFunc)g_object_unref, NULL); + g_slist_foreach(files, (GFunc)(GCallback)g_object_unref, NULL); g_slist_free(files); } diff --git a/gtk/tr-core.c b/gtk/tr-core.c index f62d777d5..9b3c9238b 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -742,7 +742,7 @@ static gboolean core_watchdir_idle(gpointer gcore) core->priv->adding_from_watch_dir = TRUE; gtr_core_add_files(core, unchanging, do_start, do_prompt, TRUE); - g_slist_foreach(unchanging, (GFunc)rename_torrent_and_unref_file, NULL); + g_slist_foreach(unchanging, (GFunc)(GCallback)rename_torrent_and_unref_file, NULL); g_slist_free(unchanging); core->priv->adding_from_watch_dir = FALSE; } diff --git a/libtransmission/CMakeLists.txt b/libtransmission/CMakeLists.txt index 4c69aae52..672cd0e0b 100644 --- a/libtransmission/CMakeLists.txt +++ b/libtransmission/CMakeLists.txt @@ -2,6 +2,18 @@ project(libtr) configure_file(version.h.in version.h) +set(THIRD_PARTY_SOURCES ConvertUTF.c jsonsl.c wildmat.c) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(DISABLE_WARNINGS -w) +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(DISABLE_WARNINGS -w) +elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro") + set(DISABLE_WARNINGS -erroff) +elseif(MSVC) + set(DISABLE_WARNINGS /w) +endif() +set_source_files_properties(${THIRD_PARTY_SOURCES} PROPERTIES COMPILE_FLAGS ${DISABLE_WARNINGS}) + set(${PROJECT_NAME}_SOURCES announcer.c announcer-http.c diff --git a/libtransmission/announcer-udp.c b/libtransmission/announcer-udp.c index c70a44f04..e141ba27d 100644 --- a/libtransmission/announcer-udp.c +++ b/libtransmission/announcer-udp.c @@ -37,11 +37,11 @@ static void tau_sockaddr_setport(struct sockaddr* sa, tr_port port) { if (sa->sa_family == AF_INET) { - ((struct sockaddr_in*)sa)->sin_port = htons(port); + TR_DISCARD_ALIGN(sa, struct sockaddr_in*)->sin_port = htons(port); } else if (sa->sa_family == AF_INET6) { - ((struct sockaddr_in6*)sa)->sin6_port = htons(port); + TR_DISCARD_ALIGN(sa, struct sockaddr_in6*)->sin6_port = htons(port); } } diff --git a/libtransmission/error.c b/libtransmission/error.c index 5770a8ddc..4331a985d 100644 --- a/libtransmission/error.c +++ b/libtransmission/error.c @@ -120,6 +120,8 @@ void tr_error_clear(tr_error** error) *error = NULL; } +static void error_prefix_valist(tr_error** error, char const* prefix_format, va_list args) TR_GNUC_PRINTF(2, 0); + static void error_prefix_valist(tr_error** error, char const* prefix_format, va_list args) { TR_ASSERT(error != NULL); diff --git a/libtransmission/error.h b/libtransmission/error.h index dda40cb0c..5a8b3dbdf 100644 --- a/libtransmission/error.h +++ b/libtransmission/error.h @@ -62,7 +62,7 @@ tr_error* tr_error_new_literal(int code, char const* message); * * @return Newly allocated error object on success, `NULL` otherwise. */ -tr_error* tr_error_new_valist(int code, char const* message_format, va_list args); +tr_error* tr_error_new_valist(int code, char const* message_format, va_list args) TR_GNUC_PRINTF(2, 0); /** * @brief Free memory used by error object. diff --git a/libtransmission/file.h b/libtransmission/file.h index d723d65e8..aa40f41ce 100644 --- a/libtransmission/file.h +++ b/libtransmission/file.h @@ -578,7 +578,7 @@ bool tr_sys_file_write_line(tr_sys_file_t handle, char const* buffer, struct tr_ * * @return `True` on success, `false` otherwise (with `error` set accordingly). */ -bool tr_sys_file_write_fmt(tr_sys_file_t handle, char const* format, struct tr_error** error, ...); +bool tr_sys_file_write_fmt(tr_sys_file_t handle, char const* format, struct tr_error** error, ...) TR_GNUC_PRINTF(2, 4); /* Directory-related wrappers */ diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index e769431a9..c1c4654c8 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -1079,6 +1079,7 @@ static ReadState canRead(struct tr_peerIo* io, void* arg, size_t* piece) break; default: + ret = READ_ERR; TR_ASSERT_MSG(false, "unhandled handshake state %d", (int)handshake->state); } diff --git a/libtransmission/net.c b/libtransmission/net.c index ecc99aded..567de25e1 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -588,11 +588,11 @@ fail: } /* We all hate NATs. */ -static int global_unicast_address(struct sockaddr* sa) +static int global_unicast_address(struct sockaddr_storage* ss) { - if (sa->sa_family == AF_INET) + if (ss->ss_family == AF_INET) { - unsigned char const* a = (unsigned char*)&((struct sockaddr_in*)sa)->sin_addr; + unsigned char const* a = (unsigned char*)&((struct sockaddr_in*)ss)->sin_addr; if (a[0] == 0 || a[0] == 127 || a[0] >= 224 || a[0] == 10 || (a[0] == 172 && a[1] >= 16 && a[1] <= 31) || (a[0] == 192 && a[1] == 168)) @@ -602,9 +602,9 @@ static int global_unicast_address(struct sockaddr* sa) return 1; } - else if (sa->sa_family == AF_INET6) + else if (ss->ss_family == AF_INET6) { - unsigned char const* a = (unsigned char*)&((struct sockaddr_in6*)sa)->sin6_addr; + unsigned char const* a = (unsigned char*)&((struct sockaddr_in6*)ss)->sin6_addr; /* 2000::/3 */ return (a[0] & 0xE0) == 0x20 ? 1 : 0; } @@ -658,7 +658,7 @@ static int tr_globalAddress(int af, void* addr, int* addr_len) return -1; } - if (global_unicast_address((struct sockaddr*)&ss) == 0) + if (global_unicast_address(&ss) == 0) { return -1; } diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index d923277dd..b617ecf5d 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -1766,7 +1766,7 @@ static void peerCallbackFunc(tr_peer* peer, tr_peer_event const* e, void* vs) tor->uploadedCur += e->length; tr_announcerAddBytes(tor, TR_ANN_UP, e->length); - tr_torrentSetActivityDate(tor, now); + tr_torrentSetDateActive(tor, now); tr_torrentSetDirty(tor); tr_statsAddUploaded(tor->session, e->length); @@ -1784,7 +1784,7 @@ static void peerCallbackFunc(tr_peer* peer, tr_peer_event const* e, void* vs) tr_torrent* tor = s->tor; tor->downloadedCur += e->length; - tr_torrentSetActivityDate(tor, now); + tr_torrentSetDateActive(tor, now); tr_torrentSetDirty(tor); tr_statsAddDownloaded(tor->session, e->length); diff --git a/libtransmission/platform.c b/libtransmission/platform.c index f9889ec38..cf0ecd825 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -90,7 +90,7 @@ bool tr_amInThread(tr_thread const* t) #ifdef _WIN32 #define ThreadFuncReturnType unsigned WINAPI #else -#define ThreadFuncReturnType void +#define ThreadFuncReturnType void* #endif static ThreadFuncReturnType ThreadFunc(void* _t) @@ -108,6 +108,8 @@ static ThreadFuncReturnType ThreadFunc(void* _t) #ifdef _WIN32 _endthreadex(0); return 0; +#else + return NULL; #endif } diff --git a/libtransmission/resume.c b/libtransmission/resume.c index 61103d630..5fd29ff7e 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -914,7 +914,7 @@ static uint64_t loadFromFile(tr_torrent* tor, uint64_t fieldsToLoad, bool* didRe if ((fieldsToLoad & TR_FR_ACTIVITY_DATE) != 0 && tr_variantDictFindInt(&top, TR_KEY_activity_date, &i)) { - tr_torrentSetActivityDate(tor, i); + tr_torrentSetDateActive(tor, i); fieldsLoaded |= TR_FR_ACTIVITY_DATE; } diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 5c9532b97..4bc631e77 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -968,7 +968,7 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor) TR_ASSERT(tor->downloadedCur == 0); TR_ASSERT(tor->uploadedCur == 0); - tr_torrentSetAddedDate(tor, tr_time()); /* this is a default value to be overwritten by the resume file */ + tr_torrentSetDateAdded(tor, tr_time()); /* this is a default value to be overwritten by the resume file */ torrentInitFromInfo(tor); @@ -2905,7 +2905,14 @@ bool tr_torrentSetAnnounceList(tr_torrent* tor, tr_tracker_info const* trackers_ *** **/ -void tr_torrentSetAddedDate(tr_torrent* tor, time_t t) +#define BACK_COMPAT_FUNC(oldname, newname) \ + void oldname(tr_torrent * tor, time_t t) { newname(tor, t); } +BACK_COMPAT_FUNC(tr_torrentSetAddedDate, tr_torrentSetDateAdded) +BACK_COMPAT_FUNC(tr_torrentSetActivityDate, tr_torrentSetDateActive) +BACK_COMPAT_FUNC(tr_torrentSetDoneDate, tr_torrentSetDateDone) +#undef BACK_COMPAT_FUNC + +void tr_torrentSetDateAdded(tr_torrent* tor, time_t t) { TR_ASSERT(tr_isTorrent(tor)); @@ -2913,7 +2920,7 @@ void tr_torrentSetAddedDate(tr_torrent* tor, time_t t) tor->anyDate = MAX(tor->anyDate, tor->addedDate); } -void tr_torrentSetActivityDate(tr_torrent* tor, time_t t) +void tr_torrentSetDateActive(tr_torrent* tor, time_t t) { TR_ASSERT(tr_isTorrent(tor)); @@ -2921,7 +2928,7 @@ void tr_torrentSetActivityDate(tr_torrent* tor, time_t t) tor->anyDate = MAX(tor->anyDate, tor->activityDate); } -void tr_torrentSetDoneDate(tr_torrent* tor, time_t t) +void tr_torrentSetDateDone(tr_torrent* tor, time_t t) { TR_ASSERT(tr_isTorrent(tor)); diff --git a/libtransmission/torrent.h b/libtransmission/torrent.h index 18bc031ef..9898c6f07 100644 --- a/libtransmission/torrent.h +++ b/libtransmission/torrent.h @@ -87,6 +87,12 @@ void tr_torrentSave(tr_torrent* tor); void tr_torrentSetLocalError(tr_torrent* tor, char const* fmt, ...) TR_GNUC_PRINTF(2, 3); +void tr_torrentSetDateAdded(tr_torrent* torrent, time_t addedDate); + +void tr_torrentSetDateActive(tr_torrent* torrent, time_t activityDate); + +void tr_torrentSetDateDone(tr_torrent* torrent, time_t doneDate); + typedef enum { TR_VERIFY_NONE, diff --git a/libtransmission/tr-macros.h b/libtransmission/tr-macros.h index b03ad16d7..237b4d054 100644 --- a/libtransmission/tr-macros.h +++ b/libtransmission/tr-macros.h @@ -125,6 +125,12 @@ #define TR_GNUC_MALLOC #endif +#if __has_attribute(__fallthrough__) || TR_GNUC_CHECK_VERSION(7, 0) +#define TR_GNUC_FALLTHROUGH __attribute__((__fallthrough__)) +#else +#define TR_GNUC_FALLTHROUGH +#endif + /*** **** ***/ @@ -159,6 +165,9 @@ **** ***/ +/* Only use this macro to suppress false-positive alignment warnings */ +#define TR_DISCARD_ALIGN(ptr, type) ((type)(void*)(ptr)) + #define SHA_DIGEST_LENGTH 20 #define TR_INET6_ADDRSTRLEN 46 diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 95e7490b7..f0136c849 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -1862,13 +1862,16 @@ tr_stat const* tr_torrentStat(tr_torrent* torrent); reduce the CPU load if you're calling tr_torrentStat() frequently. */ tr_stat const* tr_torrentStatCached(tr_torrent* torrent); -/** @deprecated */ +/** @deprecated because this should only be accessible to libtransmission. + private code, use tr_torentSetDateAdded() instead */ TR_DEPRECATED void tr_torrentSetAddedDate(tr_torrent* torrent, time_t addedDate); -/** @deprecated */ +/** @deprecated because this should only be accessible to libtransmission. + private code, use tr_torentSetDateActive() instead */ TR_DEPRECATED void tr_torrentSetActivityDate(tr_torrent* torrent, time_t activityDate); -/** @deprecated */ +/** @deprecated because this should only be accessible to libtransmission. + private code, use tr_torentSetDateDone() instead */ TR_DEPRECATED void tr_torrentSetDoneDate(tr_torrent* torrent, time_t doneDate); /** @} */ diff --git a/libtransmission/utils-test.c b/libtransmission/utils-test.c index 5a1753830..110da07c7 100644 --- a/libtransmission/utils-test.c +++ b/libtransmission/utils-test.c @@ -425,6 +425,8 @@ static int test_truncd(void) return 0; } +static char* test_strdup_printf_valist(char const* fmt, ...) TR_GNUC_PRINTF(1, 2); + static char* test_strdup_printf_valist(char const* fmt, ...) { va_list args; diff --git a/libtransmission/utils.h b/libtransmission/utils.h index 6b650aa89..98f88545c 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -225,8 +225,8 @@ void tr_quickfindFirstK(void* base, size_t nmemb, size_t size, tr_voidptr_compar * @brief sprintf() a string into a newly-allocated buffer large enough to hold it * @return a newly-allocated string that can be freed with tr_free() */ -char* tr_strdup_printf(char const* fmt, ...) TR_GNUC_PRINTF(1, 2) TR_GNUC_MALLOC; -char* tr_strdup_vprintf(char const* fmt, va_list args) TR_GNUC_MALLOC; +char* tr_strdup_printf(char const* fmt, ...) TR_GNUC_MALLOC TR_GNUC_PRINTF(1, 2); +char* tr_strdup_vprintf(char const* fmt, va_list args) TR_GNUC_MALLOC TR_GNUC_PRINTF(1, 0); /** @brief Portability wrapper for strlcpy() that uses the system implementation if available */ size_t tr_strlcpy(char* dst, void const* src, size_t siz); diff --git a/libtransmission/watchdir-inotify.c b/libtransmission/watchdir-inotify.c index 930d57ae3..68645ec20 100644 --- a/libtransmission/watchdir-inotify.c +++ b/libtransmission/watchdir-inotify.c @@ -67,7 +67,9 @@ static void tr_watchdir_inotify_on_event(struct bufferevent* event, void* contex TR_ASSERT(context != NULL); tr_watchdir_t const handle = context; +#ifdef TR_ENABLE_ASSERTS tr_watchdir_inotify* const backend = BACKEND_UPCAST(tr_watchdir_get_backend(handle)); +#endif struct inotify_event ev; size_t nread; size_t name_size = NAME_MAX + 1; diff --git a/qt/RpcQueue.h b/qt/RpcQueue.h index 2ba6dd629..098d9f62d 100644 --- a/qt/RpcQueue.h +++ b/qt/RpcQueue.h @@ -133,7 +133,7 @@ private: >::type* = nullptr> ErrorHandlerFunction normalizeErrorHandler(Func const& func) { - return [func](RpcResponseFuture const& r) + return [func](RpcResponseFuture const&) { func(); }; diff --git a/qt/Session.cc b/qt/Session.cc index c422ef63d..71549a973 100644 --- a/qt/Session.cc +++ b/qt/Session.cc @@ -144,7 +144,7 @@ void Session::copyMagnetLinkToClipboard(int torrentId) return exec(TR_KEY_torrent_get, &args); }); - q->add([this](RpcResponse const& r) + q->add([](RpcResponse const& r) { tr_variant* torrents; @@ -536,7 +536,7 @@ void Session::torrentRenamePath(QSet const& ids, QString const& oldpath, QS { return exec("torrent-rename-path", &args); }, - [this](RpcResponse const& r) + [](RpcResponse const& r) { char const* path = "(unknown)"; char const* name = "(unknown)"; @@ -547,7 +547,7 @@ void Session::torrentRenamePath(QSet const& ids, QString const& oldpath, QS tr("

Unable to rename \"%1\" as \"%2\": %3.

Please correct the errors and try again.

"). arg(QString::fromUtf8(path)).arg(QString::fromUtf8(name)).arg(r.result), QMessageBox::Close, qApp->activeWindow()); - connect(d, SIGNAL(rejected()), d, SLOT(deleteLater())); + QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater); d->show(); }); @@ -991,16 +991,16 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi { return exec("torrent-add", args); }, - [this, addMe](RpcResponse const& r) + [addMe](RpcResponse const& r) { QMessageBox* d = new QMessageBox(QMessageBox::Warning, tr("Error Adding Torrent"), QString::fromLatin1("

%1

%2

").arg(r.result).arg(addMe.readableName()), QMessageBox::Close, qApp->activeWindow()); - connect(d, SIGNAL(rejected()), d, SLOT(deleteLater())); + QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater); d->show(); }); - q->add([this, addMe](RpcResponse const& r) + q->add([addMe](RpcResponse const& r) { tr_variant* dup; @@ -1017,14 +1017,14 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi QMessageBox* d = new QMessageBox(QMessageBox::Warning, tr("Add Torrent"), tr("

Unable to add \"%1\".

It is a duplicate of \"%2\" which is already added.

"). arg(addMe.readableShortName()).arg(name), QMessageBox::Close, qApp->activeWindow()); - connect(d, SIGNAL(rejected()), d, SLOT(deleteLater())); + QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater); d->show(); } }); if (trashOriginal && addMe.type == AddData::FILENAME) { - q->add([this, addMe]() + q->add([addMe]() { QFile original(addMe.filename); original.setPermissions(QFile::ReadOwner | QFile::WriteOwner); diff --git a/utils/remote.c b/utils/remote.c index f57c4b2c0..2f089dc05 100644 --- a/utils/remote.c +++ b/utils/remote.c @@ -2056,6 +2056,7 @@ static int processResponse(char const* rpcurl, void const* response, size_t len) } /* fall-through to default: to give success or failure msg */ + TR_GNUC_FALLTHROUGH; } default: