pidgin/pidgin

Fix time_t string formatting.

2020-12-20, Elliott Sales de Andrade
52feb9438df4
Parents 2453bef0abe7
Children 865dddf7ccb8
Fix time_t string formatting.

* Use monotonic time for the last IRC ping.
Not sure why I didn't change this one before.
* Fix formats for printing of `time_t`.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/299/
--- a/libpurple/protocols/irc/cmds.c Sun Dec 20 00:51:00 2020 -0600
+++ b/libpurple/protocols/irc/cmds.c Sun Dec 20 05:02:37 2020 -0600
@@ -425,7 +425,7 @@
buf = irc_format(irc, "v:", "PING", stamp);
g_free(stamp);
} else {
- stamp = g_strdup_printf("%lu", time(NULL));
+ stamp = g_strdup_printf("%" G_GUINT64_FORMAT, g_get_monotonic_time());
buf = irc_format(irc, "vv", "PING", stamp);
g_free(stamp);
}
--- a/libpurple/protocols/jabber/iq.c Sun Dec 20 00:51:00 2020 -0600
+++ b/libpurple/protocols/jabber/iq.c Sun Dec 20 05:02:37 2020 -0600
@@ -168,7 +168,9 @@
query = purple_xmlnode_get_child(iq->node, "query");
- idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
+ idle_time =
+ g_strdup_printf("%" G_GINT64_FORMAT,
+ (gint64)(js->idle ? time(NULL) - js->idle : 0));
purple_xmlnode_set_attrib(query, "seconds", idle_time);
g_free(idle_time);
--- a/libpurple/savedstatuses.c Sun Dec 20 00:51:00 2020 -0600
+++ b/libpurple/savedstatuses.c Sun Dec 20 05:02:37 2020 -0600
@@ -276,10 +276,11 @@
purple_xmlnode_set_attrib(node, "transient", "true");
}
- g_snprintf(buf, sizeof(buf), "%lu", status->creation_time);
+ g_snprintf(buf, sizeof(buf), "%" G_GINT64_FORMAT,
+ (gint64)status->creation_time);
purple_xmlnode_set_attrib(node, "created", buf);
- g_snprintf(buf, sizeof(buf), "%lu", status->lastused);
+ g_snprintf(buf, sizeof(buf), "%" G_GINT64_FORMAT, (gint64)status->lastused);
purple_xmlnode_set_attrib(node, "lastused", buf);
g_snprintf(buf, sizeof(buf), "%u", status->usage_count);
@@ -471,11 +472,12 @@
/* Read the creation time */
attrib = purple_xmlnode_get_attrib(status, "created");
- set_creation_time(ret, (attrib != NULL ? atol(attrib) : 0));
+ set_creation_time(ret,
+ (attrib != NULL ? g_ascii_strtoll(attrib, NULL, 10) : 0));
/* Read the last used time */
attrib = purple_xmlnode_get_attrib(status, "lastused");
- ret->lastused = (attrib != NULL ? atol(attrib) : 0);
+ ret->lastused = (attrib != NULL ? g_ascii_strtoll(attrib, NULL, 10) : 0);
/* Read the usage count */
attrib = purple_xmlnode_get_attrib(status, "usage_count");