]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed timespec_get() initialization bug on some targets 1581/head
authorYann Collet <cyan@fb.com>
Thu, 11 Apr 2019 20:46:30 +0000 (13:46 -0700)
committerYann Collet <cyan@fb.com>
Thu, 11 Apr 2019 20:46:30 +0000 (13:46 -0700)
not sure why, but msan fires an "unitialized variable" error
when time gets properly initialized by timespec_get().
Maybe in some cases, not all bytes of the structure are initialized ?
Or maybe msan fails to detect the initialization ?

Anyway, pre-initializing the variable before passing it to timespec_get() works.

programs/timefn.c

index 21f2a9618b49015feb060b1b62d95e1eeeecc271..096e1910bf4bc0c8122ec4a25d66c5992298101d 100644 (file)
@@ -91,8 +91,10 @@ PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
 
 UTIL_time_t UTIL_getTime(void)
 {
-    UTIL_time_t time;
-    if (timespec_get(&time, TIME_UTC) == 0) {
+    /* time must be initialized, othersize it may fail msan test.
+     * No good reason, likely a limitation of timespec_get() for some target */
+    UTIL_time_t time = UTIL_TIME_INITIALIZER;
+    if (timespec_get(&time, TIME_UTC) != TIME_UTC) {
         perror("timefn::timespec_get");
         abort();
     }