Initialize global and non-static variables
[fio.git] / gettime-thread.c
index da409042f2ec6eb7344b6f943dad0eba84c54cd1..3d49034a72792fc6cfc590ed545c522de4f7a999 100644 (file)
@@ -6,7 +6,7 @@
 #include "fio.h"
 #include "smalloc.h"
 
-struct timeval *fio_tv;
+struct timeval *fio_tv = NULL;
 int fio_gtod_offload = 0;
 int fio_gtod_cpu = -1;
 static pthread_t gtod_thread;
@@ -14,12 +14,14 @@ static pthread_t gtod_thread;
 void fio_gtod_init(void)
 {
        fio_tv = smalloc(sizeof(struct timeval));
-       assert(fio_tv);
+       if (!fio_tv)
+               log_err("fio: smalloc pool exhausted\n");
 }
 
 static void fio_gtod_update(void)
 {
-       gettimeofday(fio_tv, NULL);
+       if (fio_tv)
+               gettimeofday(fio_tv, NULL);
 }
 
 static void *gtod_thread_main(void *data)