From e1d53855f42a5483e6bb74482717840dafcf626d Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Mon, 1 May 2017 18:46:41 +0300 Subject: [PATCH] Avoid declaring multiple variables on the same line --- daemon/daemon.c | 4 +- daemon/remote.c | 111 ++++++++++++++++++------- gtk/actions.c | 3 +- gtk/details.c | 75 +++++++++++++---- gtk/file-list.c | 3 +- gtk/icons.c | 3 +- gtk/main.c | 15 +++- gtk/makemeta-ui.c | 14 +++- gtk/msgwin.c | 3 +- gtk/stats.c | 3 +- gtk/torrent-cell-renderer.c | 22 +++-- gtk/tr-core.c | 80 ++++++++++++------ gtk/tr-prefs.c | 4 +- gtk/tr-window.c | 38 ++++++--- gtk/util.c | 9 +- libtransmission/announcer-http.c | 6 +- libtransmission/announcer-udp.c | 6 +- libtransmission/announcer.c | 12 ++- libtransmission/bandwidth.c | 3 +- libtransmission/bandwidth.h | 3 +- libtransmission/bitfield.c | 12 ++- libtransmission/cache.c | 9 +- libtransmission/clients.c | 13 ++- libtransmission/completion.c | 23 +++-- libtransmission/crypto-test.c | 9 +- libtransmission/crypto-utils-cyassl.c | 3 +- libtransmission/crypto-utils-openssl.c | 9 +- libtransmission/file-posix.c | 3 +- libtransmission/file-test.c | 30 +++++-- libtransmission/handshake.c | 3 +- libtransmission/json-test.c | 6 +- libtransmission/magnet.c | 7 +- libtransmission/metainfo.c | 4 +- libtransmission/net.c | 3 +- libtransmission/peer-mgr.c | 30 +++++-- libtransmission/peer-msgs.c | 12 ++- libtransmission/platform.c | 3 +- libtransmission/port-forwarding.c | 3 +- libtransmission/quark-test.c | 6 +- libtransmission/rpc-server.c | 3 +- libtransmission/rpcimpl.c | 3 +- libtransmission/session.c | 3 +- libtransmission/torrent.c | 15 ++-- libtransmission/tr-dht.c | 33 ++++++-- libtransmission/tr-lpd.c | 12 ++- libtransmission/tr-udp.c | 8 +- libtransmission/utils-test.c | 7 +- libtransmission/utils.c | 9 +- libtransmission/variant-test.c | 3 +- libtransmission/watchdir-test.c | 6 +- libtransmission/web.c | 4 +- qt/DetailsDialog.cc | 3 +- qt/FileTreeItem.cc | 3 +- qt/Formatter.cc | 9 +- qt/MainWindow.cc | 15 ++-- qt/TorrentModel.cc | 6 +- 56 files changed, 533 insertions(+), 214 deletions(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index 237a56d90..b61030a55 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -802,7 +802,9 @@ int tr_main(int argc, char* argv[]) }; int ret; - bool loaded, dumpSettings, foreground; + bool loaded; + bool dumpSettings; + bool foreground; tr_error* error = NULL; struct daemon_data arg; diff --git a/daemon/remote.c b/daemon/remote.c index 1f9756190..0bec76754 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -89,8 +89,16 @@ static void etaToString(char* buf, size_t buflen, int64_t eta) static char* tr_strltime(char* buf, int seconds, size_t buflen) { - int days, hours, minutes, total_seconds; - char b[128], d[128], h[128], m[128], s[128], t[128]; + int days; + int hours; + int minutes; + int total_seconds; + char b[128]; + char d[128]; + char h[128]; + char m[128]; + char s[128]; + char t[128]; if (seconds < 0) { @@ -894,11 +902,13 @@ static char const* bandwidthPriorityNames[] = static void printDetails(tr_variant* top) { - tr_variant* args, * torrents; + tr_variant* args; + tr_variant* torrents; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents)) { - int ti, tCount; + int ti; + int tCount; for (ti = 0, tCount = tr_variantListSize(torrents); ti < tCount; ++ti) { @@ -907,7 +917,9 @@ static void printDetails(tr_variant* top) char const* str; char buf[512]; char buf2[512]; - int64_t i, j, k; + int64_t i; + int64_t j; + int64_t k; bool boolVal; double d; @@ -1200,22 +1212,27 @@ static void printDetails(tr_variant* top) static void printFileList(tr_variant* top) { - tr_variant* args, * torrents; + tr_variant* args; + tr_variant* torrents; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents)) { - int i, in; + int i; + int in; for (i = 0, in = tr_variantListSize(torrents); i < in; ++i) { tr_variant* d = tr_variantListChild(torrents, i); - tr_variant* files, * priorities, * wanteds; + tr_variant* files; + tr_variant* priorities; + tr_variant* wanteds; char const* name; if (tr_variantDictFindStr(d, TR_KEY_name, &name, NULL) && tr_variantDictFindList(d, TR_KEY_files, &files) && tr_variantDictFindList(d, TR_KEY_priorities, &priorities) && tr_variantDictFindList(d, TR_KEY_wanted, &wanteds)) { - int j = 0, jn = tr_variantListSize(files); + int j = 0; + int jn = tr_variantListSize(files); printf("%s (%d files):\n", name, jn); printf("%3s %4s %8s %3s %9s %s\n", "#", "Done", "Priority", "Get", "Size", "Name"); @@ -1263,14 +1280,18 @@ static void printFileList(tr_variant* top) static void printPeersImpl(tr_variant* peers) { - int i, n; + int i; + int n; printf("%-40s %-12s %-5s %-6s %-6s %s\n", "Address", "Flags", "Done", "Down", "Up", "Client"); for (i = 0, n = tr_variantListSize(peers); i < n; ++i) { double progress; - char const* address, * client, * flagstr; - int64_t rateToClient, rateToPeer; + char const* address; + char const* client; + char const* flagstr; + int64_t rateToClient; + int64_t rateToPeer; tr_variant* d = tr_variantListChild(peers, i); if (tr_variantDictFindStr(d, TR_KEY_address, &address, NULL) && tr_variantDictFindStr(d, TR_KEY_clientName, &client, NULL) && @@ -1285,11 +1306,13 @@ static void printPeersImpl(tr_variant* peers) static void printPeers(tr_variant* top) { - tr_variant* args, * torrents; + tr_variant* args; + tr_variant* torrents; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents)) { - int i, n; + int i; + int n; for (i = 0, n = tr_variantListSize(torrents); i < n; ++i) { @@ -1311,7 +1334,9 @@ static void printPeers(tr_variant* top) static void printPiecesImpl(uint8_t const* raw, size_t rawlen, size_t j) { - size_t i, k, len; + size_t i; + size_t k; + size_t len; char* str = tr_base64_decode(raw, rawlen, &len); printf(" "); @@ -1338,11 +1363,13 @@ static void printPiecesImpl(uint8_t const* raw, size_t rawlen, size_t j) static void printPieces(tr_variant* top) { - tr_variant* args, * torrents; + tr_variant* args; + tr_variant* torrents; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents)) { - int i, n; + int i; + int n; for (i = 0, n = tr_variantListSize(torrents); i < n; ++i) { @@ -1382,13 +1409,16 @@ static void printPortTest(tr_variant* top) static void printTorrentList(tr_variant* top) { - tr_variant* args, * list; + tr_variant* args; + tr_variant* list; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &list)) { - int i, n; + int i; + int n; int64_t total_size = 0; - double total_up = 0, total_down = 0; + double total_up = 0; + double total_down = 0; char haveStr[32]; printf("%-4s %-4s %9s %-8s %6s %6s %-5s %-11s %s\n", "ID", "Done", "Have", "ETA", "Up", "Down", "Ratio", "Status", @@ -1396,8 +1426,13 @@ static void printTorrentList(tr_variant* top) for (i = 0, n = tr_variantListSize(list); i < n; ++i) { - int64_t id, eta, status, up, down; - int64_t sizeWhenDone, leftUntilDone; + int64_t id; + int64_t eta; + int64_t status; + int64_t up; + int64_t down; + int64_t sizeWhenDone; + int64_t leftUntilDone; double ratio; char const* name; tr_variant* d = tr_variantListChild(list, i); @@ -1616,11 +1651,13 @@ static void printTrackersImpl(tr_variant* trackerStats) static void printTrackers(tr_variant* top) { - tr_variant* args, * torrents; + tr_variant* args; + tr_variant* torrents; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args) && tr_variantDictFindList(args, TR_KEY_torrents, &torrents)) { - int i, n; + int i; + int n; for (i = 0, n = tr_variantListSize(torrents); i < n; ++i) { @@ -1725,8 +1762,19 @@ static void printSession(tr_variant* top) printf("\n"); { - bool altEnabled, altTimeEnabled, upEnabled, downEnabled, seedRatioLimited; - int64_t altDown, altUp, altBegin, altEnd, altDay, upLimit, downLimit, peerLimit; + bool altEnabled; + bool altTimeEnabled; + bool upEnabled; + bool downEnabled; + bool seedRatioLimited; + int64_t altDown; + int64_t altUp; + int64_t altBegin; + int64_t altEnd; + int64_t altDay; + int64_t upLimit; + int64_t downLimit; + int64_t peerLimit; double seedRatioLimit; if (tr_variantDictFindInt(args, TR_KEY_alt_speed_down, &altDown) && @@ -1859,12 +1907,16 @@ static void printSession(tr_variant* top) static void printSessionStats(tr_variant* top) { - tr_variant* args, * d; + tr_variant* args; + tr_variant* d; if (tr_variantDictFindDict(top, TR_KEY_arguments, &args)) { char buf[512]; - int64_t up, down, secs, sessions; + int64_t up; + int64_t down; + int64_t secs; + int64_t sessions; if (tr_variantDictFindDict(args, TR_KEY_current_stats, &d) && tr_variantDictFindInt(d, TR_KEY_uploadedBytes, &up) && tr_variantDictFindInt(d, TR_KEY_downloadedBytes, &down) && tr_variantDictFindInt(d, TR_KEY_secondsActive, &secs)) @@ -2276,7 +2328,8 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv) } else if (stepMode == MODE_TORRENT_GET) { - size_t i, n; + size_t i; + size_t n; tr_variant* top = tr_new0(tr_variant, 1); tr_variant* args; tr_variant* fields; diff --git a/gtk/actions.c b/gtk/actions.c index a7a96ffe1..58477cb05 100644 --- a/gtk/actions.c +++ b/gtk/actions.c @@ -185,7 +185,8 @@ void gtr_actions_set_core(TrCore* core) void gtr_actions_init(GtkUIManager* ui_manager, gpointer callback_user_data) { - int i, n; + int i; + int n; int active; char const* match; int const n_entries = G_N_ELEMENTS(entries); diff --git a/gtk/details.c b/gtk/details.c index 30b1c7a50..00889e071 100644 --- a/gtk/details.c +++ b/gtk/details.c @@ -383,7 +383,9 @@ static void refreshOptions(struct DetailsImpl* di, tr_torrent** torrents, int n) static void torrent_set_bool(struct DetailsImpl* di, tr_quark const key, gboolean value) { GSList* l; - tr_variant top, * args, * ids; + tr_variant top; + tr_variant* args; + tr_variant* ids; tr_variantInitDict(&top, 2); tr_variantDictAddStr(&top, TR_KEY_method, "torrent-set"); @@ -403,7 +405,9 @@ static void torrent_set_bool(struct DetailsImpl* di, tr_quark const key, gboolea static void torrent_set_int(struct DetailsImpl* di, tr_quark const key, int value) { GSList* l; - tr_variant top, * args, * ids; + tr_variant top; + tr_variant* args; + tr_variant* ids; tr_variantInitDict(&top, 2); tr_variantDictAddStr(&top, TR_KEY_method, "torrent-set"); @@ -423,7 +427,9 @@ static void torrent_set_int(struct DetailsImpl* di, tr_quark const key, int valu static void torrent_set_real(struct DetailsImpl* di, tr_quark const key, double value) { GSList* l; - tr_variant top, * args, * ids; + tr_variant top; + tr_variant* args; + tr_variant* ids; tr_variantInitDict(&top, 2); tr_variantDictAddStr(&top, TR_KEY_method, "torrent-set"); @@ -529,7 +535,10 @@ static GtkWidget* options_page_new(struct DetailsImpl* d) guint row; gulong tag; char buf[128]; - GtkWidget* t, * w, * tb, * h; + GtkWidget* t; + GtkWidget* w; + GtkWidget* tb; + GtkWidget* h; row = 0; t = hig_workarea_create(); @@ -643,7 +652,8 @@ static char const* activityString(int activity, bool finished) static void gtr_text_buffer_set_text(GtkTextBuffer* b, char const* str) { char* old_str; - GtkTextIter start, end; + GtkTextIter start; + GtkTextIter end; if (str == NULL) { @@ -1001,7 +1011,10 @@ static void refreshInfo(struct DetailsImpl* di, tr_torrent** torrents, int n) } { - char buf2[32], unver[64], total[64], avail[32]; + char buf2[32]; + char unver[64]; + char total[64]; + char avail[32]; double const d = sizeWhenDone ? (100.0 * available) / sizeWhenDone : 0; double const ratio = 100.0 * (sizeWhenDone ? (haveValid + haveUnchecked) / (double)sizeWhenDone : 1); @@ -1037,8 +1050,10 @@ static void refreshInfo(struct DetailsImpl* di, tr_torrent** torrents, int n) } else { - char dbuf[64], fbuf[64]; - uint64_t d = 0, f = 0; + char dbuf[64]; + char fbuf[64]; + uint64_t d = 0; + uint64_t f = 0; for (i = 0; i < n; ++i) { @@ -1189,7 +1204,10 @@ static GtkWidget* info_page_new(struct DetailsImpl* di) { guint row = 0; GtkTextBuffer* b; - GtkWidget* l, * w, * fr, * sw; + GtkWidget* l; + GtkWidget* w; + GtkWidget* fr; + GtkWidget* sw; GtkWidget* t = hig_workarea_create(); hig_workarea_add_section_title(t, &row, _("Activity")); @@ -2071,7 +2089,11 @@ static GtkWidget* peer_page_new(struct DetailsImpl* di) gboolean b; char const* str; GtkListStore* store; - GtkWidget* v, * w, * ret, * sw, * vbox; + GtkWidget* v; + GtkWidget* w; + GtkWidget* ret; + GtkWidget* sw; + GtkWidget* vbox; GtkWidget* webtree = NULL; GtkTreeModel* m; GtkTreeViewColumn* c; @@ -2545,9 +2567,11 @@ static void on_edit_trackers_response(GtkDialog* dialog, int response, gpointer if (response == GTK_RESPONSE_ACCEPT) { - int i, n; + int i; + int n; int tier; - GtkTextIter start, end; + GtkTextIter start; + GtkTextIter end; int const torrent_id = GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(dialog), TORRENT_ID_KEY)); GtkTextBuffer* text_buffer = g_object_get_qdata(G_OBJECT(dialog), TEXT_BUFFER_KEY); tr_torrent* tor = gtr_core_find_torrent(di->core, torrent_id); @@ -2650,7 +2674,12 @@ static void on_edit_trackers(GtkButton* button, gpointer data) if (tor != NULL) { guint row; - GtkWidget* w, * d, * fr, * t, * l, * sw; + GtkWidget* w; + GtkWidget* d; + GtkWidget* fr; + GtkWidget* t; + GtkWidget* l; + GtkWidget* sw; GtkWindow* win = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))); GString* gstr = di->gstr; /* buffer for temporary strings */ int const torrent_id = tr_torrentId(tor); @@ -2720,7 +2749,9 @@ static void on_add_tracker_response(GtkDialog* dialog, int response, gpointer gd { if (tr_urlIsValidTracker(url)) { - tr_variant top, * args, * trackers; + tr_variant top; + tr_variant* args; + tr_variant* trackers; tr_variantInitDict(&top, 2); tr_variantDictAddStr(&top, TR_KEY_method, "torrent-set"); @@ -2796,7 +2827,9 @@ static void on_tracker_list_remove_button_clicked(GtkButton* button UNUSED, gpoi { int torrent_id; int tracker_id; - tr_variant top, * args, * trackers; + tr_variant top; + tr_variant* args; + tr_variant* trackers; gtk_tree_model_get(model, &iter, TRACKER_COL_TRACKER_ID, &tracker_id, @@ -2823,7 +2856,11 @@ static GtkWidget* tracker_page_new(struct DetailsImpl* di) GtkCellRenderer* r; GtkTreeViewColumn* c; GtkTreeSelection* sel; - GtkWidget* vbox, * sw, * w, * v, * hbox; + GtkWidget* vbox; + GtkWidget* sw; + GtkWidget* w; + GtkWidget* v; + GtkWidget* hbox; int const pad = (GUI_PAD + GUI_PAD_BIG) / 2; vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, GUI_PAD); @@ -2961,7 +2998,11 @@ static void details_free(gpointer gdata) GtkWidget* gtr_torrent_details_dialog_new(GtkWindow* parent, TrCore* core) { - GtkWidget* d, * n, * v, * w, * l; + GtkWidget* d; + GtkWidget* n; + GtkWidget* v; + GtkWidget* w; + GtkWidget* l; struct DetailsImpl* di = g_new0(struct DetailsImpl, 1); /* one-time setup */ diff --git a/gtk/file-list.c b/gtk/file-list.c index a16243ef4..f4d8f742d 100644 --- a/gtk/file-list.c +++ b/gtk/file-list.c @@ -166,7 +166,8 @@ static gboolean refreshFilesForeach(GtkTreeModel* model, GtkTreePath* path UNUSE { int child_enabled; int child_priority; - int64_t child_have, child_size; + int64_t child_have; + int64_t child_size; gtk_tree_model_get(model, &child, FC_SIZE, &child_size, diff --git a/gtk/icons.c b/gtk/icons.c index df76479e0..7f6756b7f 100644 --- a/gtk/icons.c +++ b/gtk/icons.c @@ -50,7 +50,8 @@ static GdkPixbuf* create_void_pixbuf(int width, int height) static int get_size_in_pixels(GtkWidget* widget, GtkIconSize icon_size) { - int width, height; + int width; + int height; gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(widget), icon_size, &width, &height); return MAX(width, height); diff --git a/gtk/main.c b/gtk/main.c index 4e51ab3de..2f2c994fa 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -336,7 +336,10 @@ static void on_main_window_size_allocated(GtkWidget* gtk_window, GtkAllocation* if (!isMaximized) { - int x, y, w, h; + int x; + int y; + int w; + int h; gtk_window_get_position(GTK_WINDOW(gtk_window), &x, &y); gtk_window_get_size(GTK_WINDOW(gtk_window), &w, &h); gtr_pref_int_set(TR_KEY_main_window_x, x); @@ -940,7 +943,11 @@ static void exit_now_cb(GtkWidget* w UNUSED, gpointer data UNUSED) static void on_app_exit(gpointer vdata) { - GtkWidget* r, * p, * b, * w, * c; + GtkWidget* r; + GtkWidget* p; + GtkWidget* b; + GtkWidget* w; + GtkWidget* c; struct cbdata* cbdata = vdata; struct session_close_struct* session_close_data; @@ -1391,7 +1398,9 @@ static void append_id_to_benc_list(GtkTreeModel* m, GtkTreePath* path UNUSED, Gt static gboolean call_rpc_for_selected_torrents(struct cbdata* data, char const* method) { - tr_variant top, * args, * ids; + tr_variant top; + tr_variant* args; + tr_variant* ids; gboolean invoked = FALSE; GtkTreeSelection* s = data->sel; tr_session* session = gtr_core_session(data->core); diff --git a/gtk/makemeta-ui.c b/gtk/makemeta-ui.c index 597f31132..a48269667 100644 --- a/gtk/makemeta-ui.c +++ b/gtk/makemeta-ui.c @@ -174,7 +174,11 @@ static void onProgressDialogResponse(GtkDialog* d, int response, gpointer data) static void makeProgressDialog(GtkWidget* parent, MakeMetaUI* ui) { - GtkWidget* d, * l, * w, * v, * fr; + GtkWidget* d; + GtkWidget* l; + GtkWidget* w; + GtkWidget* v; + GtkWidget* fr; d = gtk_dialog_new_with_buttons(_("New Torrent"), GTK_WINDOW(parent), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL); @@ -417,7 +421,13 @@ static void on_drag_data_received(GtkWidget* widget UNUSED, GdkDragContext* drag GtkWidget* gtr_torrent_creation_dialog_new(GtkWindow* parent, TrCore* core) { char const* str; - GtkWidget* d, * t, * w, * l, * fr, * sw, * v; + GtkWidget* d; + GtkWidget* t; + GtkWidget* w; + GtkWidget* l; + GtkWidget* fr; + GtkWidget* sw; + GtkWidget* v; GSList* slist; guint row = 0; MakeMetaUI* ui = g_new0(MakeMetaUI, 1); diff --git a/gtk/msgwin.c b/gtk/msgwin.c index 42897a81b..8dbbc975b 100644 --- a/gtk/msgwin.c +++ b/gtk/msgwin.c @@ -123,7 +123,8 @@ static void level_combo_changed_cb(GtkComboBox* combo_box, gpointer gdata) /* similar to asctime, but is utf8-clean */ static char* gtr_localtime(time_t time) { - char buf[256], * eoln; + char buf[256]; + char* eoln; struct tm const tm = *localtime(&time); g_strlcpy(buf, asctime(&tm), sizeof(buf)); diff --git a/gtk/stats.c b/gtk/stats.c index fcca5ef31..c2f74168a 100644 --- a/gtk/stats.c +++ b/gtk/stats.c @@ -53,7 +53,8 @@ static gboolean updateStats(gpointer gdata) { char buf[128]; char const* fmt; - tr_session_stats one, all; + tr_session_stats one; + tr_session_stats all; size_t const buflen = sizeof(buf); struct stat_ui* ui = gdata; diff --git a/gtk/torrent-cell-renderer.c b/gtk/torrent-cell-renderer.c index 7bf027043..959efa893 100644 --- a/gtk/torrent-cell-renderer.c +++ b/gtk/torrent-cell-renderer.c @@ -41,7 +41,12 @@ static void getProgressString(GString* gstr, tr_torrent const* tor, tr_info cons bool const isDone = st->leftUntilDone == 0; uint64_t const haveTotal = st->haveUnchecked + st->haveValid; bool const isSeed = st->haveValid >= info->totalSize; - char buf1[32], buf2[32], buf3[32], buf4[32], buf5[32], buf6[32]; + char buf1[32]; + char buf2[32]; + char buf3[32]; + char buf4[32]; + char buf5[32]; + char buf6[32]; double seedRatio; bool const hasSeedRatio = tr_torrentGetSeedRatio(tor, &seedRatio); @@ -366,7 +371,8 @@ static void gtr_cell_renderer_get_preferred_size(GtkCellRenderer* renderer, GtkW static void get_size_compact(TorrentCellRenderer* cell, GtkWidget* widget, gint* width, gint* height) { - int xpad, ypad; + int xpad; + int ypad; GtkRequisition icon_size; GtkRequisition name_size; GtkRequisition stat_size; @@ -416,7 +422,8 @@ static void get_size_compact(TorrentCellRenderer* cell, GtkWidget* widget, gint* static void get_size_full(TorrentCellRenderer* cell, GtkWidget* widget, gint* width, gint* height) { - int xpad, ypad; + int xpad; + int ypad; GtkRequisition icon_size; GtkRequisition name_size; GtkRequisition stat_size; @@ -476,7 +483,8 @@ static void torrent_cell_renderer_get_size(GtkCellRenderer* cell, GtkWidget* wid if (self != NULL && self->priv->tor != NULL) { - int w, h; + int w; + int h; struct TorrentCellRendererPrivate* p = self->priv; if (p->compact) @@ -562,7 +570,8 @@ static void gtr_cell_renderer_render(GtkCellRenderer* renderer, GtrDrawable* dra static void render_compact(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidget* widget, GdkRectangle const* background_area, GdkRectangle const* cell_area UNUSED, GtkCellRendererState flags) { - int xpad, ypad; + int xpad; + int ypad; GtkRequisition size; GdkRectangle icon_area; GdkRectangle name_area; @@ -636,7 +645,8 @@ static void render_compact(TorrentCellRenderer* cell, GtrDrawable* window, GtkWi static void render_full(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidget* widget, GdkRectangle const* background_area, GdkRectangle const* cell_area UNUSED, GtkCellRendererState flags) { - int xpad, ypad; + int xpad; + int ypad; GtkRequisition size; GdkRectangle fill_area; GdkRectangle icon_area; diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 4b30a01f5..00669c977 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -403,7 +403,8 @@ static int compare_time(time_t a, time_t b) static int compare_by_name(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data UNUSED) { - char const* ca, * cb; + char const* ca; + char const* cb; gtk_tree_model_get(m, a, MC_NAME_COLLATED, &ca, -1); gtk_tree_model_get(m, b, MC_NAME_COLLATED, &cb, -1); return g_strcmp0(ca, cb); @@ -411,8 +412,10 @@ static int compare_by_name(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpoi static int compare_by_queue(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data UNUSED) { - tr_torrent* ta, * tb; - tr_stat const* sa, * sb; + tr_torrent* ta; + tr_torrent* tb; + tr_stat const* sa; + tr_stat const* sb; gtk_tree_model_get(m, a, MC_TORRENT, &ta, -1); sa = tr_torrentStatCached(ta); @@ -425,8 +428,10 @@ static int compare_by_queue(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpo static int compare_by_ratio(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { int ret = 0; - tr_torrent* ta, * tb; - tr_stat const* sa, * sb; + tr_torrent* ta; + tr_torrent* tb; + tr_stat const* sa; + tr_stat const* sb; gtk_tree_model_get(m, a, MC_TORRENT, &ta, -1); sa = tr_torrentStatCached(ta); @@ -449,8 +454,12 @@ static int compare_by_ratio(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpo static int compare_by_activity(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { int ret = 0; - tr_torrent* ta, * tb; - double aUp, aDown, bUp, bDown; + tr_torrent* ta; + tr_torrent* tb; + double aUp; + double aDown; + double bUp; + double bDown; gtk_tree_model_get(m, a, MC_SPEED_UP, &aUp, MC_SPEED_DOWN, &aDown, MC_TORRENT, &ta, -1); gtk_tree_model_get(m, b, MC_SPEED_UP, &bUp, MC_SPEED_DOWN, &bDown, MC_TORRENT, &tb, -1); @@ -475,7 +484,8 @@ static int compare_by_activity(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, static int compare_by_age(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer u) { int ret = 0; - tr_torrent* ta, * tb; + tr_torrent* ta; + tr_torrent* tb; gtk_tree_model_get(m, a, MC_TORRENT, &ta, -1); gtk_tree_model_get(m, b, MC_TORRENT, &tb, -1); @@ -497,7 +507,8 @@ static int compare_by_size(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpoi { int ret = 0; tr_torrent* t; - tr_info const* ia, * ib; + tr_info const* ia; + tr_info const* ib; gtk_tree_model_get(m, a, MC_TORRENT, &t, -1); ia = tr_torrentInfo(t); @@ -521,7 +532,8 @@ static int compare_by_progress(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, { int ret = 0; tr_torrent* t; - tr_stat const* sa, * sb; + tr_stat const* sa; + tr_stat const* sb; gtk_tree_model_get(m, a, MC_TORRENT, &t, -1); sa = tr_torrentStatCached(t); @@ -549,7 +561,8 @@ static int compare_by_progress(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, static int compare_by_eta(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer u) { int ret = 0; - tr_torrent* ta, * tb; + tr_torrent* ta; + tr_torrent* tb; gtk_tree_model_get(m, a, MC_TORRENT, &ta, -1); gtk_tree_model_get(m, b, MC_TORRENT, &tb, -1); @@ -570,8 +583,10 @@ static int compare_by_eta(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpoin static int compare_by_state(GtkTreeModel* m, GtkTreeIter* a, GtkTreeIter* b, gpointer u) { int ret = 0; - int sa, sb; - tr_torrent* ta, * tb; + int sa; + int sb; + tr_torrent* ta; + tr_torrent* tb; gtk_tree_model_get(m, a, MC_ACTIVITY, &sa, MC_TORRENT, &ta, -1); gtk_tree_model_get(m, b, MC_ACTIVITY, &sb, MC_TORRENT, &tb, -1); @@ -1456,19 +1471,32 @@ static int gtr_compare_double(double const a, double const b, int decimal_places static void update_foreach(GtkTreeModel* model, GtkTreeIter* iter) { - int oldActivity, newActivity; - int oldActivePeerCount, newActivePeerCount; - int oldError, newError; - bool oldFinished, newFinished; - int oldQueuePosition, newQueuePosition; - int oldDownloadPeerCount, newDownloadPeerCount; - int oldUploadPeerCount, newUploadPeerCount; - tr_priority_t oldPriority, newPriority; - unsigned int oldTrackers, newTrackers; - double oldUpSpeed, newUpSpeed; - double oldDownSpeed, newDownSpeed; - double oldRecheckProgress, newRecheckProgress; - gboolean oldActive, newActive; + int oldActivity; + int newActivity; + int oldActivePeerCount; + int newActivePeerCount; + int oldError; + int newError; + bool oldFinished; + bool newFinished; + int oldQueuePosition; + int newQueuePosition; + int oldDownloadPeerCount; + int newDownloadPeerCount; + int oldUploadPeerCount; + int newUploadPeerCount; + tr_priority_t oldPriority; + tr_priority_t newPriority; + unsigned int oldTrackers; + unsigned int newTrackers; + double oldUpSpeed; + double newUpSpeed; + double oldDownSpeed; + double newDownSpeed; + double oldRecheckProgress; + double newRecheckProgress; + gboolean oldActive; + gboolean newActive; tr_stat const* st; tr_torrent* tor; diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index 810e183c9..ef5f50992 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -968,7 +968,9 @@ static GtkWidget* speedPage(GObject* core) char const* s; GtkWidget* t; GtkWidget* l; - GtkWidget* w, * w2, * h; + GtkWidget* w; + GtkWidget* w2; + GtkWidget* h; char buf[512]; guint row = 0; struct BandwidthPage* page = tr_new0(struct BandwidthPage, 1); diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 9fb797c50..e1440a8c8 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -212,7 +212,8 @@ static void onYinYangReleased(GtkWidget* w UNUSED, gpointer vprivate) static struct { - char const* val, * i18n; + char const* val; + char const* i18n; } stats_modes[] = { @@ -360,7 +361,8 @@ static void onSpeedSet(GtkCheckMenuItem* check, gpointer vp) static GtkWidget* createSpeedMenu(PrivateData* p, tr_direction dir) { - int i, n; + int i; + int n; GObject* o; GtkWidget* w; GtkWidget* m; @@ -433,8 +435,10 @@ static void onRatioSet(GtkCheckMenuItem* check, gpointer vp) static GtkWidget* createRatioMenu(PrivateData* p) { - int i, n; - GtkWidget* m, * w; + int i; + int n; + GtkWidget* m; + GtkWidget* w; GtkMenuShell* menu_shell; m = gtk_menu_new(); @@ -538,12 +542,21 @@ static void onOptionsClicked(GtkButton* button UNUSED, gpointer vp) GtkWidget* gtr_window_new(GtkApplication* app, GtkUIManager* ui_mgr, TrCore* core) { int i, n; - char const* pch, * style; + char const* pch; + char const* style; PrivateData* p; GtkWidget* sibling = NULL; - GtkWidget* ul_lb, * dl_lb; - GtkWidget* mainmenu, * toolbar, * filter, * list, * status; - GtkWidget* vbox, * w, * self, * menu; + GtkWidget* ul_lb; + GtkWidget* dl_lb; + GtkWidget* mainmenu; + GtkWidget* toolbar; + GtkWidget* filter; + GtkWidget* list; + GtkWidget* status; + GtkWidget* vbox; + GtkWidget* w; + GtkWidget* self; + GtkWidget* menu; GtkWidget* grid_w; GtkWindow* win; GtkCssProvider* css_provider; @@ -691,7 +704,8 @@ GtkWidget* gtr_window_new(GtkApplication* app, GtkUIManager* ui_mgr, TrCore* cor { /* this is to determine the maximum width/height for the label */ - int w = 0, h = 0; + int w = 0; + int h = 0; PangoLayout* pango_layout; pango_layout = gtk_widget_create_pango_layout(ul_lb, "999.99 kB/s"); pango_layout_get_pixel_size(pango_layout, &w, &h); @@ -789,8 +803,10 @@ static void updateSpeeds(PrivateData* p) { do { - int uc, dc; - double us, ds; + int uc; + int dc; + double us; + double ds; gtk_tree_model_get(model, &iter, MC_SPEED_UP, &us, MC_SPEED_DOWN, &ds, diff --git a/gtk/util.c b/gtk/util.c index fb9b70bba..2df667c25 100644 --- a/gtk/util.c +++ b/gtk/util.c @@ -101,8 +101,13 @@ char* tr_strlsize(char* buf, guint64 bytes, size_t buflen) char* tr_strltime(char* buf, int seconds, size_t buflen) { - int days, hours, minutes; - char d[128], h[128], m[128], s[128]; + int days; + int hours; + int minutes; + char d[128]; + char h[128]; + char m[128]; + char s[128]; if (seconds < 0) { diff --git a/libtransmission/announcer-http.c b/libtransmission/announcer-http.c index 97f12e554..a73d67c3f 100644 --- a/libtransmission/announcer-http.c +++ b/libtransmission/announcer-http.c @@ -244,7 +244,8 @@ static void on_announce_done(tr_session* session, bool did_connect, bool did_tim } else { - size_t i, len; + size_t i; + size_t len; char* str = tr_variantToStr(&benc, TR_VARIANT_FMT_JSON, &len); fprintf(stderr, "%s", "Announce response:\n< "); @@ -417,7 +418,8 @@ static void on_scrape_done(tr_session* session, bool did_connect, bool did_timeo } else { - size_t i, len; + size_t i; + size_t len; char* str = tr_variantToStr(&top, TR_VARIANT_FMT_JSON, &len); fprintf(stderr, "%s", "Scrape response:\n< "); diff --git a/libtransmission/announcer-udp.c b/libtransmission/announcer-udp.c index 026733fce..60cb5cb5c 100644 --- a/libtransmission/announcer-udp.c +++ b/libtransmission/announcer-udp.c @@ -548,7 +548,8 @@ static void tau_tracker_send_request(struct tau_tracker* tracker, void const* pa static void tau_tracker_send_reqs(struct tau_tracker* tracker) { - int i, n; + int i; + int n; tr_ptrArray* reqs; time_t const now = tr_time(); @@ -639,7 +640,8 @@ static void on_tracker_connection_response(struct tau_tracker* tracker, tau_acti static void tau_tracker_timeout_reqs(struct tau_tracker* tracker) { - int i, n; + int i; + int n; tr_ptrArray* reqs; time_t const now = time(NULL); bool const cancel_all = tracker->close_at && (tracker->close_at <= now); diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index 5444e125f..a03c92d41 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -566,8 +566,10 @@ static int filter_trackers_compare_func(void const* va, void const* vb) */ static tr_tracker_info* filter_trackers(tr_tracker_info* input, int input_count, int* setme_count) { - int i, in; - int j, jn; + int i; + int in; + int j; + int jn; int n = 0; struct tr_tracker_info* ret; struct ann_tracker_info* tmp = tr_new0(struct ann_tracker_info, input_count); @@ -663,7 +665,8 @@ static tr_tracker_info* filter_trackers(tr_tracker_info* input, int input_count, static void addTorrentToTier(tr_torrent_tiers* tt, tr_torrent* tor) { - int i, n; + int i; + int n; int tier_count; tr_tier* tier; tr_tracker_info* infos = filter_trackers(tor->info.trackers, tor->info.trackerCount, &n); @@ -1827,7 +1830,8 @@ static void copy_tier_attributes_impl(struct tr_tier* tgt, int trackerIndex, tr_ static void copy_tier_attributes(struct tr_torrent_tiers* tt, tr_tier const* src) { - int i, j; + int i; + int j; bool found = false; /* find a tier (if any) which has a match for src->currentTracker */ diff --git a/libtransmission/bandwidth.c b/libtransmission/bandwidth.c index 4ac089019..b0a4a328e 100644 --- a/libtransmission/bandwidth.c +++ b/libtransmission/bandwidth.c @@ -238,7 +238,8 @@ static void phaseOne(tr_ptrArray* peerArray, tr_direction dir) void tr_bandwidthAllocate(tr_bandwidth* b, tr_direction dir, unsigned int period_msec) { - int i, peerCount; + int i; + int peerCount; tr_ptrArray tmp = TR_PTR_ARRAY_INIT; tr_ptrArray low = TR_PTR_ARRAY_INIT; tr_ptrArray high = TR_PTR_ARRAY_INIT; diff --git a/libtransmission/bandwidth.h b/libtransmission/bandwidth.h index d3a3ee3f6..1df9db65d 100644 --- a/libtransmission/bandwidth.h +++ b/libtransmission/bandwidth.h @@ -43,7 +43,8 @@ struct bratecontrol int newest; struct { - uint64_t date, size; + uint64_t date; + uint64_t size; } transfers[HISTORY_SIZE]; uint64_t cache_time; diff --git a/libtransmission/bitfield.c b/libtransmission/bitfield.c index e480e8b1d..5e0212711 100644 --- a/libtransmission/bitfield.c +++ b/libtransmission/bitfield.c @@ -412,8 +412,10 @@ void tr_bitfieldAdd(tr_bitfield* b, size_t nth) /* Sets bit range [begin, end) to 1 */ void tr_bitfieldAddRange(tr_bitfield* b, size_t begin, size_t end) { - size_t sb, eb; - unsigned char sm, em; + size_t sb; + size_t eb; + unsigned char sm; + unsigned char em; size_t const diff = (end - begin) - tr_bitfieldCountRange(b, begin, end); if (diff == 0) @@ -470,8 +472,10 @@ void tr_bitfieldRem(tr_bitfield* b, size_t nth) /* Clears bit range [begin, end) to 0 */ void tr_bitfieldRemRange(tr_bitfield* b, size_t begin, size_t end) { - size_t sb, eb; - unsigned char sm, em; + size_t sb; + size_t eb; + unsigned char sm; + unsigned char em; size_t const diff = tr_bitfieldCountRange(b, begin, end); if (diff == 0) diff --git a/libtransmission/cache.c b/libtransmission/cache.c index a43c92f09..3393eae63 100644 --- a/libtransmission/cache.c +++ b/libtransmission/cache.c @@ -139,7 +139,8 @@ enum static int calcRuns(tr_cache* cache, struct run_info* runs) { int const n = tr_ptrArraySize(&cache->blocks); - int i = 0, pos; + int i = 0; + int pos; time_t const now = tr_time(); for (pos = 0; pos < n; pos += runs[i++].len) @@ -234,7 +235,8 @@ static int cacheTrim(tr_cache* cache) * runs can grow as well as how often flushes will happen. */ int const cacheCutoff = 1 + cache->max_blocks / 4; struct run_info* runs = tr_new(struct run_info, tr_ptrArraySize(&cache->blocks)); - int i = 0, j = 0; + int i = 0; + int j = 0; calcRuns(cache, runs); @@ -406,7 +408,8 @@ int tr_cacheFlushDone(tr_cache* cache) if (tr_ptrArraySize(&cache->blocks) > 0) { - int i, n; + int i; + int n; struct run_info* runs; runs = tr_new(struct run_info, tr_ptrArraySize(&cache->blocks)); diff --git a/libtransmission/clients.c b/libtransmission/clients.c index 88d4ccac2..ccde2e2b3 100644 --- a/libtransmission/clients.c +++ b/libtransmission/clients.c @@ -126,7 +126,8 @@ static bool decodeBitCometClient(char* buf, size_t buflen, uint8_t const* id) { char const* chid = (char*)id; bool is_bitlord; - int major, minor; + int major; + int minor; char const* name; char const* mod = NULL; @@ -768,7 +769,9 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in) /* Shad0w-style */ if (*buf == '\0') { - int a, b, c; + int a; + int b; + int c; if (strchr("AOQRSTU", id[0]) != NULL && getShadowInt(id[1], &a) && getShadowInt(id[2], &b) && getShadowInt(id[3], &c)) { @@ -816,8 +819,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in) /* No match */ if (*buf == '\0') { - char out[32], * walk = out; - char const* in, * in_end; + char out[32]; + char* walk = out; + char const* in; + char const* in_end; for (in = (char const*)id, in_end = in + 8; in != in_end; ++in) { diff --git a/libtransmission/completion.c b/libtransmission/completion.c index a1a55dbd6..932bf309a 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -78,7 +78,9 @@ tr_completeness tr_cpGetStatus(tr_completion const* cp) void tr_cpPieceRem(tr_completion* cp, tr_piece_index_t piece) { - tr_block_index_t i, f, l; + tr_block_index_t i; + tr_block_index_t f; + tr_block_index_t l; tr_torrent const* tor = cp->tor; tr_torGetPieceBlockRange(cp->tor, piece, &f, &l); @@ -98,7 +100,9 @@ void tr_cpPieceRem(tr_completion* cp, tr_piece_index_t piece) void tr_cpPieceAdd(tr_completion* cp, tr_piece_index_t piece) { - tr_block_index_t i, f, l; + tr_block_index_t i; + tr_block_index_t f; + tr_block_index_t l; tr_torGetPieceBlockRange(cp->tor, piece, &f, &l); for (i = f; i <= l; ++i) @@ -180,7 +184,8 @@ uint64_t tr_cpSizeWhenDone(tr_completion const* ccp) } else { - tr_block_index_t f, l; + tr_block_index_t f; + tr_block_index_t l; tr_torGetPieceBlockRange(cp->tor, p, &f, &l); n = tr_bitfieldCountRange(&cp->blockBitfield, f, l + 1); @@ -230,7 +235,8 @@ void tr_cpGetAmountDone(tr_completion const* cp, float* tab, int tabCount) } else { - tr_block_index_t f, l; + tr_block_index_t f; + tr_block_index_t l; tr_piece_index_t const piece = (tr_piece_index_t)i * interval; tr_torGetPieceBlockRange(cp->tor, piece, &f, &l); tab[i] = tr_bitfieldCountRange(&cp->blockBitfield, f, l + 1) / (float)(l + 1 - f); @@ -246,7 +252,8 @@ size_t tr_cpMissingBlocksInPiece(tr_completion const* cp, tr_piece_index_t piece } else { - tr_block_index_t f, l; + tr_block_index_t f; + tr_block_index_t l; tr_torGetPieceBlockRange(cp->tor, piece, &f, &l); return (l + 1 - f) - tr_bitfieldCountRange(&cp->blockBitfield, f, l + 1); } @@ -261,7 +268,8 @@ size_t tr_cpMissingBytesInPiece(tr_completion const* cp, tr_piece_index_t piece) else { size_t haveBytes = 0; - tr_block_index_t f, l; + tr_block_index_t f; + tr_block_index_t l; size_t const pieceByteSize = tr_torPieceCountBytes(cp->tor, piece); tr_torGetPieceBlockRange(cp->tor, piece, &f, &l); @@ -292,7 +300,8 @@ bool tr_cpFileIsComplete(tr_completion const* cp, tr_file_index_t i) } else { - tr_block_index_t f, l; + tr_block_index_t f; + tr_block_index_t l; tr_torGetFileBlockRange(cp->tor, i, &f, &l); return tr_bitfieldCountRange(&cp->blockBitfield, f, l + 1) == (l + 1 - f); } diff --git a/libtransmission/crypto-test.c b/libtransmission/crypto-test.c index a1d7adfa5..c7ab98181 100644 --- a/libtransmission/crypto-test.c +++ b/libtransmission/crypto-test.c @@ -65,9 +65,11 @@ static int test_encrypt_decrypt(void) tr_crypto_ b; uint8_t hash[SHA_DIGEST_LENGTH]; char const test1[] = { "test1" }; - char buf11[sizeof(test1)], buf12[sizeof(test1)]; + char buf11[sizeof(test1)]; + char buf12[sizeof(test1)]; char const test2[] = { "@#)C$@)#(*%bvkdjfhwbc039bc4603756VB3)" }; - char buf21[sizeof(test2)], buf22[sizeof(test2)]; + char buf21[sizeof(test2)]; + char buf22[sizeof(test2)]; int i; for (i = 0; i < SHA_DIGEST_LENGTH; ++i) @@ -237,7 +239,8 @@ static bool base64_eq(char const* a, char const* b) static int test_base64(void) { size_t len; - char* in, * out; + char* in; + char* out; size_t i; out = tr_base64_encode_str("YOYO!", &len); diff --git a/libtransmission/crypto-utils-cyassl.c b/libtransmission/crypto-utils-cyassl.c index 89f1a2aef..7ade091b6 100644 --- a/libtransmission/crypto-utils-cyassl.c +++ b/libtransmission/crypto-utils-cyassl.c @@ -240,7 +240,8 @@ void tr_dh_free(tr_dh_ctx_t raw_handle) bool tr_dh_make_key(tr_dh_ctx_t raw_handle, size_t private_key_length UNUSED, uint8_t* public_key, size_t* public_key_length) { struct tr_dh_ctx* handle = raw_handle; - word32 my_private_key_length, my_public_key_length; + word32 my_private_key_length; + word32 my_public_key_length; tr_lock* rng_lock = get_rng_lock(); assert(handle != NULL); diff --git a/libtransmission/crypto-utils-openssl.c b/libtransmission/crypto-utils-openssl.c index d655c0520..67e372582 100644 --- a/libtransmission/crypto-utils-openssl.c +++ b/libtransmission/crypto-utils-openssl.c @@ -301,7 +301,8 @@ tr_dh_ctx_t tr_dh_new(uint8_t const* prime_num, size_t prime_num_length, uint8_t size_t generator_num_length) { DH* handle = DH_new(); - BIGNUM* p, * g; + BIGNUM* p; + BIGNUM* g; assert(prime_num != NULL); assert(generator_num != NULL); @@ -333,7 +334,8 @@ void tr_dh_free(tr_dh_ctx_t handle) bool tr_dh_make_key(tr_dh_ctx_t raw_handle, size_t private_key_length, uint8_t* public_key, size_t* public_key_length) { DH* handle = raw_handle; - int dh_size, my_public_key_length; + int dh_size; + int my_public_key_length; BIGNUM const* my_public_key; assert(handle != NULL); @@ -364,7 +366,8 @@ bool tr_dh_make_key(tr_dh_ctx_t raw_handle, size_t private_key_length, uint8_t* tr_dh_secret_t tr_dh_agree(tr_dh_ctx_t handle, uint8_t const* other_public_key, size_t other_public_key_length) { struct tr_dh_secret* ret; - int dh_size, secret_key_length; + int dh_size; + int secret_key_length; BIGNUM* other_key; assert(handle != NULL); diff --git a/libtransmission/file-posix.c b/libtransmission/file-posix.c index d598f866e..dedece46a 100644 --- a/libtransmission/file-posix.c +++ b/libtransmission/file-posix.c @@ -272,7 +272,8 @@ bool tr_sys_path_is_relative(char const* path) bool tr_sys_path_is_same(char const* path1, char const* path2, tr_error** error) { bool ret = false; - struct stat sb1, sb2; + struct stat sb1; + struct stat sb2; assert(path1 != NULL); assert(path2 != NULL); diff --git a/libtransmission/file-test.c b/libtransmission/file-test.c index 7b44bc880..11e891af8 100644 --- a/libtransmission/file-test.c +++ b/libtransmission/file-test.c @@ -159,7 +159,8 @@ static int test_get_info(void) tr_sys_path_info info; tr_sys_file_t fd; tr_error* err = NULL; - char* path1, * path2; + char* path1; + char* path2; time_t t; path1 = tr_buildPath(test_dir, "a", NULL); @@ -263,7 +264,8 @@ static int test_path_exists(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2; + char* path1; + char* path2; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); @@ -371,7 +373,9 @@ static int test_path_is_same(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2, * path3; + char* path1; + char* path2; + char* path3; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); @@ -583,7 +587,8 @@ static int test_path_resolve(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2; + char* path1; + char* path2; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); @@ -776,7 +781,9 @@ static int test_path_rename(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2, * path3; + char* path1; + char* path2; + char* path3; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); @@ -892,7 +899,9 @@ static int test_path_remove(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2, * path3; + char* path1; + char* path2; + char* path3; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); @@ -1377,7 +1386,8 @@ static int test_dir_create(void) { char* const test_dir = create_test_dir(__FUNCTION__); tr_error* err = NULL; - char* path1, * path2; + char* path1; + char* path2; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(path1, "b", NULL); @@ -1477,8 +1487,10 @@ static int test_dir_read_impl(char const* path, bool* have1, bool* have2) static int test_dir_read(void) { char* const test_dir = create_test_dir(__FUNCTION__); - char* path1, * path2; - bool have1, have2; + char* path1; + char* path2; + bool have1; + bool have2; path1 = tr_buildPath(test_dir, "a", NULL); path2 = tr_buildPath(test_dir, "b", NULL); diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index 4f1673733..6bfe66c5d 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -750,7 +750,8 @@ static ReadState readPeerId(tr_handshake* handshake, struct evbuffer* inbuf) static ReadState readYa(tr_handshake* handshake, struct evbuffer* inbuf) { uint8_t ya[KEY_LEN]; - uint8_t* walk, outbuf[KEY_LEN + PadB_MAXLEN]; + uint8_t* walk; + uint8_t outbuf[KEY_LEN + PadB_MAXLEN]; uint8_t const* myKey; int len; diff --git a/libtransmission/json-test.c b/libtransmission/json-test.c index 4e3d8c7a9..b22edae65 100644 --- a/libtransmission/json-test.c +++ b/libtransmission/json-test.c @@ -155,7 +155,11 @@ static int test1(void) " }\n" " }\n" "}\n"; - tr_variant top, * headers, * body, * args, * ids; + tr_variant top; + tr_variant* headers; + tr_variant* body; + tr_variant* args; + tr_variant* ids; char const* str; int64_t i; int const err = tr_variantFromJson(&top, in, strlen(in)); diff --git a/libtransmission/magnet.c b/libtransmission/magnet.c index 9537b8ab3..aa990f4cc 100644 --- a/libtransmission/magnet.c +++ b/libtransmission/magnet.c @@ -42,7 +42,9 @@ static int const base32LookupLen = sizeof(base32Lookup) / sizeof(base32Lookup[0] static void base32_to_sha1(uint8_t* out, char const* in, size_t const inlen) { size_t const outlen = 20; - size_t i, index, offset; + size_t i; + size_t index; + size_t offset; memset(out, 0, 20); @@ -130,7 +132,8 @@ tr_magnet_info* tr_magnetParse(char const* uri) char const* delim = strchr(key, '='); char const* val = delim == NULL ? NULL : delim + 1; char const* next = strchr(delim == NULL ? key : val, '&'); - size_t keylen, vallen; + size_t keylen; + size_t vallen; if (delim != NULL) { diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index 504b3e550..1463d9f8d 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -263,7 +263,9 @@ static char const* getannounce(tr_info* inf, tr_variant* meta) if (tr_variantDictFindList(meta, TR_KEY_announce_list, &tiers)) { int n; - int i, j, validTiers; + int i; + int j; + int validTiers; int const numTiers = tr_variantListSize(tiers); n = 0; diff --git a/libtransmission/net.c b/libtransmission/net.c index 3e5bc8317..aeec268ed 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -506,7 +506,8 @@ void tr_netClose(tr_session* session, tr_socket_t s) static int get_source_address(struct sockaddr const* dst, socklen_t dst_len, struct sockaddr* src, socklen_t* src_len) { tr_socket_t s; - int rc, save; + int rc; + int save; s = socket(dst->sa_family, SOCK_DGRAM, 0); diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index f85ded87b..085d3463a 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -772,7 +772,8 @@ static struct block_request* requestListLookup(tr_swarm* s, tr_block_index_t blo static void getBlockRequestPeers(tr_swarm* s, tr_block_index_t block, tr_ptrArray* peerArr) { bool exact; - int i, pos; + int i; + int pos; struct block_request key; key.block = block; @@ -916,7 +917,10 @@ static int comparePieceByWeight(void const* va, void const* vb) { struct weighted_piece const* a = va; struct weighted_piece const* b = vb; - int ia, ib, missing, pending; + int ia; + int ib; + int missing; + int pending; tr_torrent const* tor = weightTorrent; uint16_t const* rep = weightReplication; @@ -1688,7 +1692,8 @@ static void removeRequestFromTables(tr_swarm* s, tr_block_index_t block, tr_peer either way we need to remove all its requests */ static void peerDeclinedAllRequests(tr_swarm* s, tr_peer const* peer) { - int i, n; + int i; + int n; tr_block_index_t* blocks = tr_new(tr_block_index_t, s->requestCount); for (i = n = 0; i < s->requestCount; ++i) @@ -2979,7 +2984,8 @@ void tr_peerMgrClearInterest(tr_torrent* tor) /* does this peer have any pieces that we want? */ static bool isPeerInteresting(tr_torrent* const tor, bool const* const piece_is_interesting, tr_peer const* const peer) { - tr_piece_index_t i, n; + tr_piece_index_t i; + tr_piece_index_t n; /* these cases should have already been handled by the calling code... */ assert(!tr_torrentIsSeed(tor)); @@ -3288,7 +3294,9 @@ static inline bool isBandwidthMaxedOut(tr_bandwidth const* b, uint64_t const now static void rechokeUploads(tr_swarm* s, uint64_t const now) { - int i, size, unchokedInterested; + int i; + int size; + int unchokedInterested; int const peerCount = tr_ptrArraySize(&s->peers); tr_peer** peers = (tr_peer**)tr_ptrArrayBase(&s->peers); struct ChokeData* choke = tr_new0(struct ChokeData, peerCount); @@ -3380,7 +3388,8 @@ static void rechokeUploads(tr_swarm* s, uint64_t const now) if (choke[i].isInterested) { tr_peerMsgs const* msgs = choke[i].msgs; - int x = 1, y; + int x = 1; + int y; if (isNew(msgs)) { @@ -3702,7 +3711,8 @@ static void sortPeersByLivelinessImpl(tr_peer** peers, void** clientData, int n, void const* vb)) { int i; - struct peer_liveliness* lives, * l; + struct peer_liveliness* lives; + struct peer_liveliness* l; /* build a sortable array of peer + extra info */ lives = l = tr_new0(struct peer_liveliness, n); @@ -4336,7 +4346,8 @@ static struct peer_candidate* getPeerCandidates(tr_session* session, int* candid while ((tor = tr_torrentNext(session, tor)) != NULL) { - int i, nAtoms; + int i; + int nAtoms; struct peer_atom** atoms; if (!tor->swarm->isRunning) @@ -4439,7 +4450,8 @@ static void initiateCandidateConnection(tr_peerMgr* mgr, struct peer_candidate* static void makeNewPeerConnections(struct tr_peerMgr* mgr, int const max) { - int i, n; + int i; + int n; struct peer_candidate* candidates; candidates = getPeerCandidates(mgr->session, &n, max); diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 2042382e1..1547b52c6 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -580,7 +580,8 @@ size_t tr_generateAllowedSet(tr_piece_index_t* setmePieces, size_t desiredSetSiz if (addr->type == TR_AF_INET) { - uint8_t w[SHA_DIGEST_LENGTH + 4], * walk = w; + uint8_t w[SHA_DIGEST_LENGTH + 4]; + uint8_t* walk = w; uint8_t x[SHA_DIGEST_LENGTH]; uint32_t ui32 = ntohl(htonl(addr->addr.addr4.s_addr) & 0xffffff00); /* (1) */ @@ -966,7 +967,8 @@ static void sendLtepHandshake(tr_peerMsgs* msgs) static void parseLtepHandshake(tr_peerMsgs* msgs, uint32_t len, struct evbuffer* inbuf) { int64_t i; - tr_variant val, * sub; + tr_variant val; + tr_variant* sub; uint8_t* tmp = tr_new(uint8_t, len); uint8_t const* addr; size_t addr_len; @@ -1168,7 +1170,8 @@ static void parseUtPex(tr_peerMsgs* msgs, uint32_t msglen, struct evbuffer* inbu if (tr_variantDictFindRaw(&val, TR_KEY_added, &added, &added_len)) { tr_pex* pex; - size_t i, n; + size_t i; + size_t n; size_t added_f_len = 0; uint8_t const* added_f = NULL; @@ -1195,7 +1198,8 @@ static void parseUtPex(tr_peerMsgs* msgs, uint32_t msglen, struct evbuffer* inbu if (tr_variantDictFindRaw(&val, TR_KEY_added6, &added, &added_len)) { tr_pex* pex; - size_t i, n; + size_t i; + size_t n; size_t added_f_len = 0; uint8_t const* added_f = NULL; diff --git a/libtransmission/platform.c b/libtransmission/platform.c index 4466f2a23..c7d568c77 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -569,7 +569,8 @@ char const* tr_getWebClientDir(tr_session const* session UNUSED) #else /* everyone else, follow the XDG spec */ - tr_list* candidates = NULL, * l; + tr_list* candidates = NULL; + tr_list* l; char* tmp; /* XDG_DATA_HOME should be the first in the list of candidates */ diff --git a/libtransmission/port-forwarding.c b/libtransmission/port-forwarding.c index 6114d7f14..fe283ff1e 100644 --- a/libtransmission/port-forwarding.c +++ b/libtransmission/port-forwarding.c @@ -110,7 +110,8 @@ static void natPulse(tr_shared* s, bool do_check) static void set_evtimer_from_status(tr_shared* s) { - int sec = 0, msec = 0; + int sec = 0; + int msec = 0; /* when to wake up again */ switch (tr_sharedTraversalStatus(s)) diff --git a/libtransmission/quark-test.c b/libtransmission/quark-test.c index c951eb3df..be4eb5596 100644 --- a/libtransmission/quark-test.c +++ b/libtransmission/quark-test.c @@ -30,8 +30,10 @@ static int test_static_quarks(void) for (i = 0; i + 1 < TR_N_KEYS; i++) { - size_t len1, len2; - char const* str1, * str2; + size_t len1; + size_t len2; + char const* str1; + char const* str2; str1 = tr_quark_get_string((tr_quark)i, &len1); str2 = tr_quark_get_string((tr_quark)(i + 1), &len2); diff --git a/libtransmission/rpc-server.c b/libtransmission/rpc-server.c index b713db485..731d4d480 100644 --- a/libtransmission/rpc-server.c +++ b/libtransmission/rpc-server.c @@ -220,7 +220,8 @@ static void handle_upload(struct evhttp_request* req, struct tr_rpc_server* serv { struct tr_mimepart* p = tr_ptrArrayNth(&parts, i); size_t body_len = p->body_len; - tr_variant top, * args; + tr_variant top; + tr_variant* args; tr_variant test; bool have_source = false; char* body = p->body; diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index a015b5bd2..993bf35dc 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -1424,7 +1424,8 @@ static char const* torrentSetLocation(tr_session* session, tr_variant* args_in, } bool move; - int i, torrentCount; + int i; + int torrentCount; tr_torrent** torrents = getTorrents(session, args_in, &torrentCount); if (!tr_variantDictFindBool(args_in, TR_KEY_move, &move)) diff --git a/libtransmission/session.c b/libtransmission/session.c index b532bb52e..b26c8d102 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -1933,7 +1933,8 @@ static void sessionCloseImplWaitForIdleUdp(evutil_socket_t foo UNUSED, short bar static void sessionCloseImplStart(tr_session* session) { - int i, n; + int i; + int n; tr_torrent** torrents; session->isClosing = true; diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 10d213199..42bb232ad 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -669,7 +669,8 @@ static tr_piece_index_t getBytePiece(tr_info const* info, uint64_t byteOffset) static void initFilePieces(tr_info* info, tr_file_index_t fileIndex) { tr_file* file; - uint64_t firstByte, lastByte; + uint64_t firstByte; + uint64_t lastByte; assert(info); assert(fileIndex < info->fileCount); @@ -1324,7 +1325,8 @@ static double getVerifyProgress(tr_torrent const* tor) if (tr_torrentHasMetadata(tor)) { - tr_piece_index_t i, n; + tr_piece_index_t i; + tr_piece_index_t n; tr_piece_index_t checked = 0; for (i = 0, n = tor->info.pieceCount; i != n; ++i) @@ -2230,7 +2232,8 @@ static void onSigCHLD(int i UNUSED) static void torrentCallScript(tr_torrent const* tor, char const* script) { - char timeStr[128], * newlinePos; + char timeStr[128]; + char* newlinePos; time_t const now = tr_time(); tr_strlcpy(timeStr, ctime(&now), sizeof(timeStr)); @@ -2774,7 +2777,8 @@ void tr_torrentSetPieceChecked(tr_torrent* tor, tr_piece_index_t pieceIndex) void tr_torrentSetChecked(tr_torrent* tor, time_t when) { - tr_piece_index_t i, n; + tr_piece_index_t i; + tr_piece_index_t n; assert(tr_isTorrent(tor)); @@ -3113,7 +3117,8 @@ static void removeEmptyFoldersAndJunkFiles(char const* folder) */ static void deleteLocalData(tr_torrent* tor, tr_fileFunc func) { - int i, n; + int i; + int n; tr_file_index_t f; char* base; tr_sys_dir_t odir; diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c index 662d7a4b1..018921dfe 100644 --- a/libtransmission/tr-dht.c +++ b/libtransmission/tr-dht.c @@ -74,7 +74,8 @@ struct bootstrap_closure tr_session* session; uint8_t* nodes; uint8_t* nodes6; - size_t len, len6; + size_t len; + size_t len6; }; static bool bootstrap_done(tr_session* session, int af) @@ -115,7 +116,9 @@ static int bootstrap_af(tr_session* session) static void bootstrap_from_name(char const* name, tr_port port, int af) { - struct addrinfo hints, * info, * infop; + struct addrinfo hints; + struct addrinfo* info; + struct addrinfo* infop; char pp[10]; int rc; @@ -156,7 +159,8 @@ static void dht_bootstrap(void* closure) { struct bootstrap_closure* cl = closure; int i; - int num = cl->len / 6, num6 = cl->len6 / 18; + int num = cl->len / 6; + int num6 = cl->len6 / 18; if (session != cl->session) { @@ -319,9 +323,11 @@ int tr_dhtInit(tr_session* ss) int rc; bool have_id = false; char* dat_file; - uint8_t* nodes = NULL, * nodes6 = NULL; + uint8_t* nodes = NULL; + uint8_t* nodes6 = NULL; uint8_t const* raw; - size_t len, len6; + size_t len; + size_t len6; struct bootstrap_closure* cl; if (session != NULL) /* already initialized */ @@ -440,9 +446,13 @@ void tr_dhtUninit(tr_session* ss) tr_variant benc; struct sockaddr_in sins[300]; struct sockaddr_in6 sins6[300]; - char compact[300 * 6], compact6[300 * 18]; + char compact[300 * 6]; + char compact6[300 * 18]; char* dat_file; - int i, j, num = 300, num6 = 300; + int i; + int j; + int num = 300; + int num6 = 300; int n = dht_get_nodes(sins, &num, sins6, &num6); tr_logAddNamedInfo("DHT", "Saving %d (%d + %d) nodes", n, num, num6); @@ -505,7 +515,9 @@ struct getstatus_closure static void getstatus(void* cl) { struct getstatus_closure* closure = cl; - int good, dubious, incoming; + int good; + int dubious; + int incoming; dht_nodes(closure->af, &good, &dubious, NULL, &incoming); @@ -687,7 +699,10 @@ static void callback(void* ignore UNUSED, int event, unsigned char const* info_h static int tr_dhtAnnounce(tr_torrent* tor, int af, bool announce) { - int rc, status, numnodes, ret = 0; + int rc; + int status; + int numnodes; + int ret = 0; if (!tr_torrentAllowsDHT(tor)) { diff --git a/libtransmission/tr-lpd.c b/libtransmission/tr-lpd.c index 62d1d8ba9..ca67b8b82 100644 --- a/libtransmission/tr-lpd.c +++ b/libtransmission/tr-lpd.c @@ -95,7 +95,8 @@ static struct sockaddr_in lpd_mcastAddr; /**creator(); QString const date = torrents[0]->dateCreated().toString(); diff --git a/qt/FileTreeItem.cc b/qt/FileTreeItem.cc index cb6ca7ad3..52864f306 100644 --- a/qt/FileTreeItem.cc +++ b/qt/FileTreeItem.cc @@ -196,7 +196,8 @@ void FileTreeItem::getSubtreeWantedSize(uint64_t& have, uint64_t& total) const double FileTreeItem::progress() const { double d(0); - uint64_t have(0), total(0); + uint64_t have(0); + uint64_t total(0); getSubtreeWantedSize(have, total); diff --git a/qt/Formatter.cc b/qt/Formatter.cc index fb2a0d416..3da7373ed 100644 --- a/qt/Formatter.cc +++ b/qt/Formatter.cc @@ -144,8 +144,13 @@ QString Formatter::ratioToString(double ratio) QString Formatter::timeToString(int seconds) { - int days, hours, minutes; - QString d, h, m, s; + int days; + int hours; + int minutes; + QString d; + QString h; + QString m; + QString s; QString str; if (seconds < 0) diff --git a/qt/MainWindow.cc b/qt/MainWindow.cc index f04f5c38f..29a052527 100644 --- a/qt/MainWindow.cc +++ b/qt/MainWindow.cc @@ -715,8 +715,10 @@ void MainWindow::refreshTrayIconSoon() void MainWindow::refreshTrayIcon() { - Speed upSpeed, downSpeed; - size_t upCount, downCount; + Speed upSpeed; + Speed downSpeed; + size_t upCount; + size_t downCount; QString tip; myModel.getTransferSpeed(upSpeed, upCount, downSpeed, downCount); @@ -743,8 +745,10 @@ void MainWindow::refreshTrayIcon() void MainWindow::refreshStatusBar() { - Speed upSpeed, downSpeed; - size_t upCount, downCount; + Speed upSpeed; + Speed downSpeed; + size_t upCount; + size_t downCount; myModel.getTransferSpeed(upSpeed, upCount, downSpeed, downCount); ui.uploadSpeedLabel->setText(Formatter::uploadSpeedToString(upSpeed)); @@ -1317,7 +1321,8 @@ void MainWindow::removeTorrents(bool const deleteFiles) { QSet ids; QMessageBox msgBox(this); - QString primary_text, secondary_text; + QString primary_text; + QString secondary_text; int incomplete = 0; int connected = 0; int count; diff --git a/qt/TorrentModel.cc b/qt/TorrentModel.cc index 4eda1ae3a..faa6d4d6f 100644 --- a/qt/TorrentModel.cc +++ b/qt/TorrentModel.cc @@ -285,8 +285,10 @@ void TorrentModel::removeTorrent(int id) void TorrentModel::getTransferSpeed(Speed& uploadSpeed, size_t& uploadPeerCount, Speed& downloadSpeed, size_t& downloadPeerCount) { - Speed upSpeed, downSpeed; - size_t upCount = 0, downCount = 0; + Speed upSpeed; + Speed downSpeed; + size_t upCount = 0; + size_t downCount = 0; for (Torrent const* const tor : myTorrents) { -- 2.40.0