X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Ferror.c;h=2092fcf235e954af1afe4eb56599a399a9c4b4a9;hb=b3c611c470ddd4602e86d773343619ae8ec7c682;hp=b6d2ff42f687fb7fae99cdeceec2cdce281a42e2;hpb=482f392b771733f96e7929bca985191e20c3d175;p=lttng-tools.git diff --git a/src/common/error.c b/src/common/error.c index b6d2ff42f..2092fcf23 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ const char *log_add_time(void) struct tm tm, *res; struct timespec tp; time_t now; + const int errsv = errno; ret = lttng_clock_gettime(CLOCK_REALTIME, &tp); if (ret < 0) { @@ -65,10 +67,12 @@ const char *log_add_time(void) goto error; } + errno = errsv; return URCU_TLS(error_log_time).str; error: /* Return an empty string on error so logging is not affected. */ + errno = errsv; return ""; }