sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
290 stars 27 forks source link

Format string warning #133

Closed nwf closed 6 years ago

nwf commented 6 years ago

While compiling, I got:

discord-websockets.c: In function ‘discord_ws_set_status’: discord-websockets.c:349:57: warning: format ‘%tu’ expects argument of type ‘unsigned ptrdiff_t’, but argument 4 has type ‘long int’ [-Wformat=]
     g_string_printf(buf, "{\"op\":%d,\"d\":{\"since\":%tu,\"game\": \"name\":\"%s\",\"type\":0},\"afk\":true,\"status\":\"idle\"}}", OPCODE_STATUS_UPDATE, time(NULL)*1000, msg);
                                                         ^

May I suggest

--- a/src/discord-websockets.c
+++ b/src/discord-websockets.c
@@ -346,7 +346,7 @@ void discord_ws_set_status(discord_data *dd, gboolean idle, gchar *message)
   }

   if (idle == TRUE) {
-    g_string_printf(buf, "{\"op\":%d,\"d\":{\"since\":%tu,\"game\":{\"name\":\"%s\",\"type\":0},\"afk\":true,\"status\":\"idle\"}}", OPCODE_STATUS_UPDATE, time(NULL)*1000, msg);
+    g_string_printf(buf, "{\"op\":%d,\"d\":{\"since\":%llu,\"game\":{\"name\":\"%s\",\"type\":0},\"afk\":true,\"status\":\"idle\"}}", OPCODE_STATUS_UPDATE, ((long long)time(NULL))*1000, msg);
   } else if (message != NULL) {
     g_string_printf(buf, "{\"op\":%d,\"d\":{\"since\":null,\"game\":{\"name\":\"%s\",\"type\":0},\"afk\":false,\"status\":\"online\"}}", OPCODE_STATUS_UPDATE, msg);
   } else {
sm00th commented 6 years ago

Ah right, 32 bit arms. Thank you.