summaryrefslogtreecommitdiff
path: root/examples/C
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-05-06 22:33:52 +0200
committerThomas Haller <thaller@redhat.com>2020-05-07 13:58:13 +0200
commit5c08981356a1038f49050d748f09d859bf471810 (patch)
treee56cb4833180f5b864a846d4fb137479e5ff55b2 /examples/C
parent41a7a262591e25985431a70e8b597ce85d10ebd6 (diff)
downloadNetworkManager-5c08981356a1038f49050d748f09d859bf471810.tar.gz
examples: avoid non-thread-safe localtime() function example
Just to silence the warning on lgtm.com.
Diffstat (limited to 'examples/C')
-rw-r--r--examples/C/glib/list-connections-libnm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/C/glib/list-connections-libnm.c b/examples/C/glib/list-connections-libnm.c
index 77d5dfb729..7bed0c014e 100644
--- a/examples/C/glib/list-connections-libnm.c
+++ b/examples/C/glib/list-connections-libnm.c
@@ -30,10 +30,15 @@ show_connection (NMConnection *connection)
s_con = nm_connection_get_setting_connection (connection);
if (s_con) {
+ struct tm localtime_data;
+
/* Get various info from NMSettingConnection and show it */
timestamp = nm_setting_connection_get_timestamp (s_con);
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
- strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) &timestamp));
+ strftime (timestamp_real_str,
+ sizeof (timestamp_real_str),
+ "%c",
+ localtime_r ((time_t *) &timestamp, &localtime_data));
val1 = nm_setting_connection_get_id (s_con);
val2 = nm_setting_connection_get_uuid (s_con);