sonarcloud warnings 9 (#1511)

* refactor: const correctness 

* refactor: fix some implicit conversions

* refactor: make local pointers const if their objects are not modified

* refactor: do not cast away const in torrent-cell-renderer

* refactor: remove call to deprecated gtk_icon_size_lookup_for_settings

* refactor: member functions that do not mutate their objects should be declared const

* chore: do not end comments with a semicolon
This commit is contained in:
Charles Kerr 2020-11-08 21:31:02 -06:00 committed by GitHub
parent 6b0408b320
commit 9d313a8816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 1838 additions and 299 deletions

View File

@ -645,7 +645,7 @@ static void activity_model_update_idle(gpointer activity_model)
}
}
static void activity_torrent_model_row_changed(GtkTreeModel* tmodel, GtkTreePath* path, GtkTreeIter* iter,
static void activity_torrent_model_row_changed(GtkTreeModel const* tmodel, GtkTreePath const* path, GtkTreeIter const* iter,
gpointer activity_model)
{
TR_UNUSED(tmodel);
@ -655,7 +655,7 @@ static void activity_torrent_model_row_changed(GtkTreeModel* tmodel, GtkTreePath
activity_model_update_idle(activity_model);
}
static void activity_torrent_model_row_deleted_cb(GtkTreeModel* tmodel, GtkTreePath* path, gpointer activity_model)
static void activity_torrent_model_row_deleted_cb(GtkTreeModel const* tmodel, GtkTreePath const* path, gpointer activity_model)
{
TR_UNUSED(tmodel);
TR_UNUSED(path);
@ -726,16 +726,14 @@ static gboolean testText(tr_torrent const* tor, char const* key)
tr_info const* inf = tr_torrentInfo(tor);
/* test the torrent name... */
{
char* pch = g_utf8_casefold(tr_torrentName(tor), -1);
ret = key == NULL || strstr(pch, key) != NULL;
g_free(pch);
}
char* pch = g_utf8_casefold(tr_torrentName(tor), -1);
ret = key == NULL || strstr(pch, key) != NULL;
g_free(pch);
/* test the files... */
for (tr_file_index_t i = 0; i < inf->fileCount && !ret; ++i)
{
char* pch = g_utf8_casefold(inf->files[i].name, -1);
pch = g_utf8_casefold(inf->files[i].name, -1);
ret = key == NULL || strstr(pch, key) != NULL;
g_free(pch);
}
@ -916,7 +914,8 @@ static void update_count_label_idle(struct filter_data* data)
}
}
static void on_filter_model_row_inserted(GtkTreeModel* tree_model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
static void on_filter_model_row_inserted(GtkTreeModel const* tree_model, GtkTreePath const* path, GtkTreeIter const* iter,
gpointer data)
{
TR_UNUSED(tree_model);
TR_UNUSED(path);
@ -925,7 +924,7 @@ static void on_filter_model_row_inserted(GtkTreeModel* tree_model, GtkTreePath*
update_count_label_idle(data);
}
static void on_filter_model_row_deleted(GtkTreeModel* tree_model, GtkTreePath* path, gpointer data)
static void on_filter_model_row_deleted(GtkTreeModel const* tree_model, GtkTreePath const* path, gpointer data)
{
TR_UNUSED(tree_model);
TR_UNUSED(path);

View File

@ -49,12 +49,11 @@ static GdkPixbuf* create_void_pixbuf(int width, int height)
return p;
}
static int get_size_in_pixels(GtkWidget* widget, GtkIconSize icon_size)
static int get_size_in_pixels(GtkIconSize icon_size)
{
int width;
int height;
gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(widget), icon_size, &width, &height);
int width = 0;
int height = 0;
gtk_icon_size_lookup(icon_size, &width, &height);
return MAX(width, height);
}
@ -64,7 +63,7 @@ static IconCache* icon_cache_new(GtkWidget* for_widget, int icon_size)
IconCache* icons = g_new0(IconCache, 1);
icons->icon_theme = gtk_icon_theme_get_for_screen(gtk_widget_get_screen(for_widget));
icons->icon_size = get_size_in_pixels(for_widget, icon_size);
icons->icon_size = get_size_in_pixels(icon_size);
icons->cache = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref);
g_hash_table_insert(icons->cache, (void*)VOID_PIXBUF_KEY, create_void_pixbuf(icons->icon_size,

View File

@ -286,7 +286,7 @@ static void refresh_actions_soon(gpointer gdata)
}
}
static void on_selection_changed(GtkTreeSelection* s, gpointer gdata)
static void on_selection_changed(GtkTreeSelection const* s, gpointer gdata)
{
TR_UNUSED(s);
@ -332,7 +332,7 @@ static void ensure_magnet_handler_exists(void)
}
}
static void on_main_window_size_allocated(GtkWidget* gtk_window, GtkAllocation* alloc, gpointer gdata)
static void on_main_window_size_allocated(GtkWidget* gtk_window, GtkAllocation const* alloc, gpointer gdata)
{
TR_UNUSED(alloc);
TR_UNUSED(gdata);
@ -409,7 +409,7 @@ static gboolean on_rpc_changed_idle(gpointer gdata)
for (int i = 0; tr_variantDictChild(&tmp, i, &key, &newval); ++i)
{
bool changed;
tr_variant* oldval = tr_variantDictFind(oldvals, key);
tr_variant const* oldval = tr_variantDictFind(oldvals, key);
if (oldval == NULL)
{
@ -591,7 +591,7 @@ static void open_files(GSList* files, gpointer gdata)
gtr_core_add_files(cbdata->core, files, do_start, do_prompt, do_notify);
}
static void on_open(GApplication* application, GFile** f, gint file_count, gchar* hint, gpointer gdata)
static void on_open(GApplication const* application, GFile** f, gint file_count, gchar const* hint, gpointer gdata)
{
TR_UNUSED(application);
TR_UNUSED(hint);
@ -699,16 +699,16 @@ int main(int argc, char** argv)
return ret;
}
static void on_core_busy(TrCore* core, gboolean busy, struct cbdata* c)
static void on_core_busy(TrCore const* core, gboolean busy, struct cbdata* c)
{
TR_UNUSED(core);
gtr_window_set_busy(c->wind, busy);
}
static void on_core_error(TrCore*, guint, char const*, struct cbdata*);
static void on_core_error(TrCore const*, guint, char const*, struct cbdata*);
static void on_add_torrent(TrCore*, tr_ctor*, gpointer);
static void on_prefs_changed(TrCore* core, tr_quark const key, gpointer);
static void on_prefs_changed(TrCore const* core, tr_quark const key, gpointer);
static void main_window_setup(struct cbdata* cbdata, GtkWindow* wind);
static gboolean update_model_loop(gpointer gdata);
static gboolean update_model_once(gpointer gdata);
@ -777,6 +777,14 @@ static void app_setup(GtkWindow* wind, struct cbdata* cbdata)
}
}
static void placeWindowFromPrefs(GtkWindow* window)
{
gtk_window_resize(window, (int)gtr_pref_int_get(TR_KEY_main_window_width),
(int)gtr_pref_int_get(TR_KEY_main_window_height));
gtk_window_move(window, (int)gtr_pref_int_get(TR_KEY_main_window_x),
(int)gtr_pref_int_get(TR_KEY_main_window_y));
}
static void presentMainWindow(struct cbdata* cbdata)
{
GtkWindow* window = cbdata->wind;
@ -790,8 +798,7 @@ static void presentMainWindow(struct cbdata* cbdata)
if (!gtk_widget_get_visible(GTK_WIDGET(window)))
{
gtk_window_resize(window, gtr_pref_int_get(TR_KEY_main_window_width), gtr_pref_int_get(TR_KEY_main_window_height));
gtk_window_move(window, gtr_pref_int_get(TR_KEY_main_window_x), gtr_pref_int_get(TR_KEY_main_window_y));
placeWindowFromPrefs(window);
gtr_widget_set_visible(GTK_WIDGET(window), TRUE);
}
@ -821,7 +828,7 @@ static void toggleMainWindow(struct cbdata* cbdata)
static void on_app_exit(gpointer vdata);
static gboolean winclose(GtkWidget* w, GdkEvent* event, gpointer gdata)
static gboolean winclose(GtkWidget const* w, GdkEvent const* event, gpointer gdata)
{
TR_UNUSED(w);
TR_UNUSED(event);
@ -840,7 +847,7 @@ static gboolean winclose(GtkWidget* w, GdkEvent* event, gpointer gdata)
return TRUE; /* don't propagate event further */
}
static void rowChangedCB(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer gdata)
static void rowChangedCB(GtkTreeModel const* model, GtkTreePath* path, GtkTreeIter const* iter, gpointer gdata)
{
TR_UNUSED(model);
TR_UNUSED(iter);
@ -853,8 +860,8 @@ static void rowChangedCB(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* it
}
}
static void on_drag_data_received(GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y,
GtkSelectionData* selection_data, guint info, guint time_, gpointer gdata)
static void on_drag_data_received(GtkWidget const* widget, GdkDragContext* drag_context, gint x, gint y,
GtkSelectionData const* selection_data, guint info, guint time_, gpointer gdata)
{
TR_UNUSED(widget);
TR_UNUSED(x);
@ -956,11 +963,8 @@ static gpointer session_close_threadfunc(gpointer gdata)
return NULL;
}
static void exit_now_cb(GtkWidget* w, gpointer data)
static void exit_now_cb()
{
TR_UNUSED(w);
TR_UNUSED(data);
exit(0);
}
@ -1027,8 +1031,7 @@ static void on_app_exit(gpointer vdata)
/* ensure the window is in its previous position & size.
* this seems to be necessary because changing the main window's
* child seems to unset the size */
gtk_window_resize(cbdata->wind, gtr_pref_int_get(TR_KEY_main_window_width), gtr_pref_int_get(TR_KEY_main_window_height));
gtk_window_move(cbdata->wind, gtr_pref_int_get(TR_KEY_main_window_x), gtr_pref_int_get(TR_KEY_main_window_y));
placeWindowFromPrefs(cbdata->wind);
/* shut down libT */
session_close_data = g_new(struct session_close_struct, 1);
@ -1074,7 +1077,7 @@ static void flush_torrent_errors(struct cbdata* cbdata)
}
}
static void on_core_error(TrCore* core, guint code, char const* msg, struct cbdata* c)
static void on_core_error(TrCore const* core, guint code, char const* msg, struct cbdata* c)
{
TR_UNUSED(core);
@ -1098,7 +1101,7 @@ static void on_core_error(TrCore* core, guint code, char const* msg, struct cbda
}
}
static gboolean on_main_window_focus_in(GtkWidget* widget, GdkEventFocus* event, gpointer gdata)
static gboolean on_main_window_focus_in(GtkWidget const* widget, GdkEventFocus const* event, gpointer gdata)
{
TR_UNUSED(widget);
TR_UNUSED(event);
@ -1128,7 +1131,7 @@ static void on_add_torrent(TrCore* core, tr_ctor* ctor, gpointer gdata)
gtk_widget_show(w);
}
static void on_prefs_changed(TrCore* core, tr_quark const key, gpointer data)
static void on_prefs_changed(TrCore const* core, tr_quark const key, gpointer data)
{
TR_UNUSED(core);

View File

@ -130,7 +130,7 @@ static void onProgressDialogDestroyed(gpointer data, GObject* dead)
{
TR_UNUSED(dead);
MakeMetaUI* ui = data;
MakeMetaUI const* ui = data;
g_source_remove(ui->progress_tag);
}

View File

@ -102,16 +102,13 @@ static void g_signal_callback(GDBusProxy const* dbus_proxy, char const* sender_n
}
else if (g_strcmp0(signal_name, "ActionInvoked") == 0 && g_variant_is_of_type(params, G_VARIANT_TYPE("(us)")))
{
char* action;
tr_torrent* tor;
tor = gtr_core_find_torrent(n->core, n->torrent_id);
tr_torrent const* tor = gtr_core_find_torrent(n->core, n->torrent_id);
if (tor == NULL)
{
return;
}
char* action = NULL;
g_variant_get(params, "(u&s)", NULL, &action);
if (g_strcmp0(action, "folder") == 0)
@ -180,8 +177,6 @@ static void notify_callback(GObject* source, GAsyncResult* res, gpointer user_da
void gtr_notify_torrent_completed(TrCore* core, int torrent_id)
{
TrNotification* n;
tr_torrent* tor;
char const* cmd = gtr_pref_string_get(TR_KEY_torrent_complete_sound_command);
if (gtr_pref_flag_get(TR_KEY_torrent_complete_sound_enabled))
@ -196,9 +191,9 @@ void gtr_notify_torrent_completed(TrCore* core, int torrent_id)
g_return_if_fail(G_IS_DBUS_PROXY(proxy));
tor = gtr_core_find_torrent(core, torrent_id);
tr_torrent const* const tor = gtr_core_find_torrent(core, torrent_id);
n = g_new0(TrNotification, 1);
TrNotification* const n = g_new0(TrNotification, 1);
g_object_ref(G_OBJECT(core));
n->core = core;
n->torrent_id = torrent_id;

View File

@ -383,8 +383,8 @@ static void get_size_compact(TorrentCellRenderer* cell, GtkWidget* widget, gint*
GdkPixbuf* icon;
struct TorrentCellRendererPrivate* p = cell->priv;
tr_torrent const* tor = p->tor;
tr_stat const* st = tr_torrentStatCached((tr_torrent*)tor);
tr_torrent* tor = p->tor;
tr_stat const* st = tr_torrentStatCached(tor);
GString* gstr_stat = p->gstr1;
icon = get_icon(tor, COMPACT_ICON_SIZE, widget);
@ -433,8 +433,8 @@ static void get_size_full(TorrentCellRenderer* cell, GtkWidget* widget, gint* wi
GdkPixbuf* icon;
struct TorrentCellRendererPrivate* p = cell->priv;
tr_torrent const* tor = p->tor;
tr_stat const* st = tr_torrentStatCached((tr_torrent*)tor);
tr_torrent* tor = p->tor;
tr_stat const* st = tr_torrentStatCached(tor);
tr_info const* inf = tr_torrentInfo(tor);
GString* gstr_prog = p->gstr1;
GString* gstr_stat = p->gstr2;
@ -480,13 +480,13 @@ static void get_size_full(TorrentCellRenderer* cell, GtkWidget* widget, gint* wi
static void torrent_cell_renderer_get_size(GtkCellRenderer* cell, GtkWidget* widget, GdkRectangle const* cell_area,
gint* x_offset, gint* y_offset, gint* width, gint* height)
{
TorrentCellRenderer* self = TORRENT_CELL_RENDERER(cell);
TorrentCellRenderer const* const self = TORRENT_CELL_RENDERER(cell);
if (self != NULL && self->priv->tor != NULL)
{
int w;
int h;
struct TorrentCellRendererPrivate* p = self->priv;
struct TorrentCellRendererPrivate const* const p = self->priv;
if (p->compact)
{
@ -588,8 +588,8 @@ static void render_compact(TorrentCellRenderer* cell, GtrDrawable* window, GtkWi
bool seed;
struct TorrentCellRendererPrivate* p = cell->priv;
tr_torrent const* tor = p->tor;
tr_stat const* st = tr_torrentStatCached((tr_torrent*)tor);
tr_torrent* tor = p->tor;
tr_stat const* st = tr_torrentStatCached(tor);
gboolean const active = st->activity != TR_STATUS_STOPPED && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
st->activity != TR_STATUS_SEED_WAIT;
double const percentDone = get_percent_done(tor, st, &seed);
@ -666,8 +666,8 @@ static void render_full(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidge
bool seed;
struct TorrentCellRendererPrivate* p = cell->priv;
tr_torrent const* tor = p->tor;
tr_stat const* st = tr_torrentStatCached((tr_torrent*)tor);
tr_torrent* tor = p->tor;
tr_stat const* st = tr_torrentStatCached(tor);
tr_info const* inf = tr_torrentInfo(tor);
gboolean const active = st->activity != TR_STATUS_STOPPED && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
st->activity != TR_STATUS_SEED_WAIT;
@ -772,7 +772,7 @@ static void torrent_cell_renderer_render(GtkCellRenderer* cell, GtrDrawable* win
if (self != NULL && self->priv->tor != NULL)
{
struct TorrentCellRendererPrivate* p = self->priv;
struct TorrentCellRendererPrivate const* const p = self->priv;
if (p->compact)
{

View File

@ -1023,15 +1023,15 @@ static gboolean find_row_from_torrent_id(GtkTreeModel* model, int id, GtkTreeIte
static gboolean on_torrent_metadata_changed_idle(gpointer gdata)
{
struct notify_callback_data* data = gdata;
tr_session* session = gtr_core_session(data->core);
tr_torrent* tor = tr_torrentFindFromId(session, data->torrent_id);
struct notify_callback_data* const data = gdata;
tr_session* const session = gtr_core_session(data->core);
tr_torrent const* const tor = tr_torrentFindFromId(session, data->torrent_id);
/* update the torrent's collated name */
if (tor != NULL)
{
GtkTreeIter iter;
GtkTreeModel* model = core_raw_model(data->core);
GtkTreeModel* const model = core_raw_model(data->core);
if (find_row_from_torrent_id(model, data->torrent_id, &iter))
{
@ -1124,15 +1124,14 @@ void gtr_core_add_torrent(TrCore* core, tr_torrent* tor, gboolean do_notify)
static tr_torrent* core_create_new_torrent(TrCore* core, tr_ctor* ctor)
{
tr_torrent* tor;
bool do_trash = false;
tr_session* session = gtr_core_session(core);
tr_session const* const session = gtr_core_session(core);
/* let the gtk client handle the removal, since libT
* doesn't have any concept of the glib trash API */
tr_ctorGetDeleteSource(ctor, &do_trash);
tr_ctorSetDeleteSource(ctor, FALSE);
tor = tr_torrentNew(ctor, NULL, NULL);
tr_torrent* const tor = tr_torrentNew(ctor, NULL, NULL);
if (tor != NULL && do_trash)
{
@ -1266,7 +1265,7 @@ static void add_file_async_callback(GObject* file, GAsyncResult* result, gpointe
static bool add_file(TrCore* core, GFile* file, gboolean do_start, gboolean do_prompt, gboolean do_notify)
{
bool handled = false;
tr_session* session = gtr_core_session(core);
tr_session const* const session = gtr_core_session(core);
if (session != NULL)
{

View File

@ -766,16 +766,15 @@ GtkWidget* gtr_window_new(GtkApplication* app, GtkUIManager* ui_mgr, TrCore* cor
static void updateStats(PrivateData* p)
{
char const* pch;
char up[32];
char down[32];
char ratio[32];
char buf[512];
struct tr_session_stats stats;
tr_session* session = gtr_core_session(p->core);
tr_session const* const session = gtr_core_session(p->core);
/* update the stats */
pch = gtr_pref_string_get(TR_KEY_statusbar_stats);
char const* pch = gtr_pref_string_get(TR_KEY_statusbar_stats);
if (g_strcmp0(pch, "session-ratio") == 0)
{
@ -815,7 +814,7 @@ static void updateStats(PrivateData* p)
static void updateSpeeds(PrivateData* p)
{
tr_session* session = gtr_core_session(p->core);
tr_session const* const session = gtr_core_session(p->core);
if (session != NULL)
{

View File

@ -369,7 +369,7 @@ bool gtr_file_trash_or_remove(char const* filename, tr_error** error)
char const* gtr_get_help_uri(void)
{
static char* uri = NULL;
static char const* uri = NULL;
if (uri == NULL)
{
@ -534,7 +534,7 @@ void gtr_widget_set_visible(GtkWidget* w, gboolean b)
if (GTK_IS_WINDOW(w))
{
GList* windows = gtk_window_list_toplevels();
GtkWindow* window = GTK_WINDOW(w);
GtkWindow const* const window = GTK_WINDOW(w);
for (GList* l = windows; l != NULL; l = l->next)
{
@ -621,7 +621,7 @@ void gtr_paste_clipboard_url_into_entry(GtkWidget* e)
for (size_t i = 0; i < G_N_ELEMENTS(text); ++i)
{
char* s = text[i];
char const* const s = text[i];
if (s != NULL && (gtr_is_supported_url(s) || gtr_is_magnet_link(s) || gtr_is_hex_hashcode(s)))
{

View File

@ -779,7 +779,7 @@ bool tr_announcerCanManualAnnounce(tr_torrent const* tor)
TR_ASSERT(tr_isTorrent(tor));
TR_ASSERT(tor->tiers != NULL);
struct tr_torrent_tiers* tt = NULL;
struct tr_torrent_tiers const* tt = NULL;
if (tor->isRunning)
{
@ -801,7 +801,7 @@ bool tr_announcerCanManualAnnounce(tr_torrent const* tor)
time_t tr_announcerNextManualAnnounce(tr_torrent const* tor)
{
time_t ret = ~(time_t)0;
struct tr_torrent_tiers* tt = tor->tiers;
struct tr_torrent_tiers const* tt = tor->tiers;
/* find the earliest manual announce time from all peers */
for (int i = 0; tt != NULL && i < tt->tier_count; ++i)
@ -989,13 +989,13 @@ static void announce_request_free(tr_announce_request* req);
void tr_announcerRemoveTorrent(tr_announcer* announcer, tr_torrent* tor)
{
struct tr_torrent_tiers* tt = tor->tiers;
struct tr_torrent_tiers const* tt = tor->tiers;
if (tt != NULL)
{
for (int i = 0; i < tt->tier_count; ++i)
{
tr_tier* tier = &tt->tiers[i];
tr_tier const* tier = &tt->tiers[i];
if (tier->isRunning)
{
@ -1767,12 +1767,11 @@ tr_tracker_stat* tr_announcerStats(tr_torrent const* torrent, int* setmeTrackerC
time_t const now = tr_time();
int out = 0;
tr_tracker_stat* ret;
struct tr_torrent_tiers* tt = torrent->tiers;
struct tr_torrent_tiers const* const tt = torrent->tiers;
/* alloc the stats */
*setmeTrackerCount = tt->tracker_count;
ret = tr_new0(tr_tracker_stat, tt->tracker_count);
tr_tracker_stat* const ret = tr_new0(tr_tracker_stat, tt->tracker_count);
/* populate the stats */
for (int i = 0; i < tt->tier_count; ++i)

View File

@ -221,13 +221,12 @@ bool tr_blocklistFileHasAddress(tr_blocklistFile* b, tr_address const* addr)
*/
static bool parseLine1(char const* line, struct tr_ipv4_range* range)
{
char* walk;
int b[4];
int e[4];
char str[64];
tr_address addr;
walk = strrchr(line, ':');
char const* walk = strrchr(line, ':');
if (walk == NULL)
{

View File

@ -365,7 +365,7 @@ int tr_cacheReadBlock(tr_cache* cache, tr_torrent* torrent, tr_piece_index_t pie
int tr_cachePrefetchBlock(tr_cache* cache, tr_torrent* torrent, tr_piece_index_t piece, uint32_t offset, uint32_t len)
{
int err = 0;
struct cache_block* cb = findBlock(cache, torrent, piece, offset);
struct cache_block const* const cb = findBlock(cache, torrent, piece, offset);
if (cb == NULL)
{

View File

@ -1190,7 +1190,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((DIR*)handle);
struct dirent const* const entry = readdir((DIR*)handle);
if (entry != NULL)
{

View File

@ -798,7 +798,6 @@ static ReadState readCryptoProvide(tr_handshake* handshake, struct evbuffer* inb
uint8_t obfuscatedTorrentHash[SHA_DIGEST_LENGTH];
uint16_t padc_len = 0;
uint32_t crypto_provide = 0;
tr_torrent* tor;
size_t const needlen = SHA_DIGEST_LENGTH + /* HASH('req1', s) */
SHA_DIGEST_LENGTH + /* HASH('req2', SKEY) xor HASH('req3', S) */
VC_LENGTH + sizeof(crypto_provide) + sizeof(padc_len);
@ -823,6 +822,7 @@ static ReadState readCryptoProvide(tr_handshake* handshake, struct evbuffer* inb
obfuscatedTorrentHash[i] = req2[i] ^ req3[i];
}
tr_torrent const* tor;
if ((tor = tr_torrentFindFromObfuscatedHash(handshake->session, obfuscatedTorrentHash)) != NULL)
{
bool const clientIsSeed = tr_torrentIsSeed(tor);

View File

@ -636,7 +636,7 @@ static int tr_globalAddress(int af, void* addr, int* addr_len)
socklen_t sslen = sizeof(ss);
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
struct sockaddr* sa;
struct sockaddr const* sa;
socklen_t salen;
int rc;
@ -647,7 +647,7 @@ static int tr_globalAddress(int af, void* addr, int* addr_len)
sin.sin_family = AF_INET;
evutil_inet_pton(AF_INET, "91.121.74.28", &sin.sin_addr);
sin.sin_port = htons(6969);
sa = (struct sockaddr*)&sin;
sa = (struct sockaddr const*)&sin;
salen = sizeof(sin);
break;
@ -658,7 +658,7 @@ static int tr_globalAddress(int af, void* addr, int* addr_len)
a native IPv6 address, not Teredo or 6to4. */
evutil_inet_pton(AF_INET6, "2001:1890:1112:1::20", &sin6.sin6_addr);
sin6.sin6_port = htons(6969);
sa = (struct sockaddr*)&sin6;
sa = (struct sockaddr const*)&sin6;
salen = sizeof(sin6);
break;

View File

@ -489,7 +489,7 @@ static void utp_on_write(void* closure, unsigned char* buf, size_t buflen)
static size_t utp_get_rb_size(void* closure)
{
tr_peerIo* io = closure;
tr_peerIo const* const io = closure;
TR_ASSERT(tr_isPeerIo(io));

View File

@ -444,7 +444,7 @@ static void replicationNew(tr_swarm* s)
for (int peer_i = 0; peer_i < n; ++peer_i)
{
tr_peer* peer = tr_ptrArrayNth(&s->peers, peer_i);
tr_peer const* const peer = tr_ptrArrayNth(&s->peers, peer_i);
if (tr_bitfieldHas(&peer->have, piece_i))
{
@ -1113,10 +1113,10 @@ static void pieceListRebuild(tr_swarm* s)
* the new list so we don't lose its requestCounts */
if (s->pieces != NULL)
{
struct weighted_piece* o = s->pieces;
struct weighted_piece* oend = o + s->pieceCount;
struct weighted_piece const* o = s->pieces;
struct weighted_piece const* const oend = o + s->pieceCount;
struct weighted_piece* n = pieces;
struct weighted_piece* nend = n + pieceCount;
struct weighted_piece const* const nend = n + pieceCount;
pieceListSort(s, PIECES_SORTED_BY_INDEX);
@ -1151,7 +1151,7 @@ static void pieceListRebuild(tr_swarm* s)
static void pieceListRemovePiece(tr_swarm* s, tr_piece_index_t piece)
{
struct weighted_piece* p;
struct weighted_piece const* p;
if ((p = pieceListLookup(s, piece)) != NULL)
{
@ -1541,7 +1541,7 @@ static void refillUpkeep(evutil_socket_t fd, short what, void* vmgr)
for (int i = 0; i < n; ++i)
{
struct block_request const* const request = &s->requests[i];
tr_peerMsgs* msgs = PEER_MSGS(request->peer);
tr_peerMsgs const* const msgs = PEER_MSGS(request->peer);
if (msgs != NULL && request->sentAt <= too_old && !tr_peerMsgsIsReadingBlock(msgs, request->block))
{
@ -2094,7 +2094,7 @@ static bool myHandshakeDoneCB(tr_handshake* handshake, tr_peerIo* io, bool readA
}
else
{
tr_peer* peer = atom->peer;
tr_peer const* const peer = atom->peer;
if (peer != NULL)
{
@ -2789,7 +2789,7 @@ struct tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, int* setmeCount)
{
char* pch;
tr_peer* peer = peers[i];
tr_peerMsgs* msgs = PEER_MSGS(peer);
tr_peerMsgs const* const msgs = PEER_MSGS(peer);
struct peer_atom const* atom = peer->atom;
tr_peer_stat* stat = ret + i;
@ -3675,8 +3675,8 @@ static void enforceTorrentPeerLimit(tr_swarm* s, uint64_t now)
if (n > max)
{
void* base = tr_ptrArrayBase(&s->peers);
tr_peer** peers = tr_memdup(base, n * sizeof(tr_peer*));
void const* const base = tr_ptrArrayBase(&s->peers);
tr_peer** const peers = tr_memdup(base, n * sizeof(tr_peer*));
sortPeersByLiveliness(peers, NULL, n, now);
while (n > max)

View File

@ -1065,17 +1065,16 @@ static void parseLtepHandshake(tr_peerMsgs* msgs, uint32_t len, struct evbuffer*
static void parseUtMetadata(tr_peerMsgs* msgs, uint32_t msglen, struct evbuffer* inbuf)
{
tr_variant dict;
char* msg_end;
char const* benc_end;
int64_t msg_type = -1;
int64_t piece = -1;
int64_t total_size = 0;
uint8_t* tmp = tr_new(uint8_t, msglen);
uint8_t* const tmp = tr_new(uint8_t, msglen);
tr_peerIoReadBytes(msgs->io, inbuf, tmp, msglen);
msg_end = (char*)tmp + msglen;
char const* const msg_end = (char const*)tmp + msglen;
tr_variant dict;
char const* benc_end;
if (tr_variantFromBencFull(&dict, tmp, msglen, NULL, &benc_end) == 0)
{
(void)tr_variantDictFindInt(&dict, TR_KEY_msg_type, &msg_type);
@ -1883,7 +1882,7 @@ bool tr_peerMsgsIsReadingBlock(tr_peerMsgs const* msgs, tr_block_index_t block)
static void updateDesiredRequestCount(tr_peerMsgs* msgs)
{
tr_torrent* const torrent = msgs->torrent;
tr_torrent const* const torrent = msgs->torrent;
/* there are lots of reasons we might not want to request any blocks... */
if (tr_torrentIsSeed(torrent) || !tr_torrentHasMetadata(torrent) || msgs->client_is_choked || !msgs->client_is_interested)

View File

@ -105,7 +105,7 @@ static char const* getdev(char const* path)
#else
struct mntent* mnt;
struct mntent const* mnt;
fp = setmntent(_PATH_MOUNTED, "r");
@ -181,7 +181,7 @@ static char const* getfstype(char const* device)
#else
struct mntent* mnt;
struct mntent const* mnt;
fp = setmntent(_PATH_MOUNTED, "r");

View File

@ -253,7 +253,7 @@ static char* win32_get_known_folder(REFKNOWNFOLDERID folder_id)
static char const* getHomeDir(void)
{
static char* home = NULL;
static char const* home = NULL;
if (home == NULL)
{
@ -328,7 +328,7 @@ char const* tr_getResumeDir(tr_session const* session)
char const* tr_getDefaultConfigDir(char const* appname)
{
static char* s = NULL;
static char const* s = NULL;
if (tr_str_is_empty(appname))
{
@ -380,7 +380,7 @@ char const* tr_getDefaultConfigDir(char const* appname)
char const* tr_getDefaultDownloadDir(void)
{
static char* user_dir = NULL;
static char const* user_dir = NULL;
if (user_dir == NULL)
{
@ -477,7 +477,7 @@ static bool isWebClientDir(char const* path)
char const* tr_getWebClientDir(tr_session const* session)
{
static char* s = NULL;
static char const* s = NULL;
if (s == NULL)
{

View File

@ -242,7 +242,7 @@ static void* tr_ptrArrayRemoveSortedValue(tr_ptrArray* t, void const* ptr, tr_vo
void tr_ptrArrayRemoveSortedPointer(tr_ptrArray* t, void const* ptr, tr_voidptr_compare_func compare)
{
void* removed = tr_ptrArrayRemoveSortedValue(t, ptr, compare);
void const* removed = tr_ptrArrayRemoveSortedValue(t, ptr, compare);
#ifndef TR_ENABLE_ASSERTS

View File

@ -436,19 +436,16 @@ static tr_ptrArray my_runtime = TR_PTR_ARRAY_INIT_STATIC;
bool tr_quark_lookup(void const* str, size_t len, tr_quark* setme)
{
static size_t const n_static = TR_N_ELEMENTS(my_static);
TR_ASSERT(n_static == TR_N_KEYS);
struct tr_key_struct tmp;
struct tr_key_struct* match;
bool success = false;
tmp.str = str;
tmp.len = len;
/* is it in our static array? */
match = bsearch(&tmp, my_static, n_static, sizeof(struct tr_key_struct), compareKeys);
struct tr_key_struct const* const match = bsearch(&tmp, my_static, n_static, sizeof(struct tr_key_struct), compareKeys);
bool success = false;
if (match != NULL)
{
*setme = match - my_static;

View File

@ -666,8 +666,8 @@ static uint64_t loadProgress(tr_variant* dict, tr_torrent* tor)
err = NULL;
tr_bitfieldConstruct(&blocks, tor->blockCount);
tr_variant* b;
if ((b = tr_variantDictFind(prog, TR_KEY_blocks)) != NULL)
tr_variant const* const b = tr_variantDictFind(prog, TR_KEY_blocks);
if (b != NULL)
{
size_t buflen;
uint8_t const* buf;

View File

@ -729,7 +729,7 @@ static void loadBlocklists(tr_session* session);
static void tr_sessionInitImpl(void* vdata)
{
struct init_data* data = vdata;
tr_variant* clientSettings = data->clientSettings;
tr_variant const* const clientSettings = data->clientSettings;
tr_session* session = data->session;
TR_ASSERT(tr_amInEventThread(session));

View File

@ -787,7 +787,7 @@ static void refreshCurrentDir(tr_torrent* tor);
static void torrentInitFromInfo(tr_torrent* tor)
{
uint64_t t;
tr_info* info = &tor->info;
tr_info const* const info = &tor->info;
tor->blockSize = tr_getBlockSize(info->pieceSize);

View File

@ -133,7 +133,7 @@ static void incoming(void* closure, struct UTPSocket* s)
void tr_utpSendTo(void* closure, unsigned char const* buf, size_t buflen, struct sockaddr const* to, socklen_t tolen)
{
tr_session* ss = closure;
tr_session const* const ss = closure;
if (to->sa_family == AF_INET && ss->udp_socket != TR_BAD_SOCKET)
{

View File

@ -557,21 +557,19 @@ static void jsonStringFunc(tr_variant const* val, void* vdata)
{
char* out;
char* outwalk;
char* outend;
struct evbuffer_iovec vec[1];
struct jsonWalk* data = vdata;
struct jsonWalk* const data = vdata;
unsigned char const* it;
unsigned char const* end;
char const* str = NULL;
size_t len = 0;
(void)tr_variantGetStr(val, &str, &len);
it = (unsigned char const*)str;
end = it + len;
unsigned char const* const end = it + len;
evbuffer_reserve_space(data->out, len * 4, vec, 1);
out = vec[0].iov_base;
outend = out + vec[0].iov_len;
char const* const outend = out + vec[0].iov_len;
outwalk = out;
*outwalk++ = '"';

View File

@ -433,7 +433,7 @@ bool tr_variantDictFindReal(tr_variant* dict, tr_quark const key, double* setme)
bool tr_variantDictFindStr(tr_variant* dict, tr_quark const key, char const** setme, size_t* len)
{
tr_variant* child = tr_variantDictFind(dict, key);
tr_variant const* const child = tr_variantDictFind(dict, key);
return tr_variantGetStr(child, setme, len);
}

View File

@ -71,7 +71,7 @@ static void tr_watchdir_inotify_on_event(struct bufferevent* event, void* contex
tr_watchdir_t const handle = context;
#ifdef TR_ENABLE_ASSERTS
tr_watchdir_inotify* const backend = BACKEND_UPCAST(tr_watchdir_get_backend(handle));
tr_watchdir_inotify const* const backend = BACKEND_UPCAST(tr_watchdir_get_backend(handle));
#endif
struct inotify_event ev;
size_t nread;

View File

@ -113,7 +113,7 @@ static size_t writeFunc(void* ptr, size_t size, size_t nmemb, void* vtask)
/* webseed downloads should be speed limited */
if (task->torrentId != -1)
{
tr_torrent* tor = tr_torrentFindFromId(task->session, task->torrentId);
tr_torrent const* const tor = tr_torrentFindFromId(task->session, task->torrentId);
if (tor != NULL && tr_bandwidthClamp(&tor->bandwidth, TR_DOWN, nmemb) == 0)
{
@ -133,7 +133,7 @@ static int sockoptfunction(void* vtask, curl_socket_t fd, curlsocktype purpose)
{
TR_UNUSED(purpose);
struct tr_web_task* task = vtask;
struct tr_web_task const* const task = vtask;
bool const isScrape = strstr(task->url, "scrape") != NULL;
bool const isAnnounce = strstr(task->url, "announce") != NULL;

View File

@ -201,7 +201,7 @@ static void connection_succeeded(void* vdata)
if (data->real_url != NULL)
{
tr_torrent* tor = tr_torrentFindFromId(w->session, w->torrent_id);
tr_torrent const* const tor = tr_torrentFindFromId(w->session, w->torrent_id);
if (tor != NULL)
{
@ -558,8 +558,8 @@ static void webseed_destruct(tr_peer* peer)
/* if we have an array of file URLs, free it */
if (w->file_urls != NULL)
{
tr_torrent* tor = tr_torrentFindFromId(w->session, w->torrent_id);
tr_info const* inf = tr_torrentInfo(tor);
tr_torrent const* const tor = tr_torrentFindFromId(w->session, w->torrent_id);
tr_info const* const inf = tr_torrentInfo(tor);
for (tr_file_index_t i = 0; i < inf->fileCount; ++i)
{

View File

@ -37,7 +37,7 @@ bool ComInteropHelper::isConnected() const
return !client_->isNull();
}
QVariant ComInteropHelper::addMetainfo(QString const& metainfo)
QVariant ComInteropHelper::addMetainfo(QString const& metainfo) const
{
return client_->dynamicCall("AddMetainfo(QString)", metainfo);
}

View File

@ -23,7 +23,7 @@ public:
bool isConnected() const;
QVariant addMetainfo(QString const& metainfo);
QVariant addMetainfo(QString const& metainfo) const;
static void initialize();
static void registerObject(QObject* parent);

View File

@ -21,7 +21,7 @@ bool DBusInteropHelper::isConnected() const
return QDBusConnection::sessionBus().isConnected();
}
QVariant DBusInteropHelper::addMetainfo(QString const& metainfo)
QVariant DBusInteropHelper::addMetainfo(QString const& metainfo) const
{
auto request = QDBusMessage::createMethodCall(
QStringLiteral("com.transmissionbt.Transmission"),

View File

@ -19,7 +19,7 @@ public:
bool isConnected() const;
QVariant addMetainfo(QString const& metainfo);
QVariant addMetainfo(QString const& metainfo) const;
static void registerObject(QObject* parent);
};

View File

@ -393,6 +393,7 @@ void DetailsDialog::refreshUI()
QString const mixed = tr("Mixed");
QString const unknown = tr("Unknown");
auto const now = time(nullptr);
auto const& fmt = Formatter::get();
// build a list of torrents
for (int const id : ids_)
@ -501,13 +502,14 @@ void DetailsDialog::refreshUI()
double const d = size_when_done == 0 ?
100.0 :
100.0 * static_cast<double>(size_when_done - left_until_done) / static_cast<double>(size_when_done);
auto const pct = Formatter::get().percentToString(d);
auto const pct = fmt.percentToString(d);
auto const size_when_done_str = fmt.sizeToString(size_when_done);
if (have_unverified == 0 && left_until_done == 0)
{
//: Text following the "Have:" label in torrent properties dialog;
//: %1 is amount of downloaded and verified data
string = tr("%1 (100%)").arg(Formatter::get().sizeToString(have_verified));
string = tr("%1 (100%)").arg(fmt.sizeToString(have_verified));
}
else if (have_unverified == 0)
{
@ -515,9 +517,10 @@ void DetailsDialog::refreshUI()
//: %1 is amount of downloaded and verified data,
//: %2 is overall size of torrent data,
//: %3 is percentage (%1/%2*100)
string = tr("%1 of %2 (%3%)").arg(Formatter::get().sizeToString(have_verified)).arg(Formatter::get().sizeToString(
size_when_done)).
arg(pct);
string = tr("%1 of %2 (%3%)")
.arg(fmt.sizeToString(have_verified))
.arg(size_when_done_str)
.arg(pct);
}
else
{
@ -526,8 +529,11 @@ void DetailsDialog::refreshUI()
//: %2 is overall size of torrent data,
//: %3 is percentage (%1/%2*100),
//: %4 is amount of downloaded but not yet verified data
string = tr("%1 of %2 (%3%), %4 Unverified").arg(Formatter::get().sizeToString(have_verified + have_unverified)).
arg(Formatter::get().sizeToString(size_when_done)).arg(pct).arg(Formatter::get().sizeToString(have_unverified));
string = tr("%1 of %2 (%3%), %4 Unverified")
.arg(fmt.sizeToString(have_verified + have_unverified))
.arg(size_when_done_str)
.arg(pct)
.arg(fmt.sizeToString(have_unverified));
}
}
@ -541,7 +547,7 @@ void DetailsDialog::refreshUI()
else
{
auto const percent = 100.0 * static_cast<double>(available) / static_cast<double>(size_when_done);
string = QStringLiteral("%1%").arg(Formatter::get().percentToString(percent));
string = QStringLiteral("%1%").arg(fmt.percentToString(percent));
}
ui_.availabilityValueLabel->setText(string);
@ -553,8 +559,8 @@ void DetailsDialog::refreshUI()
}
else
{
uint64_t d = 0;
uint64_t f = 0;
auto d = uint64_t{};
auto f = uint64_t{};
for (Torrent const* const t : torrents)
{
@ -562,8 +568,8 @@ void DetailsDialog::refreshUI()
f += t->failedEver();
}
QString const dstr = Formatter::get().sizeToString(d);
QString const fstr = Formatter::get().sizeToString(f);
QString const dstr = fmt.sizeToString(d);
QString const fstr = fmt.sizeToString(f);
if (f != 0)
{
@ -584,8 +590,8 @@ void DetailsDialog::refreshUI()
}
else
{
uint64_t u = 0;
uint64_t d = 0;
auto u = uint64_t{};
auto d = uint64_t{};
for (Torrent const* const t : torrents)
{
@ -593,8 +599,9 @@ void DetailsDialog::refreshUI()
d += t->downloadedEver();
}
string = tr("%1 (Ratio: %2)").arg(Formatter::get().sizeToString(u)).arg(Formatter::get().ratioToString(tr_getRatio(u,
d)));
string = tr("%1 (Ratio: %2)")
.arg(fmt.sizeToString(u))
.arg(fmt.ratioToString(tr_getRatio(u, d)));
}
ui_.uploadedValueLabel->setText(string);
@ -633,7 +640,7 @@ void DetailsDialog::refreshUI()
else
{
auto const seconds = int(std::difftime(now, baseline));
string = Formatter::get().timeToString(seconds);
string = fmt.timeToString(seconds);
}
}
@ -667,7 +674,7 @@ void DetailsDialog::refreshUI()
}
else
{
string = Formatter::get().timeToString(baseline);
string = fmt.timeToString(baseline);
}
}
}
@ -705,7 +712,7 @@ void DetailsDialog::refreshUI()
}
else
{
string = tr("%1 ago").arg(Formatter::get().timeToString(seconds));
string = tr("%1 ago").arg(fmt.timeToString(seconds));
}
}
@ -748,7 +755,7 @@ void DetailsDialog::refreshUI()
else
{
int pieces = 0;
uint64_t size = 0;
auto size = uint64_t{};
uint32_t piece_size = torrents[0]->pieceSize();
for (Torrent const* const t : torrents)
@ -768,12 +775,14 @@ void DetailsDialog::refreshUI()
}
else if (piece_size > 0)
{
string = tr("%1 (%Ln pieces @ %2)", "", pieces).arg(Formatter::get().sizeToString(size)).
arg(Formatter::get().memToString(piece_size));
string = tr("%1 (%Ln pieces @ %2)", "", pieces)
.arg(fmt.sizeToString(size))
.arg(fmt.memToString(piece_size));
}
else
{
string = tr("%1 (%Ln pieces)", "", pieces).arg(Formatter::get().sizeToString(size));
string = tr("%1 (%Ln pieces)", "", pieces)
.arg(fmt.sizeToString(size));
}
}
@ -1144,9 +1153,9 @@ void DetailsDialog::refreshUI()
code_tip.resize(code_tip.size() - 1); // eat the trailing linefeed
}
item->setText(COL_UP, peer.rate_to_peer.isZero() ? QString() : Formatter::get().speedToString(peer.rate_to_peer));
item->setText(COL_UP, peer.rate_to_peer.isZero() ? QString() : fmt.speedToString(peer.rate_to_peer));
item->setText(COL_DOWN,
peer.rate_to_client.isZero() ? QString() : Formatter::get().speedToString(peer.rate_to_client));
peer.rate_to_client.isZero() ? QString() : fmt.speedToString(peer.rate_to_client));
item->setText(COL_PERCENT, peer.progress > 0 ? QStringLiteral("%1%").arg(int(peer.progress * 100.0)) :
QString());
item->setText(COL_STATUS, code);
@ -1484,7 +1493,7 @@ void DetailsDialog::initPeersTab()
****
***/
void DetailsDialog::initFilesTab()
void DetailsDialog::initFilesTab() const
{
connect(ui_.filesView, &FileTreeView::openRequested, this, &DetailsDialog::onOpenRequested);
connect(ui_.filesView, &FileTreeView::pathEdited, this, &DetailsDialog::onPathEdited);
@ -1525,7 +1534,7 @@ void DetailsDialog::onPathEdited(QString const& oldpath, QString const& newname)
session_.torrentRenamePath(ids_, oldpath, newname);
}
void DetailsDialog::onOpenRequested(QString const& path)
void DetailsDialog::onOpenRequested(QString const& path) const
{
if (!session_.isLocal())
{

1569
qt/DetailsDialog.cc.orig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ private:
void initPeersTab();
void initTrackerTab();
void initInfoTab();
void initFilesTab();
void initFilesTab() const;
void initOptionsTab();
QIcon getStockIcon(QString const& freedesktop_name, int fallback) const;
@ -79,7 +79,7 @@ private slots:
void onFilePriorityChanged(QSet<int> const& file_indices, int);
void onFileWantedChanged(QSet<int> const& file_indices, bool);
void onPathEdited(QString const& old_path, QString const& new_name);
void onOpenRequested(QString const& path);
void onOpenRequested(QString const& path) const;
// Options tab
void onBandwidthPriorityChanged(int);

View File

@ -33,7 +33,7 @@ FaviconCache::FaviconCache() :
namespace
{
QPixmap scale(QPixmap pixmap)
QPixmap scale(QPixmap const& pixmap)
{
return pixmap.scaled(FaviconCache::getIconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
}

View File

@ -22,7 +22,7 @@
QHash<QString, int> const& FileTreeItem::getMyChildRows()
{
size_t const n = childCount();
int const n = childCount();
// ensure that all the rows are hashed
while (first_unhashed_row_ < n)
@ -50,7 +50,7 @@ FileTreeItem::~FileTreeItem()
void FileTreeItem::appendChild(FileTreeItem* child)
{
size_t const n = childCount();
int const n = childCount();
child->parent_ = this;
children_.append(child);
first_unhashed_row_ = n;

View File

@ -107,7 +107,7 @@ private:
QString name_;
uint64_t const total_size_ = {};
uint64_t have_size_ = {};
size_t first_unhashed_row_ = {};
int first_unhashed_row_ = {};
int const file_index_ = {};
int priority_ = {};
bool is_wanted_ = {};

View File

@ -202,33 +202,7 @@ void FileTreeView::update(FileList const& files, bool update_fields)
if (model_was_empty)
{
// expand up until the item with more than one expandable child
for (QModelIndex index = proxy_->index(0, 0); index.isValid();)
{
QModelIndex const old_index = index;
expand(old_index);
index = QModelIndex();
for (int i = 0, count = proxy_->rowCount(old_index); i < count; ++i)
{
QModelIndex const new_index = proxy_->index(i, 0, old_index);
if (proxy_->rowCount(new_index) == 0)
{
continue;
}
if (index.isValid())
{
index = QModelIndex();
break;
}
index = new_index;
}
}
expand(proxy_->index(0, 0));
}
proxy_->sort(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
@ -325,16 +299,13 @@ void FileTreeView::onlyCheckSelectedItems()
{
unwanted_indices << child_index;
}
else if (!wanted_indices_parents.contains(child_index))
{
unwanted_indices << child_index;
}
else
{
if (!wanted_indices_parents.contains(child_index))
{
unwanted_indices << child_index;
}
else
{
parents_queue.enqueue(child_index);
}
parents_queue.enqueue(child_index);
}
}
}
@ -344,7 +315,7 @@ void FileTreeView::onlyCheckSelectedItems()
void FileTreeView::setSelectedItemsPriority()
{
auto* action = qobject_cast<QAction*>(sender());
auto const* action = qobject_cast<QAction const*>(sender());
assert(action != nullptr);
model_->setPriority(selectedSourceRows(), action->property(PriorityKey).toInt());
}

View File

@ -92,7 +92,7 @@ FilterBarComboBox* FilterBar::createActivityCombo()
namespace
{
QString getCountString(int n)
QString getCountString(size_t n)
{
return QStringLiteral("%L1").arg(n);
}
@ -136,7 +136,7 @@ void FilterBar::refreshTrackers()
i->setData(display_name, Qt::DisplayRole);
i->setData(display_name, TRACKER_ROLE);
i->setData(getCountString(count), FilterBarComboBox::CountStringRole);
i->setData(getCountString(static_cast<size_t>(count)), FilterBarComboBox::CountStringRole);
i->setData(icon, Qt::DecorationRole);
i->setData(int(count), FilterBarComboBox::CountRole);
@ -192,7 +192,7 @@ FilterBarComboBox* FilterBar::createTrackerCombo(QStandardItemModel* model)
row->setData(QString(), TRACKER_ROLE);
int const count = torrents_.rowCount();
row->setData(count, FilterBarComboBox::CountRole);
row->setData(getCountString(count), FilterBarComboBox::CountStringRole);
row->setData(getCountString(static_cast<size_t>(count)), FilterBarComboBox::CountStringRole);
model->appendRow(row);
model->appendRow(new QStandardItem); // separator
@ -380,7 +380,7 @@ void FilterBar::recount()
auto const mode = index.data(ACTIVITY_ROLE).toInt();
auto const count = torrents_per_mode[mode];
model->setData(index, count, FilterBarComboBox::CountRole);
model->setData(index, getCountString(count), FilterBarComboBox::CountStringRole);
model->setData(index, getCountString(static_cast<size_t>(count)), FilterBarComboBox::CountStringRole);
}
}

View File

@ -73,13 +73,8 @@ QString Formatter::memToString(int64_t bytes) const
return QString::fromUtf8(buf.data());
}
QString Formatter::sizeToString(int64_t bytes) const
QString Formatter::sizeToString(uint64_t bytes) const
{
if (bytes < 0)
{
return tr("Unknown");
}
if (bytes == 0)
{
return tr("None");
@ -90,6 +85,16 @@ QString Formatter::sizeToString(int64_t bytes) const
return QString::fromUtf8(buf.data());
}
QString Formatter::sizeToString(int64_t bytes) const
{
if (bytes < 0)
{
return tr("Unknown");
}
return Formatter::sizeToString(static_cast<uint64_t>(bytes));
}
QString Formatter::speedToString(Speed const& speed) const
{
auto buf = std::array<char, 128>{};

View File

@ -49,6 +49,7 @@ public:
QString memToString(int64_t bytes) const;
QString sizeToString(int64_t bytes) const;
QString sizeToString(uint64_t bytes) const;
QString speedToString(Speed const& speed) const;
QString percentToString(double x) const;
QString ratioToString(double ratio) const;

View File

@ -29,7 +29,7 @@ bool InteropHelper::isConnected() const
return is_connected;
}
bool InteropHelper::addMetainfo(QString const& metainfo)
bool InteropHelper::addMetainfo(QString const& metainfo) const
{
#ifdef ENABLE_DBUS_INTEROP

View File

@ -22,7 +22,7 @@ class InteropHelper
public:
bool isConnected() const;
bool addMetainfo(QString const& metainfo);
bool addMetainfo(QString const& metainfo) const;
static void initialize();
static void registerObject(QObject* parent);

View File

@ -16,14 +16,14 @@ InteropObject::InteropObject(QObject* parent) :
}
// NOLINTNEXTLINE(readability-identifier-naming)
bool InteropObject::PresentWindow()
bool InteropObject::PresentWindow() const
{
trApp->raise();
return true;
}
// NOLINTNEXTLINE(readability-identifier-naming)
bool InteropObject::AddMetainfo(QString const& metainfo)
bool InteropObject::AddMetainfo(QString const& metainfo) const
{
AddData addme(metainfo);

View File

@ -33,6 +33,6 @@ public:
explicit InteropObject(QObject* parent = nullptr);
public slots:
bool PresentWindow();
bool AddMetainfo(QString const& metainfo);
bool PresentWindow() const;
bool AddMetainfo(QString const& metainfo) const;
};

View File

@ -75,7 +75,7 @@ public:
}
};
QIcon MainWindow::getStockIcon(QString const& name, int fallback)
QIcon MainWindow::getStockIcon(QString const& name, int fallback) const
{
QIcon icon = QIcon::fromTheme(name);
@ -87,7 +87,7 @@ QIcon MainWindow::getStockIcon(QString const& name, int fallback)
return icon;
}
QIcon MainWindow::addEmblem(QIcon base_icon, QStringList const& emblem_names)
QIcon MainWindow::addEmblem(QIcon base_icon, QStringList const& emblem_names) const
{
if (base_icon.isNull())
{
@ -121,11 +121,7 @@ QIcon MainWindow::addEmblem(QIcon base_icon, QStringList const& emblem_names)
QPixmap pixmap = base_icon.pixmap(size);
QPixmap emblem_pixmap = emblem_icon.pixmap(emblem_size);
{
QPainter painter(&pixmap);
painter.drawPixmap(emblem_rect, emblem_pixmap, emblem_pixmap.rect());
}
QPainter(&pixmap).drawPixmap(emblem_rect, emblem_pixmap, emblem_pixmap.rect());
icon.addPixmap(pixmap);
}
@ -507,7 +503,7 @@ QMenu* MainWindow::createStatsModeMenu()
*****
****/
void MainWindow::onSortModeChanged(QAction* action)
void MainWindow::onSortModeChanged(QAction const* action)
{
prefs_.set(Prefs::SORT_MODE, SortMode(action->property(SortModeKey).toInt()));
}
@ -673,7 +669,7 @@ void MainWindow::openStats()
Utils::openDialog(stats_dialog_, session_, this);
}
void MainWindow::openDonate()
void MainWindow::openDonate() const
{
QDesktopServices::openUrl(QUrl(QStringLiteral("https://transmissionbt.com/donate/")));
}
@ -683,7 +679,7 @@ void MainWindow::openAbout()
Utils::openDialog(about_dialog_, this);
}
void MainWindow::openHelp()
void MainWindow::openHelp() const
{
QDesktopServices::openUrl(QUrl(QStringLiteral("https://transmissionbt.com/help/gtk/%1.%2x").arg(MAJOR_VERSION).
arg(MINOR_VERSION / 10)));
@ -763,7 +759,7 @@ void MainWindow::refreshTitle()
if (!url.isEmpty())
{
//: Second (optional) part of main window title "Transmission - host:port" (added when connected to remote session);
//: Second (optional) part of main window title "Transmission - host:port" (added when connected to remote session)
//: notice that leading space (before the dash) is included here
title += tr(" - %1:%2").arg(url.host()).arg(url.port());
}
@ -799,9 +795,10 @@ void MainWindow::refreshTrayIcon(TransferStats const& stats)
void MainWindow::refreshStatusBar(TransferStats const& stats)
{
ui_.uploadSpeedLabel->setText(Formatter::get().uploadSpeedToString(stats.speed_up));
auto const& fmt = Formatter::get();
ui_.uploadSpeedLabel->setText(fmt.uploadSpeedToString(stats.speed_up));
ui_.uploadSpeedLabel->setVisible(stats.peers_sending || stats.peers_receiving);
ui_.downloadSpeedLabel->setText(Formatter::get().downloadSpeedToString(stats.speed_down));
ui_.downloadSpeedLabel->setText(fmt.downloadSpeedToString(stats.speed_down));
ui_.downloadSpeedLabel->setVisible(stats.peers_sending);
ui_.networkLabel->setVisible(!session_.isServer());
@ -812,27 +809,27 @@ void MainWindow::refreshStatusBar(TransferStats const& stats)
if (mode == session_ratio_stats_mode_name_)
{
str = tr("Ratio: %1")
.arg(Formatter::get().ratioToString(session_.getStats().ratio));
.arg(fmt.ratioToString(session_.getStats().ratio));
}
else if (mode == session_transfer_stats_mode_name_)
{
auto const& st = session_.getStats();
str = tr("Down: %1, Up: %2")
.arg(Formatter::get().sizeToString(st.downloadedBytes))
.arg(Formatter::get().sizeToString(st.uploadedBytes));
.arg(fmt.sizeToString(st.downloadedBytes))
.arg(fmt.sizeToString(st.uploadedBytes));
}
else if (mode == total_transfer_stats_mode_name_)
{
auto const& st = session_.getCumulativeStats();
str = tr("Down: %1, Up: %2")
.arg(Formatter::get().sizeToString(st.downloadedBytes))
.arg(Formatter::get().sizeToString(st.uploadedBytes));
.arg(fmt.sizeToString(st.downloadedBytes))
.arg(fmt.sizeToString(st.uploadedBytes));
}
else // default is "total-ratio"
{
assert(mode == total_ratio_stats_mode_name_);
str = tr("Ratio: %1")
.arg(Formatter::get().ratioToString(session_.getCumulativeStats().ratio));
.arg(fmt.ratioToString(session_.getCumulativeStats().ratio));
}
ui_.statsLabel->setText(str);
@ -1027,7 +1024,7 @@ void MainWindow::reannounceSelected()
***
**/
void MainWindow::onStatsModeChanged(QAction* action)
void MainWindow::onStatsModeChanged(QAction const* action)
{
prefs_.set(Prefs::STATUSBAR_STATS, action->property(StatsModeKey).toString());
}
@ -1085,7 +1082,6 @@ void MainWindow::toggleWindows(bool do_show)
showNormal();
}
// activateWindow ();
raise();
QApplication::setActiveWindow(this);
}
@ -1111,7 +1107,7 @@ void MainWindow::refreshPref(int key)
bool b;
int i;
QString str;
QActionGroup* action_group;
QActionGroup const* action_group;
switch (key)
{

View File

@ -102,12 +102,12 @@ private slots:
void onSessionSourceChanged();
void onSetPrefs();
void onSetPrefs(bool);
void onSortModeChanged(QAction* action);
void onStatsModeChanged(QAction* action);
void onSortModeChanged(QAction const* action);
void onStatsModeChanged(QAction const* action);
void openAbout();
void openDonate();
void openDonate() const;
void openFolder();
void openHelp();
void openHelp() const;
void openPreferences();
void openProperties();
void openStats();
@ -123,8 +123,8 @@ private slots:
void trayActivated(QSystemTrayIcon::ActivationReason);
private:
QIcon getStockIcon(QString const&, int fallback = -1);
QIcon addEmblem(QIcon icon, QStringList const& emblem_names);
QIcon getStockIcon(QString const&, int fallback = -1) const;
QIcon addEmblem(QIcon icon, QStringList const& emblem_names) const;
torrent_ids_t getSelectedTorrents(bool withMetadataOnly = false) const;
void updateNetworkIcon();

View File

@ -221,8 +221,11 @@ void MakeDialog::onSourceChanged()
{
QString files = tr("%Ln File(s)", nullptr, builder_->fileCount);
QString pieces = tr("%Ln Piece(s)", nullptr, builder_->pieceCount);
text = tr("%1 in %2; %3 @ %4").arg(Formatter::get().sizeToString(builder_->totalSize)).arg(files).arg(pieces).
arg(Formatter::get().sizeToString(builder_->pieceSize));
text = tr("%1 in %2; %3 @ %4")
.arg(Formatter::get().sizeToString(builder_->totalSize))
.arg(files)
.arg(pieces)
.arg(Formatter::get().sizeToString(static_cast<uint64_t>(builder_->pieceSize)));
}
ui_.sourceSizeLabel->setText(text);

View File

@ -101,7 +101,7 @@ void PathButton::paintEvent(QPaintEvent* /*event*/)
painter.drawComplexControl(QStyle::CC_ToolButton, option);
}
void PathButton::onClicked()
void PathButton::onClicked() const
{
auto* dialog = new QFileDialog(window(), effectiveTitle());
dialog->setFileMode(isDirMode() ? QFileDialog::Directory : QFileDialog::ExistingFile);

View File

@ -44,7 +44,7 @@ protected:
void paintEvent(QPaintEvent* event) override;
private slots:
void onClicked();
void onClicked() const;
void onFileSelected(QString const& path);
private:

View File

@ -371,7 +371,7 @@ Prefs::~Prefs()
* This is where we initialize the preferences file with the default values.
* If you add a new preferences key, you /must/ add a default value here.
*/
void Prefs::initDefaults(tr_variant* d)
void Prefs::initDefaults(tr_variant* d) const
{
auto constexpr FilterMode = std::string_view { "all" };
auto constexpr SessionHost = std::string_view { "localhost" };

View File

@ -198,7 +198,7 @@ private:
int type;
};
void initDefaults(tr_variant*);
void initDefaults(tr_variant*) const;
void set(int key, char const* value) = delete;

View File

@ -161,7 +161,7 @@ QString qtDayName(int day)
} // namespace
bool PrefsDialog::updateWidgetValue(QWidget* widget, int pref_key)
bool PrefsDialog::updateWidgetValue(QWidget* widget, int pref_key) const
{
PreferenceWidget pref_widget(widget);

View File

@ -53,7 +53,7 @@ private slots:
private:
using key2widget_t = QMap<int, QWidget*>;
bool updateWidgetValue(QWidget* widget, int pref_key);
bool updateWidgetValue(QWidget* widget, int pref_key) const;
void linkWidgetToPref(QWidget* widget, int pref_key);
void updateBlocklistLabel();
void updateDownloadingWidgetsLocality();

View File

@ -22,7 +22,7 @@ void RelocateDialog::onSetLocation()
close();
}
void RelocateDialog::onMoveToggled(bool b)
void RelocateDialog::onMoveToggled(bool b) const
{
move_flag = b;
}

View File

@ -26,7 +26,7 @@ public:
private slots:
void onSetLocation();
void onMoveToggled(bool);
void onMoveToggled(bool) const;
private:
QString newLocation() const;

View File

@ -297,13 +297,13 @@ void RpcClient::localRequestFinished(TrVariantPtr response)
promise.reportFinished(&result);
}
int64_t RpcClient::parseResponseTag(tr_variant& json)
int64_t RpcClient::parseResponseTag(tr_variant& json) const
{
auto const tag = dictFind<int>(&json, TR_KEY_tag);
return tag ? *tag : -1;
}
RpcResponse RpcClient::parseResponseData(tr_variant& json)
RpcResponse RpcClient::parseResponseData(tr_variant& json) const
{
RpcResponse ret;

View File

@ -87,8 +87,8 @@ private:
void sendNetworkRequest(TrVariantPtr json, QFutureInterface<RpcResponse> const& promise);
void sendLocalRequest(TrVariantPtr json, QFutureInterface<RpcResponse> const& promise, int64_t tag);
int64_t parseResponseTag(tr_variant& response);
RpcResponse parseResponseData(tr_variant& response);
int64_t parseResponseTag(tr_variant& response) const;
RpcResponse parseResponseData(tr_variant& response) const;
static void localSessionCallback(tr_session* s, tr_variant* response, void* vself) noexcept;

View File

@ -69,7 +69,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, RpcResponseFuture>
>::type* = nullptr>
QueuedFunction normalizeFunc(Func const& func)
QueuedFunction normalizeFunc(Func const& func) const
{
return [func](RpcResponseFuture const& r)
{
@ -81,7 +81,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func>, RpcResponseFuture>
>::type* = nullptr>
QueuedFunction normalizeFunc(Func const& func)
QueuedFunction normalizeFunc(Func const& func) const
{
return [func](RpcResponseFuture const&)
{
@ -93,7 +93,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, void>
>::type* = nullptr>
QueuedFunction normalizeFunc(Func const& func)
QueuedFunction normalizeFunc(Func const& func) const
{
return [func](RpcResponseFuture const& r)
{
@ -106,7 +106,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func>, void>
>::type* = nullptr>
QueuedFunction normalizeFunc(Func const& func)
QueuedFunction normalizeFunc(Func const& func) const
{
return [func](RpcResponseFuture const& r)
{
@ -119,7 +119,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, void>
>::type* = nullptr>
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
ErrorHandlerFunction normalizeErrorHandler(Func const& func) const
{
return [func](RpcResponseFuture const& r)
{
@ -131,7 +131,7 @@ private:
template<typename Func, typename std::enable_if<
std::is_same_v<typename std::invoke_result_t<Func>, void>
>::type* = nullptr>
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
ErrorHandlerFunction normalizeErrorHandler(Func const& func) const
{
return [func](RpcResponseFuture const&)
{

View File

@ -394,7 +394,7 @@ bool Session::isLocal() const
****
***/
void Session::addOptionalIds(tr_variant* args, torrent_ids_t const& ids)
void Session::addOptionalIds(tr_variant* args, torrent_ids_t const& ids) const
{
auto constexpr RecentlyActiveKey = std::string_view { "recently-active" };
@ -1234,7 +1234,7 @@ void Session::reannounceTorrents(torrent_ids_t const& ids)
****
***/
void Session::launchWebInterface()
void Session::launchWebInterface() const
{
QUrl url;

View File

@ -120,7 +120,7 @@ public:
public slots:
void addTorrent(AddData const& addme);
void launchWebInterface();
void launchWebInterface() const;
void queueMoveBottom(torrent_ids_t const& torrentIds = {});
void queueMoveDown(torrent_ids_t const& torrentIds = {});
void queueMoveTop(torrent_ids_t const& torrentIds = {});
@ -162,7 +162,7 @@ private:
static void updateStats(tr_variant* d, tr_session_stats* stats);
void addOptionalIds(tr_variant* args, torrent_ids_t const& ids);
void addOptionalIds(tr_variant* args, torrent_ids_t const& ids) const;
QString const config_dir_;
Prefs& prefs_;

View File

@ -26,7 +26,7 @@ void SessionDialog::accept()
BaseDialog::accept();
}
void SessionDialog::resensitize()
void SessionDialog::resensitize() const
{
bool const is_remote = ui_.remoteSessionRadio->isChecked();
bool const use_auth = ui_.authCheck->isChecked();

View File

@ -30,7 +30,7 @@ public slots:
void accept() override;
private slots:
void resensitize();
void resensitize() const;
private:
Session& session_;

View File

@ -285,7 +285,7 @@ public:
{
auto const l = leftUntilDone();
auto const s = sizeWhenDone();
return s ? double(s - l) / s : 0.0;
return s ? static_cast<double>(s - l) / static_cast<double>(s) : 0.0;
}
double metadataPercentDone() const

View File

@ -149,14 +149,14 @@ QString TorrentDelegate::progressString(Torrent const& tor)
if (is_magnet) // magnet link with no metadata
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is the percentage of torrent metadata downloaded
str = tr("Magnetized transfer - retrieving metadata (%1%)").
arg(Formatter::get().percentToString(tor.metadataPercentDone() * 100.0));
}
else if (!is_done) // downloading
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is how much we've got,
//: %2 is how much we'll have when done,
//: %3 is a percentage of the two
@ -169,7 +169,7 @@ QString TorrentDelegate::progressString(Torrent const& tor)
{
if (has_seed_ratio)
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is how much we've got,
//: %2 is the torrent's total size,
//: %3 is a percentage of the two,
@ -184,7 +184,7 @@ QString TorrentDelegate::progressString(Torrent const& tor)
}
else
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is how much we've got,
//: %2 is the torrent's total size,
//: %3 is a percentage of the two,
@ -200,7 +200,7 @@ QString TorrentDelegate::progressString(Torrent const& tor)
{
if (has_seed_ratio)
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is the torrent's total size,
//: %2 is how much we've uploaded,
//: %3 is our upload-to-download ratio,
@ -211,7 +211,7 @@ QString TorrentDelegate::progressString(Torrent const& tor)
}
else // seeding w/o a ratio
{
//: First part of torrent progress string;
//: First part of torrent progress string,
//: %1 is the torrent's total size,
//: %2 is how much we've uploaded,
//: %3 is our upload-to-download ratio
@ -225,14 +225,14 @@ QString TorrentDelegate::progressString(Torrent const& tor)
{
if (tor.hasETA())
{
//: Second (optional) part of torrent progress string;
//: %1 is duration;
//: Second (optional) part of torrent progress string,
//: %1 is duration,
//: notice that leading space (before the dash) is included here
str += tr(" - %1 left").arg(Formatter::get().timeToString(tor.getETA()));
}
else
{
//: Second (optional) part of torrent progress string;
//: Second (optional) part of torrent progress string,
//: notice that leading space (before the dash) is included here
str += tr(" - Remaining time unknown");
}
@ -329,7 +329,7 @@ QString TorrentDelegate::statusString(Torrent const& tor)
if (tor.webseedsWeAreDownloadingFrom())
{
//: Second (optional) part of phrase "Downloading from ... of ... connected peer(s) and ... web seed(s)";
//: Second (optional) part of phrase "Downloading from ... of ... connected peer(s) and ... web seed(s)",
//: notice that leading space (before "and") is included here
str += tr(" and %Ln web seed(s)", nullptr, tor.webseedsWeAreDownloadingFrom());
}

View File

@ -268,11 +268,11 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const
}
else if (inf.st.seeder_count >= 0 && inf.st.leecher_count >= 0)
{
//: First part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago";
//: First part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago",
//: %1 and %2 are replaced with HTML markup
str += tr("Tracker had%1 %Ln seeder(s)%2", nullptr, inf.st.seeder_count).arg(success_markup_begin).
arg(success_markup_end);
//: Second part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago";
//: Second part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago",
//: %1 and %2 are replaced with HTML markup, %3 is duration;
//: notice that leading space (before "and") is included here
str += tr(" and%1 %Ln leecher(s)%2 %3 ago", nullptr, inf.st.leecher_count).arg(success_markup_begin).

View File

@ -107,9 +107,8 @@ static bool removeURL(tr_variant* metainfo, char const* url)
while ((tier = tr_variantListChild(announce_list, tierIndex)) != NULL)
{
tr_variant* node;
int nodeIndex = 0;
tr_variant const* node;
while ((node = tr_variantListChild(tier, nodeIndex)) != NULL)
{
if (tr_variantGetStr(node, &str, NULL) && strcmp(str, url) == 0)
@ -163,8 +162,8 @@ static bool removeURL(tr_variant* metainfo, char const* url)
static char* replaceSubstr(char const* str, char const* in, char const* out)
{
char* walk;
struct evbuffer* buf = evbuffer_new();
char const* walk;
struct evbuffer* const buf = evbuffer_new();
size_t const inlen = strlen(in);
size_t const outlen = strlen(out);
@ -229,17 +228,17 @@ static bool replaceURL(tr_variant* metainfo, char const* in, char const* out)
static bool announce_list_has_url(tr_variant* announce_list, char const* url)
{
tr_variant* tier;
int tierCount = 0;
tr_variant* tier;
while ((tier = tr_variantListChild(announce_list, tierCount)) != NULL)
{
tr_variant* node;
char const* str;
int nodeCount = 0;
tr_variant const* node;
while ((node = tr_variantListChild(tier, nodeCount)) != NULL)
{
char const* str = NULL;
if (tr_variantGetStr(node, &str, NULL) && strcmp(str, url) == 0)
{
return true;

View File

@ -976,7 +976,7 @@ static void printDetails(tr_variant* top)
if (tr_variantDictFindList(t, TR_KEY_labels, &l))
{
size_t child_pos = 0;
tr_variant* child;
tr_variant const* child;
while ((child = tr_variantListChild(l, child_pos++)))
{
if (tr_variantGetStr(child, &str, NULL))