cleanup: Adapt loop counter to proper type

Fixing a couple of -Wsign-compare warnings.
This commit is contained in:
Michael Vetter
2026-02-19 12:23:40 +01:00
parent 3e0c9e79e4
commit 6e61383e97
12 changed files with 33 additions and 33 deletions

View File

@@ -1767,7 +1767,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
"/history", "/vercheck", "/privileges", "/wrap",
"/carbons", "/slashguard", "/mam", "/silence" };
for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
if (result) {
return result;
@@ -1784,7 +1784,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
// Remove quote character before and after names when doing autocomplete
char* unquoted = strip_arg_quotes(input);
for (int i = 0; i < ARRAY_SIZE(nick_choices); i++) {
for (size_t i = 0; i < ARRAY_SIZE(nick_choices); i++) {
result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE, previous);
if (result) {
free(unquoted);
@@ -1799,7 +1799,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
gchar* contact_choices[] = { "/msg", "/info" };
// Remove quote character before and after names when doing autocomplete
char* unquoted = strip_arg_quotes(input);
for (int i = 0; i < ARRAY_SIZE(contact_choices); i++) {
for (size_t i = 0; i < ARRAY_SIZE(contact_choices); i++) {
result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete, previous, NULL);
if (result) {
free(unquoted);
@@ -1814,7 +1814,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
free(unquoted);
gchar* resource_choices[] = { "/caps", "/ping" };
for (int i = 0; i < ARRAY_SIZE(resource_choices); i++) {
for (size_t i = 0; i < ARRAY_SIZE(resource_choices); i++) {
result = autocomplete_param_with_func(input, resource_choices[i], roster_fulljid_autocomplete, previous, NULL);
if (result) {
return result;
@@ -1823,7 +1823,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
}
gchar* invite_choices[] = { "/join" };
for (int i = 0; i < ARRAY_SIZE(invite_choices); i++) {
for (size_t i = 0; i < ARRAY_SIZE(invite_choices); i++) {
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous, NULL);
if (result) {
return result;
@@ -1843,7 +1843,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
{ "/inputwin", winpos_ac },
};
for (int i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
for (size_t i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
result = autocomplete_param_with_ac(input, ac_cmds[i].cmd, ac_cmds[i].completer, TRUE, previous);
if (result) {
return result;
@@ -1932,7 +1932,7 @@ _who_autocomplete(ProfWin* window, const char* const input, gboolean previous)
"/who chat", "/who away", "/who xa", "/who dnd", "/who available",
"/who unavailable" };
for (int i = 0; i < ARRAY_SIZE(group_commands); i++) {
for (size_t i = 0; i < ARRAY_SIZE(group_commands); i++) {
result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete, previous, NULL);
if (result) {
return result;
@@ -2254,7 +2254,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current",
"/notify room text", "/notify chat text", "/notify room offline" };
for (int i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL);
if (result) {
return result;
@@ -2287,7 +2287,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
}
gchar* boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger" };
for (int i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
result = autocomplete_param_with_func(input, boolean_choices2[i], prefs_autocomplete_boolean_choice, previous, NULL);
if (result) {
return result;
@@ -3733,7 +3733,7 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
"/account disable", "/account rename", "/account clear", "/account remove",
"/account default set" };
for (int i = 0; i < ARRAY_SIZE(account_choice); i++) {
for (size_t i = 0; i < ARRAY_SIZE(account_choice); i++) {
found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all, previous, NULL);
if (found) {
return found;
@@ -4274,7 +4274,7 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
gboolean is_num = TRUE;
if (num_args >= 2) {
for (int i = 0; i < strlen(args[1]); i++) {
for (size_t i = 0; i < strlen(args[1]); i++) {
if (!isdigit((int)args[1][i])) {
is_num = FALSE;
break;

View File

@@ -2796,7 +2796,7 @@ _cmd_index(const Command* cmd)
g_string_free(index_source, TRUE);
GString* index = g_string_new("");
for (int i = 0; i < g_strv_length(tokens); i++) {
for (guint i = 0; i < g_strv_length(tokens); i++) {
index = g_string_append(index, tokens[i]);
index = g_string_append(index, " ");
}

View File

@@ -253,7 +253,7 @@ _prefs_load(void)
gsize len = 0;
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
autocomplete_add(room_trigger_ac, triggers[i]);
}
}
@@ -418,7 +418,7 @@ prefs_message_get_triggers(const char* const message)
gsize len = 0;
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
auto_gchar gchar* trigger_lower = g_utf8_strdown(triggers[i], -1);
if (g_strrstr(message_lower, trigger_lower)) {
result = g_list_append(result, strdup(triggers[i]));
@@ -1392,7 +1392,7 @@ prefs_get_room_notify_triggers(void)
gsize len = 0;
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
result = g_list_append(result, strdup(triggers[i]));
}
@@ -1739,7 +1739,7 @@ prefs_get_aliases(void)
gsize len;
auto_gcharv gchar** keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL);
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
char* name = keys[i];
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);

View File

@@ -82,7 +82,7 @@ tlscerts_init(void)
gsize len = 0;
auto_gcharv gchar** groups = g_key_file_get_groups(tlscerts, &len);
for (int i = 0; i < g_strv_length(groups); i++) {
for (guint i = 0; i < g_strv_length(groups); i++) {
autocomplete_add(certs_ac, groups[i]);
}

View File

@@ -180,7 +180,7 @@ p_gpg_on_connect(const char* const barejid)
return;
}
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
GError* gerr = NULL;
gchar* jid = jids[i];
auto_gchar gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);

View File

@@ -126,7 +126,7 @@ plugins_init(void)
if (!plugins_pref) {
return;
}
for (int i = 0; i < g_strv_length(plugins_pref); i++) {
for (guint i = 0; i < g_strv_length(plugins_pref); i++) {
gboolean loaded = FALSE;
gchar* filename = plugins_pref[i];
#ifdef HAVE_PYTHON

View File

@@ -175,7 +175,7 @@ autocomplete_add(Autocomplete ac, const char* item)
void
autocomplete_add_all(Autocomplete ac, char** items)
{
for (int i = 0; i < g_strv_length(items); i++) {
for (guint i = 0; i < g_strv_length(items); i++) {
autocomplete_add(ac, items[i]);
}
}
@@ -205,7 +205,7 @@ autocomplete_remove(Autocomplete ac, const char* const item)
void
autocomplete_remove_all(Autocomplete ac, char** items)
{
for (int i = 0; i < g_strv_length(items); i++) {
for (guint i = 0; i < g_strv_length(items); i++) {
autocomplete_remove(ac, items[i]);
}
}

View File

@@ -328,7 +328,7 @@ GHashTable*
parse_options(gchar** args, gchar** opt_keys, gboolean* res)
{
GList* keys = NULL;
for (int i = 0; i < g_strv_length(opt_keys); i++) {
for (guint i = 0; i < g_strv_length(opt_keys); i++) {
keys = g_list_append(keys, opt_keys[i]);
}
@@ -344,7 +344,7 @@ parse_options(gchar** args, gchar** opt_keys, gboolean* res)
// validate options
GList* found_keys = NULL;
for (int curr = 0; curr < g_strv_length(args); curr += 2) {
for (guint curr = 0; curr < g_strv_length(args); curr += 2) {
// check if option valid
if (g_list_find_custom(keys, args[curr], (GCompareFunc)g_strcmp0) == NULL) {
*res = FALSE;
@@ -377,7 +377,7 @@ parse_options(gchar** args, gchar** opt_keys, gboolean* res)
// create map
options = g_hash_table_new(g_str_hash, g_str_equal);
*res = TRUE;
for (int curr = 0; curr < g_strv_length(args); curr += 2) {
for (guint curr = 0; curr < g_strv_length(args); curr += 2) {
g_hash_table_insert(options, args[curr], args[curr + 1]);
}

View File

@@ -117,7 +117,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
cons_show("");
win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]);
win_print(console, THEME_HELP_HEADER, "-", "");
int i;
size_t i;
for (i = 0; i < strlen(cmd) - 1; i++) {
win_append(console, THEME_HELP_HEADER, "-");
}
@@ -131,7 +131,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
win_println(console, THEME_HELP_HEADER, "-", "Description");
win_println(console, THEME_DEFAULT, "-", "%s", help->desc);
int maxlen = 0;
size_t maxlen = 0;
for (i = 0; help->args[i][0] != NULL; i++) {
if (strlen(help->args[i][0]) > maxlen)
maxlen = strlen(help->args[i][0]);
@@ -823,7 +823,7 @@ cons_show_qrcode(const char* const text)
static const size_t ZOOM_SIZE = 10;
QRcode* qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
int width = (qrcode->width * ZOOM_SIZE);
size_t width = (qrcode->width * ZOOM_SIZE);
unsigned char* data = qrcode->data;
ProfWin* console = wins_get_console();
@@ -835,7 +835,7 @@ cons_show_qrcode(const char* const text)
return;
}
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
for (size_t i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
strcat(pad, "\u2588\u2588");
}
@@ -2760,7 +2760,7 @@ cons_show_bookmarks_ignore(gchar** list, gsize len)
cons_show("");
cons_show("Ignored bookmarks:");
for (int i = 0; i < len; i++) {
for (gsize i = 0; i < len; i++) {
win_print(console, THEME_DEFAULT, "-", " %s", list[i]);
win_newline(console);
}

View File

@@ -1882,7 +1882,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
int curx = getcurx(win);
int cury;
int maxx = getmaxx(win);
size_t maxx = getmaxx(win);
// wrap required
if (curx + wordlen > maxx) {

View File

@@ -376,7 +376,7 @@ _caps_by_ver(const char* const ver)
auto_gcharv gchar** features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
GSList* features = NULL;
if (features_list && features_len > 0) {
for (int i = 0; i < features_len; i++) {
for (gsize i = 0; i < features_len; i++) {
features = g_slist_append(features, features_list[i]);
}
}

View File

@@ -222,7 +222,7 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
auto_char char* filename_cpy = strdup(upload->filename);
// strip spaces from filename (servers don't spaces)
for (int i = 0; i < strlen(filename_cpy); i++) {
for (size_t i = 0; i < strlen(filename_cpy); i++) {
if (filename_cpy[i] == ' ') {
filename_cpy[i] = '_';
}
@@ -1863,7 +1863,7 @@ stanza_get_error_message(xmpp_stanza_t* stanza)
STANZA_NAME_UNEXPECTED_REQUEST
};
for (int i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
for (size_t i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
xmpp_stanza_t* cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
if (cond_stanza) {
char* result = strdup(xmpp_stanza_get_name(cond_stanza));