[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH for-4.6 01/13] libxl: use thread-safe localtime_t and handle NULL



Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl_x86.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 8cd15ca..bac0b8f 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -306,10 +306,16 @@ int libxl__arch_domain_create(libxl__gc *gc, 
libxl_domain_config *d_config,
     rtc_timeoffset = d_config->b_info.rtc_timeoffset;
     if (libxl_defbool_val(d_config->b_info.localtime)) {
         time_t t;
-        struct tm *tm;
+        struct tm *tm, result;
 
         t = time(NULL);
-        tm = localtime(&t);
+        tm = localtime_r(&t, &result);
+
+        if (!tm) {
+            LOGE(ERROR, "Failed to call localtime_r");
+            ret = ERROR_FAIL;
+            goto out;
+        }
 
         rtc_timeoffset += tm->tm_gmtoff;
     }
@@ -335,6 +341,7 @@ int libxl__arch_domain_create(libxl__gc *gc, 
libxl_domain_config *d_config,
         }
     }
 
+out:
     return ret;
 }
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.