Avoid declaring multiple variables on the same line

This commit is contained in:
Mike Gelfand 2017-05-01 18:46:41 +03:00
parent 1bc247c105
commit e1d53855f4
56 changed files with 533 additions and 214 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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 */

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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)
{

View File

@ -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< ");

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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));

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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));

View File

@ -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)
{

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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))

View File

@ -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);

View File

@ -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;

View File

@ -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))

View File

@ -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;

View File

@ -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;

View File

@ -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))
{

View File

@ -95,7 +95,8 @@ static struct sockaddr_in lpd_mcastAddr; /**<initialized from the above constant
* @brief Protocol-related information carried by a Local Peer Discovery packet */
struct lpd_protocolVersion
{
int major, minor;
int major;
int minor;
};
enum lpd_enumTimeToLive
@ -169,7 +170,8 @@ static int lpd_unsolicitedMsgCounter;
*/
static char const* lpd_extractHeader(char const* s, struct lpd_protocolVersion* const ver)
{
int major = -1, minor = -1;
int major = -1;
int minor = -1;
size_t len;
assert(s != NULL);
@ -294,7 +296,8 @@ static void on_upkeep_timer(evutil_socket_t, short, void*);
int tr_lpdInit(tr_session* ss, tr_address* tr_addr UNUSED)
{
struct ip_mreq mcastReq;
int const opt_on = 1, opt_off = 0;
int const opt_on = 1;
int const opt_off = 0;
if (session != NULL) /* already initialized */
{
@ -551,7 +554,8 @@ static int tr_lpdConsiderAnnounce(tr_pex* peer, char const* const msg)
struct lpd_protocolVersion ver = { -1, -1 };
char value[maxValueLen] = { 0 };
char hashString[maxHashLen] = { 0 };
int res = 0, peerPort = 0;
int res = 0;
int peerPort = 0;
if (peer != NULL && msg != NULL)
{

View File

@ -52,8 +52,12 @@ THE SOFTWARE.
static void set_socket_buffers(tr_socket_t fd, bool large)
{
int size, rbuf, sbuf, rc;
socklen_t rbuf_len = sizeof(rbuf), sbuf_len = sizeof(sbuf);
int size;
int rbuf;
int sbuf;
int rc;
socklen_t rbuf_len = sizeof(rbuf);
socklen_t sbuf_len = sizeof(sbuf);
char err_buf[512];
size = large ? RECV_BUFFER_SIZE : SMALL_BUFFER_SIZE;

View File

@ -53,7 +53,8 @@ static int test_strip_positional_args(void)
static int test_strstrip(void)
{
char* in, * out;
char* in;
char* out;
/* strstrip */
in = tr_strdup(" test ");
@ -441,7 +442,9 @@ static char* test_strdup_printf_valist(char const* fmt, ...)
static int test_strdup_printf(void)
{
char* s, * s2, * s3;
char* s;
char* s2;
char* s3;
s = tr_strdup_printf("%s", "test");
check_streq("test", s);

View File

@ -989,7 +989,8 @@ int tr_lowerBound(void const* key, void const* base, size_t nmemb, size_t size,
do \
{ \
register size_t __size = (size); \
register char* __a = (a), * __b = (b); \
register char* __a = (a); \
register char* __b = (b); \
if (__a != __b) \
{ \
do \
@ -1318,7 +1319,8 @@ char* tr_win32_format_message(uint32_t code)
void tr_win32_make_args_utf8(int* argc, char*** argv)
{
int my_argc, i;
int my_argc;
int i;
char** my_argv;
wchar_t** my_wide_argv;
@ -1393,7 +1395,8 @@ struct number_range
*/
static bool parseNumberSection(char const* str, size_t len, struct number_range* setme)
{
long a, b;
long a;
long b;
bool success;
char* end;
int const error = errno;

View File

@ -408,7 +408,8 @@ static int testJSON(void)
static int testMerge(void)
{
size_t len;
tr_variant dest, src;
tr_variant dest;
tr_variant src;
int64_t i;
char const* s;
tr_quark const i1 = tr_quark_new("i1", 2);

View File

@ -229,8 +229,10 @@ static int test_watch_two_dirs(void)
char* const test_dir = libtest_sandbox_create();
char* const dir1 = tr_buildPath(test_dir, "a", NULL);
char* const dir2 = tr_buildPath(test_dir, "b", NULL);
callback_data wd1_data = CB_DATA_STATIC_INIT, wd2_data = CB_DATA_STATIC_INIT;
tr_watchdir_t wd1, wd2;
callback_data wd1_data = CB_DATA_STATIC_INIT;
callback_data wd2_data = CB_DATA_STATIC_INIT;
tr_watchdir_t wd1;
tr_watchdir_t wd2;
ev_base = event_base_new();

View File

@ -486,7 +486,9 @@ static void tr_webThreadFunc(void* vsession)
int usec;
int max_fd;
struct timeval t;
fd_set r_fd_set, w_fd_set, c_fd_set;
fd_set r_fd_set;
fd_set w_fd_set;
fd_set c_fd_set;
max_fd = 0;
FD_ZERO(&r_fd_set);

View File

@ -864,7 +864,8 @@ void DetailsDialog::refresh()
if (!torrents.empty())
{
bool mixed_creator = false, mixed_date = false;
bool mixed_creator = false;
bool mixed_date = false;
QString const creator = torrents[0]->creator();
QString const date = torrents[0]->dateCreated().toString();

View File

@ -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);

View File

@ -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)

View File

@ -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<int> ids;
QMessageBox msgBox(this);
QString primary_text, secondary_text;
QString primary_text;
QString secondary_text;
int incomplete = 0;
int connected = 0;
int count;

View File

@ -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)
{