mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 23:28:08 +02:00
cli: avoid non-thread-safe localtime() function in nmcli
Static analysis tools flag the use of localtime() because it is not thread safe. Of course, that was no problem here, but avoiding the warning is simple. Also, if we allocate 128 bytes, let strftime use it.
This commit is contained in:
parent
53b2297701
commit
6f0dadabd7
1 changed files with 3 additions and 1 deletions
|
|
@ -541,6 +541,8 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
if (info->info_type == NMC_GENERIC_INFO_TYPE_CON_SHOW_TIMESTAMP)
|
||||
return (*out_to_free = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp));
|
||||
else {
|
||||
struct tm localtime_result;
|
||||
|
||||
if (!timestamp) {
|
||||
if (get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
|
||||
return _("never");
|
||||
|
|
@ -548,7 +550,7 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
}
|
||||
timestamp_real = timestamp;
|
||||
s_mut = g_malloc0 (128);
|
||||
strftime (s_mut, 64, "%c", localtime (×tamp_real));
|
||||
strftime (s_mut, 127, "%c", localtime_r (×tamp_real, &localtime_result));
|
||||
return (*out_to_free = s_mut);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue