Fix printf format warnings on certain platforms

This commit is contained in:
Håvard Pettersson 2019-01-19 15:14:44 +01:00
parent 40894df778
commit 80319b30cd
5 changed files with 24 additions and 20 deletions

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
@ -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);
}

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
@ -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);
}

View File

@ -17,6 +17,7 @@
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
@ -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"

View File

@ -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);
}

View File

@ -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;
}