Skip to contentSkip to conversation

Fix variation in timestamps caused by timezone differences.

PATCH In review Vagrant Cascadian 3 participants 3 messages Oct 2, 2015 – Oct 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix variation in timestamps caused by timezone differences.

When building with SOURCE_DATE_EPOCH set, avoid use of mktime in default_image.c, which converts the timestamp into localtime. This causes variation based on timezone when building u-boot.img and u-boot-sunxi-with-spl.bin targets.

---

 tools/default_image.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
tools/default_image.c +1 -5
index 18940af..3ed7014 100644
@@ -89,7 +89,6 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 {
 	uint32_t checksum;
 	char *source_date_epoch;
-	struct tm *time_universal;
 	time_t time;
 
 	image_header_t * hdr = (image_header_t *)ptr;
@@ -103,13 +102,10 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 	if (source_date_epoch != NULL) {
 		time = (time_t) strtol(source_date_epoch, NULL, 10);
 
-		time_universal = gmtime(&time);
-		if (time_universal == NULL) {
+		if (gmtime(&time) == NULL) {
 			fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n",
 				__func__);
 			time = 0;
-		} else {
-			time = mktime(time_universal);
 		}
 	} else {
 		time = sbuf->st_mtime;
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 Fix variation in timestamps caused by timezone differences.

Le vendredi 02 octobre 2015 ? 09:11 -0700, Vagrant Cascadian a ?crit :

Quoted 4 lines

When building with SOURCE_DATE_EPOCH set, avoid use of mktime in default_image.c, which converts the timestamp into localtime. This causes variation based on timezone when building u-boot.img and u-boot-sunxi-with-spl.bin targets.

I have tested this with the Cubieboard2_defconfig when setting SOURCE_DATE_EPOCH and changing TZ. This corrects the problem in the way I suggested, so this is:

Thanks!

Quoted 34 lines

---

 tools/default_image.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
tools/default_image.c +0 -1
index 18940af..3ed7014 100644
@@ -89,7 +89,6 @@ static void image_set_header(void *ptr, struct stat
 *sbuf, int ifd,
 {
 	uint32_t checksum;
 	char *source_date_epoch;
-	struct tm *time_universal;
 	time_t time;
 
tools/default_image.c +1 -4
 	image_header_t * hdr = (image_header_t *)ptr;
@@ -103,13 +102,10 @@ static void image_set_header(void *ptr, struct
 stat *sbuf, int ifd,
 	if (source_date_epoch != NULL) {
 		time = (time_t) strtol(source_date_epoch, NULL, 10);
 
-		time_universal = gmtime(&time);
-		if (time_universal == NULL) {
+		if (gmtime(&time) == NULL) {
 			fprintf(stderr, "%s: SOURCE_DATE_EPOCH is
 not valid\n",
 				__func__);
 			time = 0;
-		} else {
-			time = mktime(time_universal);
 		}

tools/default_image.c static void image_set_header(void *ptr, struct stat *sbuf, int ifd, · line 111

Quoted 2 lines
tools/default_image.c +0 -0
 	} else {
 		time = sbuf->st_mtime;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151007/f47b6159/attachment.sig>

#2 lore raw
In reply to Vagrant Cascadian
Quoted 8 lines · Vagrant Cascadian

When building with SOURCE_DATE_EPOCH set, avoid use of mktime in default_image.c, which converts the timestamp into localtime. This causes variation based on timezone when building u-boot.img and u-boot-sunxi-with-spl.bin targets.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151012/655deb75/attachment.sig>