From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH for-4.6 01/13] libxl: use thread-safe localtime_t and handle NULL Date: Thu, 23 Jul 2015 08:59:02 +0100 Message-ID: <1437638354-14216-2-git-send-email-wei.liu2@citrix.com> References: <1437638354-14216-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIBPV-0004wZ-70 for xen-devel@lists.xenproject.org; Thu, 23 Jul 2015 07:59:21 +0000 In-Reply-To: <1437638354-14216-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Wei Liu , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Signed-off-by: Wei Liu --- 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