Skip to content

Commit 657de5f

Browse files
authored
Merge pull request #2089 from profanity-im/cleanup
Cleanup
2 parents 2b6bb1a + a1fe714 commit 657de5f

File tree

26 files changed

+126
-118
lines changed

26 files changed

+126
-118
lines changed

meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ if is_debug
6363
add_project_arguments([
6464
'-ggdb3',
6565
'-Wunused',
66+
'-Wall',
67+
'-Wextra',
6668
], language: 'c')
6769
endif
6870

src/command/cmd_ac.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
17671767
"/history", "/vercheck", "/privileges", "/wrap",
17681768
"/carbons", "/slashguard", "/mam", "/silence" };
17691769

1770-
for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
1770+
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
17711771
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
17721772
if (result) {
17731773
return result;
@@ -1784,7 +1784,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
17841784

17851785
// Remove quote character before and after names when doing autocomplete
17861786
char* unquoted = strip_arg_quotes(input);
1787-
for (int i = 0; i < ARRAY_SIZE(nick_choices); i++) {
1787+
for (size_t i = 0; i < ARRAY_SIZE(nick_choices); i++) {
17881788
result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE, previous);
17891789
if (result) {
17901790
free(unquoted);
@@ -1799,7 +1799,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
17991799
gchar* contact_choices[] = { "/msg", "/info" };
18001800
// Remove quote character before and after names when doing autocomplete
18011801
char* unquoted = strip_arg_quotes(input);
1802-
for (int i = 0; i < ARRAY_SIZE(contact_choices); i++) {
1802+
for (size_t i = 0; i < ARRAY_SIZE(contact_choices); i++) {
18031803
result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete, previous, NULL);
18041804
if (result) {
18051805
free(unquoted);
@@ -1814,7 +1814,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
18141814
free(unquoted);
18151815

18161816
gchar* resource_choices[] = { "/caps", "/ping" };
1817-
for (int i = 0; i < ARRAY_SIZE(resource_choices); i++) {
1817+
for (size_t i = 0; i < ARRAY_SIZE(resource_choices); i++) {
18181818
result = autocomplete_param_with_func(input, resource_choices[i], roster_fulljid_autocomplete, previous, NULL);
18191819
if (result) {
18201820
return result;
@@ -1823,7 +1823,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
18231823
}
18241824

18251825
gchar* invite_choices[] = { "/join" };
1826-
for (int i = 0; i < ARRAY_SIZE(invite_choices); i++) {
1826+
for (size_t i = 0; i < ARRAY_SIZE(invite_choices); i++) {
18271827
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous, NULL);
18281828
if (result) {
18291829
return result;
@@ -1843,7 +1843,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
18431843
{ "/inputwin", winpos_ac },
18441844
};
18451845

1846-
for (int i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
1846+
for (size_t i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
18471847
result = autocomplete_param_with_ac(input, ac_cmds[i].cmd, ac_cmds[i].completer, TRUE, previous);
18481848
if (result) {
18491849
return result;
@@ -1863,7 +1863,8 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
18631863
}
18641864
parsed[i] = '\0';
18651865

1866-
char* (*ac_func)(ProfWin*, const char* const, gboolean) = g_hash_table_lookup(ac_funcs, parsed);
1866+
char* (*ac_func)(ProfWin*, const char* const, gboolean) = (char* (*)(ProfWin*, const char* const, gboolean))g_hash_table_lookup(ac_funcs, parsed);
1867+
18671868
if (ac_func) {
18681869
result = ac_func(window, input, previous);
18691870
if (result) {
@@ -1932,7 +1933,7 @@ _who_autocomplete(ProfWin* window, const char* const input, gboolean previous)
19321933
"/who chat", "/who away", "/who xa", "/who dnd", "/who available",
19331934
"/who unavailable" };
19341935

1935-
for (int i = 0; i < ARRAY_SIZE(group_commands); i++) {
1936+
for (size_t i = 0; i < ARRAY_SIZE(group_commands); i++) {
19361937
result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete, previous, NULL);
19371938
if (result) {
19381939
return result;
@@ -2254,7 +2255,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
22542255

22552256
gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current",
22562257
"/notify room text", "/notify chat text", "/notify room offline" };
2257-
for (int i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
2258+
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
22582259
result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL);
22592260
if (result) {
22602261
return result;
@@ -2287,7 +2288,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
22872288
}
22882289

22892290
gchar* boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger" };
2290-
for (int i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
2291+
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
22912292
result = autocomplete_param_with_func(input, boolean_choices2[i], prefs_autocomplete_boolean_choice, previous, NULL);
22922293
if (result) {
22932294
return result;
@@ -3733,7 +3734,7 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
37333734
"/account disable", "/account rename", "/account clear", "/account remove",
37343735
"/account default set" };
37353736

3736-
for (int i = 0; i < ARRAY_SIZE(account_choice); i++) {
3737+
for (size_t i = 0; i < ARRAY_SIZE(account_choice); i++) {
37373738
found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all, previous, NULL);
37383739
if (found) {
37393740
return found;
@@ -4274,7 +4275,7 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
42744275
gboolean is_num = TRUE;
42754276

42764277
if (num_args >= 2) {
4277-
for (int i = 0; i < strlen(args[1]); i++) {
4278+
for (size_t i = 0; i < strlen(args[1]); i++) {
42784279
if (!isdigit((int)args[1][i])) {
42794280
is_num = FALSE;
42804281
break;

src/command/cmd_defs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,7 @@ _cmd_index(const Command* cmd)
27962796
g_string_free(index_source, TRUE);
27972797

27982798
GString* index = g_string_new("");
2799-
for (int i = 0; i < g_strv_length(tokens); i++) {
2799+
for (guint i = 0; i < g_strv_length(tokens); i++) {
28002800
index = g_string_append(index, tokens[i]);
28012801
index = g_string_append(index, " ");
28022802
}

src/command/cmd_funcs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ _writecsv(int fd, const char* const str)
10841084

10851085
auto_char char* s = malloc(2 * len * sizeof(char));
10861086
char* c = s;
1087-
for (int i = 0; i < strlen(str); i++) {
1087+
for (size_t i = 0; i < strlen(str); i++) {
10881088
if (str[i] != '"')
10891089
*c++ = str[i];
10901090
else {
@@ -1387,7 +1387,7 @@ cmd_close(ProfWin* window, const char* const command, gchar** args)
13871387
gboolean is_num = TRUE;
13881388
int index = 0;
13891389
if (args[0] != NULL) {
1390-
for (int i = 0; i < strlen(args[0]); i++) {
1390+
for (size_t i = 0; i < strlen(args[0]); i++) {
13911391
if (!isdigit((int)args[0][i])) {
13921392
is_num = FALSE;
13931393
break;
@@ -1474,7 +1474,7 @@ gboolean
14741474
cmd_win(ProfWin* window, const char* const command, gchar** args)
14751475
{
14761476
gboolean is_num = TRUE;
1477-
for (int i = 0; i < strlen(args[0]); i++) {
1477+
for (size_t i = 0; i < strlen(args[0]); i++) {
14781478
if (!isdigit((int)args[0][i])) {
14791479
is_num = FALSE;
14801480
break;
@@ -9983,7 +9983,7 @@ cmd_vcard_set(ProfWin* window, const char* const command, gchar** args)
99839983
}
99849984

99859985
gboolean is_num = TRUE;
9986-
for (int i = 0; i < strlen(key); i++) {
9986+
for (size_t i = 0; i < strlen(key); i++) {
99879987
if (!isdigit((int)key[i])) {
99889988
is_num = FALSE;
99899989
break;

src/config/color.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ color_distance(const struct color_def* a, const struct color_def* b)
344344
static int
345345
find_closest_col(int h, int s, int l)
346346
{
347-
struct color_def a = { h, s, l };
347+
struct color_def a = { h, s, l, NULL };
348348
int min = 0;
349349
int dmin = color_distance(&a, &color_names[0]);
350350

@@ -369,7 +369,7 @@ find_col(const char* col_name, int n)
369369
* blue.
370370
*/
371371

372-
if (n >= sizeof(name)) {
372+
if (n >= (int)sizeof(name)) {
373373
/* truncate */
374374
log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name));
375375
n = sizeof(name) - 1;

src/config/preferences.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ _prefs_load(void)
253253
gsize len = 0;
254254
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
255255

256-
for (int i = 0; i < len; i++) {
256+
for (gsize i = 0; i < len; i++) {
257257
autocomplete_add(room_trigger_ac, triggers[i]);
258258
}
259259
}
@@ -418,7 +418,7 @@ prefs_message_get_triggers(const char* const message)
418418
gsize len = 0;
419419
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
420420

421-
for (int i = 0; i < len; i++) {
421+
for (gsize i = 0; i < len; i++) {
422422
auto_gchar gchar* trigger_lower = g_utf8_strdown(triggers[i], -1);
423423
if (g_strrstr(message_lower, trigger_lower)) {
424424
result = g_list_append(result, strdup(triggers[i]));
@@ -1392,7 +1392,7 @@ prefs_get_room_notify_triggers(void)
13921392
gsize len = 0;
13931393
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
13941394

1395-
for (int i = 0; i < len; i++) {
1395+
for (gsize i = 0; i < len; i++) {
13961396
result = g_list_append(result, strdup(triggers[i]));
13971397
}
13981398

@@ -1739,7 +1739,7 @@ prefs_get_aliases(void)
17391739
gsize len;
17401740
auto_gcharv gchar** keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL);
17411741

1742-
for (int i = 0; i < len; i++) {
1742+
for (gsize i = 0; i < len; i++) {
17431743
char* name = keys[i];
17441744
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
17451745

src/config/tlscerts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ tlscerts_init(void)
8282
gsize len = 0;
8383
auto_gcharv gchar** groups = g_key_file_get_groups(tlscerts, &len);
8484

85-
for (int i = 0; i < g_strv_length(groups); i++) {
85+
for (guint i = 0; i < g_strv_length(groups); i++) {
8686
autocomplete_add(certs_ac, groups[i]);
8787
}
8888

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ main(int argc, char** argv)
7878

7979
GOptionEntry entries[] = {
8080
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
81-
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup" },
81+
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup", NULL },
8282
{ "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO, WARN (default), ERROR", "LEVEL" },
8383
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Use an alternative configuration file", NULL },
8484
{ "logfile", 'f', 0, G_OPTION_ARG_STRING, &log_file, "Specify log file", NULL },

src/omemo/omemo.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
773773
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
774774
// Yourself as recipients in case of MUC
775775
if (equals_our_barejid(recipients_iter->data)) {
776-
if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
776+
if ((uint32_t)GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
777777
log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data));
778778
continue;
779779
}
@@ -832,7 +832,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
832832
log_debug("[OMEMO][SEND][Sender] Sending to device %d for %s ", address.device_id, address.name);
833833
// Don't encrypt for this device (according to
834834
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
835-
if (address.device_id == omemo_ctx.device_id) {
835+
if ((uint32_t)address.device_id == omemo_ctx.device_id) {
836836
continue;
837837
}
838838

@@ -1030,7 +1030,7 @@ omemo_format_fingerprint(const char* const fingerprint)
10301030
{
10311031
char* output = malloc(strlen(fingerprint) + strlen(fingerprint) / 8);
10321032

1033-
int i, j;
1033+
size_t i, j;
10341034
for (i = 0, j = 0; i < strlen(fingerprint); i++) {
10351035
if (i > 0 && i % 8 == 0) {
10361036
output[j++] = '-';
@@ -1117,7 +1117,7 @@ omemo_is_trusted_identity(const char* const jid, const char* const fingerprint)
11171117
static char*
11181118
_omemo_fingerprint(ec_public_key* identity, gboolean formatted)
11191119
{
1120-
int i;
1120+
size_t i;
11211121
signal_buffer* identity_public_key;
11221122

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

1164-
int i;
1165-
int j;
1164+
size_t i;
1165+
size_t j;
11661166
for (i = 0, j = 0; i < strlen(fingerprint);) {
11671167
if (!g_ascii_isxdigit(fingerprint[i])) {
11681168
i++;
@@ -1724,7 +1724,7 @@ _bytes_from_hex(const char* hex, size_t hex_size,
17241724

17251725
memset(bytes, 0, bytes_size);
17261726

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

src/pgp/gpg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ _p_gpg_free_pubkeyid(ProfPGPPubKeyId* pubkeyid)
8787
free(pubkeyid);
8888
}
8989

90-
static gpgme_error_t*
90+
static gpgme_error_t
9191
_p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_info, int prev_was_bad, int fd)
9292
{
9393
if (passphrase) {
@@ -109,7 +109,7 @@ _p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_in
109109
gpgme_io_write(fd, passphrase_attempt, strlen(passphrase_attempt));
110110
}
111111

112-
return 0;
112+
return GPG_ERR_NO_ERROR;
113113
}
114114

115115
static void
@@ -180,7 +180,7 @@ p_gpg_on_connect(const char* const barejid)
180180
return;
181181
}
182182

183-
for (int i = 0; i < len; i++) {
183+
for (gsize i = 0; i < len; i++) {
184184
GError* gerr = NULL;
185185
gchar* jid = jids[i];
186186
auto_gchar gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);

0 commit comments

Comments
 (0)