Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 80319b3

Browse files
committed
Fix printf format warnings on certain platforms
1 parent 40894df commit 80319b3

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

src/twc-chat.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20+
#include <inttypes.h>
2021
#include <stdio.h>
2122
#include <string.h>
2223

@@ -126,7 +127,7 @@ struct t_twc_chat *
126127
twc_chat_new_group(struct t_twc_profile *profile, int32_t group_number)
127128
{
128129
char buffer_name[32];
129-
sprintf(buffer_name, "group_chat_%d", group_number);
130+
sprintf(buffer_name, "group_chat_%" PRId32, group_number);
130131

131132
struct t_twc_chat *chat = twc_chat_new(profile, buffer_name);
132133
if (chat)
@@ -171,7 +172,7 @@ twc_chat_refresh(const struct t_twc_chat *chat)
171172
tox_conference_get_title(chat->profile->tox, chat->group_number,
172173
(uint8_t *)group_name, &err);
173174
if (!rc)
174-
sprintf(group_name, "Group Chat %d", chat->group_number);
175+
sprintf(group_name, "Group Chat %" PRId32, chat->group_number);
175176

176177
name = title = strdup((char *)group_name);
177178
}

src/twc-commands.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20+
#include <inttypes.h>
2021
#include <stdio.h>
2122
#include <string.h>
2223
#include <sys/stat.h>
@@ -275,7 +276,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
275276
NULL) != TOX_CONNECTION_NONE)
276277
? "chat_nick"
277278
: "chat_nick_offline";
278-
weechat_printf(profile->buffer, "%s[%d] %s%s [%s]%s %s",
279+
weechat_printf(profile->buffer, "%s[%" PRIu32 "] %s%s [%s]%s %s",
279280
weechat_prefix("network"), friend_number,
280281
weechat_color(online_color), name, hex_address,
281282
weechat_color("reset"), status);
@@ -455,7 +456,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
455456
}
456457
}
457458

458-
weechat_printf(profile->buffer, "%s%s %d friend requests.",
459+
weechat_printf(profile->buffer, "%s%s %zu friend requests.",
459460
weechat_prefix("network"),
460461
accept ? "Accepted" : "Declined", count);
461462

@@ -520,8 +521,8 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
520521
hex_address);
521522

522523
weechat_printf(profile->buffer,
523-
"%s[%d] Address: %s\n"
524-
"[%d] Message: %s",
524+
"%s[%zu] Address: %s\n"
525+
"[%zu] Message: %s",
525526
weechat_prefix("network"), index, hex_address, index,
526527
item->friend_request->message);
527528
}
@@ -608,7 +609,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer,
608609
{
609610
char *friend_name = twc_get_name_nt(
610611
profile->tox, item->group_chat_invite->friend_number);
611-
weechat_printf(profile->buffer, "%s[%d] From: %s",
612+
weechat_printf(profile->buffer, "%s[%zu] From: %s",
612613
weechat_prefix("network"), index, friend_name);
613614
free(friend_name);
614615
}

src/twc-profile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20+
#include <inttypes.h>
2021
#include <pwd.h>
2122
#include <stdio.h>
2223
#include <string.h>
@@ -247,7 +248,8 @@ twc_tox_new_print_error(struct t_twc_profile *profile,
247248
break;
248249
case TOX_ERR_NEW_PROXY_BAD_PORT:
249250
weechat_printf(profile->buffer,
250-
"%scould not load Tox (invalid proxy port: \"%d\")",
251+
"%scould not load Tox (invalid proxy port: \"%"
252+
PRIu16 "\")",
251253
weechat_prefix("error"), options->proxy_port);
252254
break;
253255
case TOX_ERR_NEW_PROXY_NOT_FOUND:
@@ -316,7 +318,7 @@ twc_profile_load(struct t_twc_profile *profile)
316318
/* print a proxy message */
317319
if (options.proxy_type != TOX_PROXY_TYPE_NONE)
318320
{
319-
weechat_printf(profile->buffer, "%susing %s proxy %s:%d",
321+
weechat_printf(profile->buffer, "%susing %s proxy %s:%" PRIu16,
320322
weechat_prefix("network"),
321323
options.proxy_type == TOX_PROXY_TYPE_HTTP
322324
? "HTTP"

src/twc-tfer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
{ \
5050
case 1: \
5151
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
52-
"request number %ld has been " #past, n); \
52+
"request number %zu has been " #past, n); \
5353
case 0: \
5454
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
55-
"request number %ld cannot be " #past " because " \
55+
"request number %zu cannot be " #past " because " \
5656
"of tox internal issues", \
5757
n); \
5858
case -1: \
5959
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
60-
"request number %ld cannot be " #past, n); \
60+
"request number %zu cannot be " #past, n); \
6161
} \
6262
} while (0)
6363

@@ -220,7 +220,7 @@ twc_tfer_file_unique_name(const char *original)
220220
i = number;
221221
do
222222
{
223-
snprintf(name, FILENAME_MAX, "%s(%i)%s", body, i, extension);
223+
snprintf(name, FILENAME_MAX, "%s(%d)%s", body, i, extension);
224224
i++;
225225
} while (twc_tfer_file_check(name));
226226

@@ -449,14 +449,14 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
449449
const char *status = twc_tfer_file_get_status_str(file);
450450
if (file->size == UINT64_MAX)
451451
{
452-
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s [STREAM]", index,
452+
weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s [STREAM]", index,
453453
type, file->nickname, file->filename);
454454
}
455455
else
456456
{
457457
float display_size = twc_tfer_cut_size(file->size);
458458
const char *size_suffix = twc_tfer_size_suffix(file->size);
459-
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s %i (%.2f%s)", index,
459+
weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s %zu (%.2f%s)", index,
460460
type, file->nickname, file->filename, file->size,
461461
display_size, size_suffix);
462462
}
@@ -486,7 +486,7 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
486486
float display_pos = twc_tfer_cut_size(file->position);
487487
const char *pos_suffix = twc_tfer_size_suffix(file->position);
488488

489-
weechat_printf_y(tfer->buffer, line + 1, "%s%i%% [%s] %.2f%s %.2f%s",
489+
weechat_printf_y(tfer->buffer, line + 1, "%s%d%% [%s] %.2f%s %.2f%s",
490490
placeholder, percents, progress_bar, display_pos,
491491
pos_suffix, display_speed, speed_suffix);
492492
}

src/twc-tox-callbacks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ twc_group_invite_callback(Tox *tox, uint32_t friend_number,
335335
char *friend_name = twc_get_name_nt(profile->tox, friend_number);
336336
struct t_twc_chat *friend_chat =
337337
twc_chat_search_friend(profile, friend_number, false);
338-
int64_t rc;
338+
int rc;
339339
char *tags;
340340

341341
char *type_str;
@@ -602,7 +602,7 @@ twc_file_recv_control_callback(Tox *tox, uint32_t friend_number,
602602
if (!file)
603603
{
604604
weechat_printf(profile->tfer->buffer,
605-
"%sthere is no file with number %i in queue",
605+
"%sthere is no file with number %" PRIu32 " in queue",
606606
weechat_prefix("error"), file_number);
607607
return;
608608
}
@@ -644,7 +644,7 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number,
644644
if (!file)
645645
{
646646
weechat_printf(profile->tfer->buffer,
647-
"%sthere is no file with number %i in queue",
647+
"%sthere is no file with number %" PRIu32 " in queue",
648648
weechat_prefix("error"), file_number);
649649
return;
650650
}
@@ -744,7 +744,7 @@ twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number,
744744
if (!file)
745745
{
746746
weechat_printf(profile->tfer->buffer,
747-
"%sthere is no file with number %i in queue",
747+
"%sthere is no file with number %" PRIu32 " in queue",
748748
weechat_prefix("error"), file_number);
749749
return;
750750
}

0 commit comments

Comments
 (0)