fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings
* fix: implicit fallthrough warning
* fixup! fix: implicit fallthrough warning
* fix: disable warnings for 3rd party code
Since we want to leave upstream code as-is
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: disable warnings for 3rd party code
* silence spurious alignment warning
Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: 90ac46f710/f/src/util/util_safealign.h (_35)
* fixup! fix: disable warnings for 3rd party code
* fixup! fix: implicit fallthrough warning
* make uncrustify happy
* remove uncrustify-test.sh
that's probably off-topic for this PR
* fixup! fix: __attribute__(__printf__) warnings
* Update libtransmission/CMakeLists.txt
Co-Authored-By: ckerr <ckerr@github.com>
* fixup! silence spurious alignment warning
* use -w for DISABLE_WARNINGS in Clang
* refactor: fix libtransmission deprecation warnings
* fix: pthread_create's start_routine's return value
This was defined as `void` on non-Windows but should have been `void*`
* chore: uncrustify
* fix: add DISABLE_WARNINGS option for SunPro Studio
* fix "unused in lambda capture" warnings by clang++
* fix 'increases required alignment' warning
Caused from storing int16_t's in a char array.
* fix net.c 'increases required alignment' warning
The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.
* make building quieter so warnings are more visible
* fixup! fix 'increases required alignment' warning
* Fix -Wcast-function-type warnings in GTK+ app code
https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.
GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.
Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.
In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).
* fixup! fix "unused in lambda capture" warnings by clang++
* fixup! fix "unused in lambda capture" warnings by clang++
* fix two more libtransmission compiler warnings
* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
This commit is contained in:
parent
8d7fbb5d45
commit
abac811dd2
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
14
gtk/main.c
14
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;
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -133,7 +133,7 @@ private:
|
|||
>::type* = nullptr>
|
||||
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
|
||||
{
|
||||
return [func](RpcResponseFuture const& r)
|
||||
return [func](RpcResponseFuture const&)
|
||||
{
|
||||
func();
|
||||
};
|
||||
|
|
|
@ -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<int> 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<int> const& ids, QString const& oldpath, QS
|
|||
tr("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p><p>Please correct the errors and try again.</p>").
|
||||
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("<p><b>%1</b></p><p>%2</p>").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("<p><b>Unable to add \"%1\".</b></p><p>It is a duplicate of \"%2\" which is already added.</p>").
|
||||
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);
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue