mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-03 12:19:20 +02:00
Prefer g_get_real_time() over time(NULL)
Especially when casting the result to guint64, since this might not be always correct. See also issue #1402.
This commit is contained in:
@@ -658,7 +658,7 @@ keyring_generate_entry (const gchar *cookie_context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_contents = g_string_new (NULL);
|
new_contents = g_string_new (NULL);
|
||||||
now = (guint64) time (NULL);
|
now = g_get_real_time ();
|
||||||
changed_file = FALSE;
|
changed_file = FALSE;
|
||||||
|
|
||||||
max_line_id = 0;
|
max_line_id = 0;
|
||||||
@@ -672,7 +672,7 @@ keyring_generate_entry (const gchar *cookie_context,
|
|||||||
gchar **tokens;
|
gchar **tokens;
|
||||||
gchar *endp;
|
gchar *endp;
|
||||||
gint line_id;
|
gint line_id;
|
||||||
guint64 line_when;
|
gint64 line_when;
|
||||||
gboolean keep_entry;
|
gboolean keep_entry;
|
||||||
|
|
||||||
if (line[0] == '\0')
|
if (line[0] == '\0')
|
||||||
@@ -745,7 +745,7 @@ keyring_generate_entry (const gchar *cookie_context,
|
|||||||
if (line_when - now > 24*60*60)
|
if (line_when - now > 24*60*60)
|
||||||
{
|
{
|
||||||
keep_entry = FALSE;
|
keep_entry = FALSE;
|
||||||
_log ("Deleted SHA1 cookie from %" G_GUINT64_FORMAT " seconds in the future", line_when - now);
|
_log ("Deleted SHA1 cookie from %" G_GINT64_FORMAT " seconds in the future", line_when - now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -764,7 +764,7 @@ keyring_generate_entry (const gchar *cookie_context,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_string_append_printf (new_contents,
|
g_string_append_printf (new_contents,
|
||||||
"%d %" G_GUINT64_FORMAT " %s\n",
|
"%d %" G_GINT64_FORMAT " %s\n",
|
||||||
line_id,
|
line_id,
|
||||||
line_when,
|
line_when,
|
||||||
tokens[2]);
|
tokens[2]);
|
||||||
@@ -807,9 +807,9 @@ keyring_generate_entry (const gchar *cookie_context,
|
|||||||
g_free (raw_cookie);
|
g_free (raw_cookie);
|
||||||
|
|
||||||
g_string_append_printf (new_contents,
|
g_string_append_printf (new_contents,
|
||||||
"%d %" G_GUINT64_FORMAT " %s\n",
|
"%d %" G_GINT64_FORMAT " %s\n",
|
||||||
*out_id,
|
*out_id,
|
||||||
(guint64) time (NULL),
|
g_get_real_time (),
|
||||||
*out_cookie);
|
*out_cookie);
|
||||||
changed_file = TRUE;
|
changed_file = TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -2138,7 +2138,7 @@ g_local_file_trash (GFile *file,
|
|||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm now;
|
struct tm now;
|
||||||
t = time (NULL);
|
t = g_get_real_time ();
|
||||||
localtime_r (&t, &now);
|
localtime_r (&t, &now);
|
||||||
delete_time[0] = 0;
|
delete_time[0] = 0;
|
||||||
strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
|
strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
|
||||||
|
@@ -273,7 +273,8 @@ main (int argc, char *argv[])
|
|||||||
"Negotiated capabilities: unix-fd-passing=%d\n",
|
"Negotiated capabilities: unix-fd-passing=%d\n",
|
||||||
g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
||||||
|
|
||||||
greeting = g_strdup_printf ("Hey, it's %" G_GUINT64_FORMAT " already!", (guint64) time (NULL));
|
greeting = g_strdup_printf ("Hey, it's %" G_GINT64_FORMAT " already!",
|
||||||
|
g_get_real_time ());
|
||||||
value = g_dbus_connection_call_sync (connection,
|
value = g_dbus_connection_call_sync (connection,
|
||||||
NULL, /* bus_name */
|
NULL, /* bus_name */
|
||||||
"/org/gtk/GDBus/TestObject",
|
"/org/gtk/GDBus/TestObject",
|
||||||
|
@@ -79,7 +79,7 @@ on_name_appeared (GDBusConnection *connection,
|
|||||||
gssize len;
|
gssize len;
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
now = time (NULL);
|
now = g_get_real_time ();
|
||||||
strftime (now_buf,
|
strftime (now_buf,
|
||||||
sizeof now_buf,
|
sizeof now_buf,
|
||||||
"%Y-%m-%d %H:%M:%S",
|
"%Y-%m-%d %H:%M:%S",
|
||||||
|
Reference in New Issue
Block a user