From 80319b30cd6cf665732f1c034987edcd96fc67ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Sat, 19 Jan 2019 15:14:44 +0100 Subject: [PATCH] Fix printf format warnings on certain platforms --- src/twc-chat.c | 5 +++-- src/twc-commands.c | 11 ++++++----- src/twc-profile.c | 6 ++++-- src/twc-tfer.c | 14 +++++++------- src/twc-tox-callbacks.c | 8 ++++---- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/twc-chat.c b/src/twc-chat.c index 1f99e34..97921b8 100644 --- a/src/twc-chat.c +++ b/src/twc-chat.c @@ -17,6 +17,7 @@ * along with Tox-WeeChat. If not, see . */ +#include #include #include @@ -126,7 +127,7 @@ struct t_twc_chat * twc_chat_new_group(struct t_twc_profile *profile, int32_t group_number) { char buffer_name[32]; - sprintf(buffer_name, "group_chat_%d", group_number); + sprintf(buffer_name, "group_chat_%" PRId32, group_number); struct t_twc_chat *chat = twc_chat_new(profile, buffer_name); if (chat) @@ -171,7 +172,7 @@ twc_chat_refresh(const struct t_twc_chat *chat) tox_conference_get_title(chat->profile->tox, chat->group_number, (uint8_t *)group_name, &err); if (!rc) - sprintf(group_name, "Group Chat %d", chat->group_number); + sprintf(group_name, "Group Chat %" PRId32, chat->group_number); name = title = strdup((char *)group_name); } diff --git a/src/twc-commands.c b/src/twc-commands.c index 36b8536..a3a0618 100644 --- a/src/twc-commands.c +++ b/src/twc-commands.c @@ -17,6 +17,7 @@ * along with Tox-WeeChat. If not, see . */ +#include #include #include #include @@ -275,7 +276,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer, NULL) != TOX_CONNECTION_NONE) ? "chat_nick" : "chat_nick_offline"; - weechat_printf(profile->buffer, "%s[%d] %s%s [%s]%s %s", + weechat_printf(profile->buffer, "%s[%" PRIu32 "] %s%s [%s]%s %s", weechat_prefix("network"), friend_number, weechat_color(online_color), name, hex_address, weechat_color("reset"), status); @@ -455,7 +456,7 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer, } } - weechat_printf(profile->buffer, "%s%s %d friend requests.", + weechat_printf(profile->buffer, "%s%s %zu friend requests.", weechat_prefix("network"), accept ? "Accepted" : "Declined", count); @@ -520,8 +521,8 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer, hex_address); weechat_printf(profile->buffer, - "%s[%d] Address: %s\n" - "[%d] Message: %s", + "%s[%zu] Address: %s\n" + "[%zu] Message: %s", weechat_prefix("network"), index, hex_address, index, item->friend_request->message); } @@ -608,7 +609,7 @@ twc_cmd_group(const void *pointer, void *data, struct t_gui_buffer *buffer, { char *friend_name = twc_get_name_nt( profile->tox, item->group_chat_invite->friend_number); - weechat_printf(profile->buffer, "%s[%d] From: %s", + weechat_printf(profile->buffer, "%s[%zu] From: %s", weechat_prefix("network"), index, friend_name); free(friend_name); } diff --git a/src/twc-profile.c b/src/twc-profile.c index e4e83ab..7936794 100644 --- a/src/twc-profile.c +++ b/src/twc-profile.c @@ -17,6 +17,7 @@ * along with Tox-WeeChat. If not, see . */ +#include #include #include #include @@ -247,7 +248,8 @@ twc_tox_new_print_error(struct t_twc_profile *profile, break; case TOX_ERR_NEW_PROXY_BAD_PORT: weechat_printf(profile->buffer, - "%scould not load Tox (invalid proxy port: \"%d\")", + "%scould not load Tox (invalid proxy port: \"%" + PRIu16 "\")", weechat_prefix("error"), options->proxy_port); break; case TOX_ERR_NEW_PROXY_NOT_FOUND: @@ -316,7 +318,7 @@ twc_profile_load(struct t_twc_profile *profile) /* print a proxy message */ if (options.proxy_type != TOX_PROXY_TYPE_NONE) { - weechat_printf(profile->buffer, "%susing %s proxy %s:%d", + weechat_printf(profile->buffer, "%susing %s proxy %s:%" PRIu16, weechat_prefix("network"), options.proxy_type == TOX_PROXY_TYPE_HTTP ? "HTTP" diff --git a/src/twc-tfer.c b/src/twc-tfer.c index 36205ef..81b467a 100644 --- a/src/twc-tfer.c +++ b/src/twc-tfer.c @@ -49,15 +49,15 @@ { \ case 1: \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \ - "request number %ld has been " #past, n); \ + "request number %zu has been " #past, n); \ case 0: \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \ - "request number %ld cannot be " #past " because " \ + "request number %zu cannot be " #past " because " \ "of tox internal issues", \ n); \ case -1: \ TWC_TFER_UPDATE_STATUS_AND_RETURN( \ - "request number %ld cannot be " #past, n); \ + "request number %zu cannot be " #past, n); \ } \ } while (0) @@ -220,7 +220,7 @@ twc_tfer_file_unique_name(const char *original) i = number; do { - snprintf(name, FILENAME_MAX, "%s(%i)%s", body, i, extension); + snprintf(name, FILENAME_MAX, "%s(%d)%s", body, i, extension); i++; } while (twc_tfer_file_check(name)); @@ -449,14 +449,14 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file) const char *status = twc_tfer_file_get_status_str(file); if (file->size == UINT64_MAX) { - weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s [STREAM]", index, + weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s [STREAM]", index, type, file->nickname, file->filename); } else { float display_size = twc_tfer_cut_size(file->size); const char *size_suffix = twc_tfer_size_suffix(file->size); - weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s %i (%.2f%s)", index, + weechat_printf_y(tfer->buffer, line, "%zu) %s %s: %s %zu (%.2f%s)", index, type, file->nickname, file->filename, file->size, display_size, size_suffix); } @@ -486,7 +486,7 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file) float display_pos = twc_tfer_cut_size(file->position); const char *pos_suffix = twc_tfer_size_suffix(file->position); - weechat_printf_y(tfer->buffer, line + 1, "%s%i%% [%s] %.2f%s %.2f%s", + weechat_printf_y(tfer->buffer, line + 1, "%s%d%% [%s] %.2f%s %.2f%s", placeholder, percents, progress_bar, display_pos, pos_suffix, display_speed, speed_suffix); } diff --git a/src/twc-tox-callbacks.c b/src/twc-tox-callbacks.c index 3db5e14..6117fb6 100644 --- a/src/twc-tox-callbacks.c +++ b/src/twc-tox-callbacks.c @@ -335,7 +335,7 @@ twc_group_invite_callback(Tox *tox, uint32_t friend_number, char *friend_name = twc_get_name_nt(profile->tox, friend_number); struct t_twc_chat *friend_chat = twc_chat_search_friend(profile, friend_number, false); - int64_t rc; + int rc; char *tags; char *type_str; @@ -602,7 +602,7 @@ twc_file_recv_control_callback(Tox *tox, uint32_t friend_number, if (!file) { weechat_printf(profile->tfer->buffer, - "%sthere is no file with number %i in queue", + "%sthere is no file with number %" PRIu32 " in queue", weechat_prefix("error"), file_number); return; } @@ -644,7 +644,7 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number, if (!file) { weechat_printf(profile->tfer->buffer, - "%sthere is no file with number %i in queue", + "%sthere is no file with number %" PRIu32 " in queue", weechat_prefix("error"), file_number); return; } @@ -744,7 +744,7 @@ twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number, if (!file) { weechat_printf(profile->tfer->buffer, - "%sthere is no file with number %i in queue", + "%sthere is no file with number %" PRIu32 " in queue", weechat_prefix("error"), file_number); return; }