Skip to content
Merged

Cleanup #2089

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ if is_debug
add_project_arguments([
'-ggdb3',
'-Wunused',
'-Wall',
'-Wextra',
], language: 'c')
endif

Expand Down
25 changes: 13 additions & 12 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -1863,7 +1863,8 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
}
parsed[i] = '\0';

char* (*ac_func)(ProfWin*, const char* const, gboolean) = g_hash_table_lookup(ac_funcs, parsed);
char* (*ac_func)(ProfWin*, const char* const, gboolean) = (char* (*)(ProfWin*, const char* const, gboolean))g_hash_table_lookup(ac_funcs, parsed);

if (ac_func) {
result = ac_func(window, input, previous);
if (result) {
Expand Down Expand Up @@ -1932,7 +1933,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;
Expand Down Expand Up @@ -2254,7 +2255,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;
Expand Down Expand Up @@ -2287,7 +2288,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;
Expand Down Expand Up @@ -3733,7 +3734,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;
Expand Down Expand Up @@ -4274,7 +4275,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;
Expand Down
2 changes: 1 addition & 1 deletion src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ");
}
Expand Down
8 changes: 4 additions & 4 deletions src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ _writecsv(int fd, const char* const str)

auto_char char* s = malloc(2 * len * sizeof(char));
char* c = s;
for (int i = 0; i < strlen(str); i++) {
for (size_t i = 0; i < strlen(str); i++) {
if (str[i] != '"')
*c++ = str[i];
else {
Expand Down Expand Up @@ -1387,7 +1387,7 @@ cmd_close(ProfWin* window, const char* const command, gchar** args)
gboolean is_num = TRUE;
int index = 0;
if (args[0] != NULL) {
for (int i = 0; i < strlen(args[0]); i++) {
for (size_t i = 0; i < strlen(args[0]); i++) {
if (!isdigit((int)args[0][i])) {
is_num = FALSE;
break;
Expand Down Expand Up @@ -1474,7 +1474,7 @@ gboolean
cmd_win(ProfWin* window, const char* const command, gchar** args)
{
gboolean is_num = TRUE;
for (int i = 0; i < strlen(args[0]); i++) {
for (size_t i = 0; i < strlen(args[0]); i++) {
if (!isdigit((int)args[0][i])) {
is_num = FALSE;
break;
Expand Down Expand Up @@ -9983,7 +9983,7 @@ cmd_vcard_set(ProfWin* window, const char* const command, gchar** args)
}

gboolean is_num = TRUE;
for (int i = 0; i < strlen(key); i++) {
for (size_t i = 0; i < strlen(key); i++) {
if (!isdigit((int)key[i])) {
is_num = FALSE;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/config/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ color_distance(const struct color_def* a, const struct color_def* b)
static int
find_closest_col(int h, int s, int l)
{
struct color_def a = { h, s, l };
struct color_def a = { h, s, l, NULL };
int min = 0;
int dmin = color_distance(&a, &color_names[0]);

Expand All @@ -369,7 +369,7 @@ find_col(const char* col_name, int n)
* blue.
*/

if (n >= sizeof(name)) {
if (n >= (int)sizeof(name)) {
/* truncate */
log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name));
n = sizeof(name) - 1;
Expand Down
8 changes: 4 additions & 4 deletions src/config/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down Expand Up @@ -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]));
Expand Down Expand Up @@ -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]));
}

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/config/tlscerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ main(int argc, char** argv)

GOptionEntry entries[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup" },
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup", NULL },
{ "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO, WARN (default), ERROR", "LEVEL" },
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Use an alternative configuration file", NULL },
{ "logfile", 'f', 0, G_OPTION_ARG_STRING, &log_file, "Specify log file", NULL },
Expand Down
14 changes: 7 additions & 7 deletions src/omemo/omemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
// Yourself as recipients in case of MUC
if (equals_our_barejid(recipients_iter->data)) {
if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
if ((uint32_t)GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data));
continue;
}
Expand Down Expand Up @@ -832,7 +832,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
log_debug("[OMEMO][SEND][Sender] Sending to device %d for %s ", address.device_id, address.name);
// Don't encrypt for this device (according to
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
if (address.device_id == omemo_ctx.device_id) {
if ((uint32_t)address.device_id == omemo_ctx.device_id) {
continue;
}

Expand Down Expand Up @@ -1030,7 +1030,7 @@ omemo_format_fingerprint(const char* const fingerprint)
{
char* output = malloc(strlen(fingerprint) + strlen(fingerprint) / 8);

int i, j;
size_t i, j;
for (i = 0, j = 0; i < strlen(fingerprint); i++) {
if (i > 0 && i % 8 == 0) {
output[j++] = '-';
Expand Down Expand Up @@ -1117,7 +1117,7 @@ omemo_is_trusted_identity(const char* const jid, const char* const fingerprint)
static char*
_omemo_fingerprint(ec_public_key* identity, gboolean formatted)
{
int i;
size_t i;
signal_buffer* identity_public_key;

ec_public_key_serialize(&identity_public_key, identity);
Expand Down Expand Up @@ -1161,8 +1161,8 @@ _omemo_fingerprint_decode(const char* const fingerprint, size_t* len)
{
unsigned char* output = malloc(strlen(fingerprint) / 2 + 1);

int i;
int j;
size_t i;
size_t j;
for (i = 0, j = 0; i < strlen(fingerprint);) {
if (!g_ascii_isxdigit(fingerprint[i])) {
i++;
Expand Down Expand Up @@ -1724,7 +1724,7 @@ _bytes_from_hex(const char* hex, size_t hex_size,

memset(bytes, 0, bytes_size);

for (int i = 0; (i < hex_size) && (i / 2 < bytes_size); i += 2) {
for (size_t i = 0; (i < hex_size) && (i / 2 < bytes_size); i += 2) {
b0 = ((unsigned char)hex[i + 0] & 0x1f) ^ 0x10;
b1 = ((unsigned char)hex[i + 1] & 0x1f) ^ 0x10;

Expand Down
6 changes: 3 additions & 3 deletions src/pgp/gpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ _p_gpg_free_pubkeyid(ProfPGPPubKeyId* pubkeyid)
free(pubkeyid);
}

static gpgme_error_t*
static gpgme_error_t
_p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_info, int prev_was_bad, int fd)
{
if (passphrase) {
Expand All @@ -109,7 +109,7 @@ _p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_in
gpgme_io_write(fd, passphrase_attempt, strlen(passphrase_attempt));
}

return 0;
return GPG_ERR_NO_ERROR;
}

static void
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/python_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,11 @@ static struct PyModuleDef profModule = {
"prof",
"",
-1,
apiMethods
apiMethods,
NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/tools/autocomplete.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down Expand Up @@ -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]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -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;
Expand Down Expand Up @@ -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]);
}

Expand Down
Loading
Loading