Patchwork [4/4] gsm0411_utils: Use portable helper gmtoffset_from_ts helper in gsm340_scts

login
register
mail settings
Submitter Daniel Willmann
Date March 26, 2014, 10:30 p.m.
Message ID <f951222ec3735c3f20bbd9940e06f48fd19012d7.1395872056.git.daniel@totalueberwachung.de>
Download mbox | patch
Permalink /patch/334130/
State New
Headers show

Comments

Daniel Willmann - March 26, 2014, 10:30 p.m.
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(-)

Patch

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;
 }