From patchwork Wed Mar 26 22:30:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Willmann X-Patchwork-Id: 334130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 37440140076 for ; Thu, 27 Mar 2014 09:44:08 +1100 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WSwNi-0002A5-BY; Wed, 26 Mar 2014 23:33:10 +0100 Received: from isonoe.totalueberwachung.de ([2a01:198:210:100::1]) by ganesha.gnumonks.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1WSwLr-00020H-Rg for openbsc@lists.osmocom.org; Wed, 26 Mar 2014 23:31:17 +0100 Received: from adrastea.totalueberwachung.de (p5099b351.dip0.t-ipconnect.de [80.153.179.81]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by isonoe.totalueberwachung.de (Postfix) with ESMTPSA id 58B0760059; Wed, 26 Mar 2014 23:31:10 +0100 (CET) Received: by adrastea.totalueberwachung.de (Postfix, from userid 1000) id D3672220BC; Wed, 26 Mar 2014 23:31:07 +0100 (CET) From: Daniel Willmann To: OpenBSC Mailing List Subject: [PATCH 4/4] gsm0411_utils: Use portable helper gmtoffset_from_ts helper in gsm340_scts Date: Wed, 26 Mar 2014 23:30:47 +0100 Message-Id: X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1395873047-28229-1-git-send-email-dwillmann@sysmocom.de> References: <1395873047-28229-1-git-send-email-dwillmann@sysmocom.de> In-Reply-To: <64c11ccd40489136537a1d3e804c18e0d66440f4.1395872056.git.daniel@totalueberwachung.de> References: <64c11ccd40489136537a1d3e804c18e0d66440f4.1395872056.git.daniel@totalueberwachung.de> X-Spam-Score: -0.0 (/) Cc: Daniel Willmann X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org Avoid depending on the presence of tm_gmtoff to calculate the gmt offset. --- src/gsm/gsm0411_utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c index c6d68bd..94d48fd 100644 --- a/src/gsm/gsm0411_utils.c +++ b/src/gsm/gsm0411_utils.c @@ -119,7 +119,7 @@ time_t gsm340_scts(uint8_t *scts) struct tm tm; uint8_t yr, tz; int ofs; - time_t timestamp; + time_t timestamp, gmtoffset; memset(&tm, 0x00, sizeof(struct tm)); @@ -151,12 +151,12 @@ time_t gsm340_scts(uint8_t *scts) if (timestamp < 0) return -1; + gmtoffset = gmtoffset_from_ts(timestamp); + /* Take into account timezone offset */ timestamp -= ofs; -#ifdef HAVE_TM_GMTOFF_IN_TM /* Remove an artificial timezone offset, introduced by mktime() */ - timestamp += tm.tm_gmtoff; -#endif + timestamp += gmtoffset; return timestamp; }