mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-06 16:21:50 +00:00
log,dhcp: avoid deprecated GTimeVal API and use g_get_real_time()
GTimeVal is deprecated because it's not year 2038 safe (on architectures
where gulong is 32 bit). Don't use it. It's easy to replace.
See-also: e3f88f311f
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1572
This commit is contained in:
parent
2c9faea63c
commit
575e35d1ca
|
@ -25,15 +25,16 @@
|
|||
G_STMT_START \
|
||||
{ \
|
||||
if ((always_enabled) || _NMLOG_ENABLED(level)) { \
|
||||
GTimeVal _tv; \
|
||||
gint64 _tv; \
|
||||
\
|
||||
g_get_current_time(&_tv); \
|
||||
g_print( \
|
||||
"nm-dhcp-helper[%ld] %-7s [%ld.%04ld] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) "\n", \
|
||||
_tv = g_get_real_time(); \
|
||||
g_print("nm-dhcp-helper[%ld] %-7s [%" G_GINT64_FORMAT \
|
||||
".%04d] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) "\n", \
|
||||
(long) getpid(), \
|
||||
nm_utils_syslog_to_str(level), \
|
||||
_tv.tv_sec, \
|
||||
_tv.tv_usec / 100 _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
(_tv / NM_UTILS_USEC_PER_SEC), \
|
||||
((int) ((_tv % NM_UTILS_USEC_PER_SEC) / (((gint64) 100)))) \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
|
|
@ -665,7 +665,7 @@ _nm_log_impl(const char *file,
|
|||
char msg_stack[400];
|
||||
gs_free char *msg_heap = NULL;
|
||||
const char *msg;
|
||||
GTimeVal tv;
|
||||
gint64 tv;
|
||||
int errsv;
|
||||
const NMLogDomain *cur_log_state;
|
||||
NMLogDomain cur_log_state_copy[_LOGL_N_REAL];
|
||||
|
@ -721,11 +721,12 @@ _nm_log_impl(const char *file,
|
|||
* We also do this for all messages (for all levels), because then the logging
|
||||
* lines are formatted and aligned in a consistent way, which aids reading the
|
||||
* logs. */
|
||||
#define MESSAGE_FMT "%s%-7s [%ld.%04ld] %s"
|
||||
#define MESSAGE_FMT "%s%-7s [%" G_GINT64_FORMAT ".%04d] %s"
|
||||
#define MESSAGE_ARG(prefix, tv, msg) \
|
||||
prefix, nm_log_level_desc[level].level_str, (tv).tv_sec, ((tv).tv_usec / 100), (msg)
|
||||
prefix, nm_log_level_desc[level].level_str, ((tv) / NM_UTILS_USEC_PER_SEC), \
|
||||
((int) ((((tv) % NM_UTILS_USEC_PER_SEC)) / ((gint64) 100))), (msg)
|
||||
|
||||
g_get_current_time(&tv);
|
||||
tv = g_get_real_time();
|
||||
|
||||
if (g->debug_stderr)
|
||||
g_printerr(MESSAGE_FMT "\n", MESSAGE_ARG(g->prefix, tv, msg));
|
||||
|
|
Loading…
Reference in a new issue