linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit system
@ 2024-04-12 20:55 Ben Hutchings
  2024-04-13  2:13 ` Zhihao Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2024-04-12 20:55 UTC (permalink / raw)
  To: linux-mtd; +Cc: Ben Hutchings

fectest.c formats a struct timeval with the assumption that time_t and
suseconds_t are aliases for long, but some 32-bit systems now define
them as long long in order to support timestamps beyond 2038.

As this is an elapsed time and not a timestamp, both fields should be
within the range of long, so cast them to long before formatting
rather than moving to long long.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 misc-utils/fectest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc-utils/fectest.c b/misc-utils/fectest.c
index eb1d33e..f560f2b 100644
--- a/misc-utils/fectest.c
+++ b/misc-utils/fectest.c
@@ -87,6 +87,6 @@ int main(void)
 		exit(1);
 	}
 
-	printf("Decoded in %ld.%06lds\n", now.tv_sec, now.tv_usec);
+	printf("Decoded in %ld.%06lds\n", (long)now.tv_sec, (long)now.tv_usec);
 	return 0;
 }
-- 
2.39.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit system
  2024-04-12 20:55 [PATCH] mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit system Ben Hutchings
@ 2024-04-13  2:13 ` Zhihao Cheng
  2024-04-19  9:21   ` David Oberhollenzer
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihao Cheng @ 2024-04-13  2:13 UTC (permalink / raw)
  To: Ben Hutchings, linux-mtd

在 2024/4/13 4:55, Ben Hutchings 写道:
> fectest.c formats a struct timeval with the assumption that time_t and
> suseconds_t are aliases for long, but some 32-bit systems now define
> them as long long in order to support timestamps beyond 2038.
> 
> As this is an elapsed time and not a timestamp, both fields should be
> within the range of long, so cast them to long before formatting
> rather than moving to long long.
> 
> Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
> ---
>   misc-utils/fectest.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Fix compiler warning.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/misc-utils/fectest.c b/misc-utils/fectest.c
> index eb1d33e..f560f2b 100644
> --- a/misc-utils/fectest.c
> +++ b/misc-utils/fectest.c
> @@ -87,6 +87,6 @@ int main(void)
>   		exit(1);
>   	}
>   
> -	printf("Decoded in %ld.%06lds\n", now.tv_sec, now.tv_usec);
> +	printf("Decoded in %ld.%06lds\n", (long)now.tv_sec, (long)now.tv_usec);
>   	return 0;
>   }
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit system
  2024-04-13  2:13 ` Zhihao Cheng
@ 2024-04-19  9:21   ` David Oberhollenzer
  0 siblings, 0 replies; 3+ messages in thread
From: David Oberhollenzer @ 2024-04-19  9:21 UTC (permalink / raw)
  To: Zhihao Cheng, Ben Hutchings, linux-mtd

Applied to mtd-utils.git master.

Thanks,

David

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-19  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 20:55 [PATCH] mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit system Ben Hutchings
2024-04-13  2:13 ` Zhihao Cheng
2024-04-19  9:21   ` David Oberhollenzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).