[PATCH v4 8/8] tests/msg_control: Use the old time_t struct for old timestamps

Dmitry V. Levin ldv at altlinux.org
Tue Mar 10 01:56:36 UTC 2020


On Mon, Mar 09, 2020 at 05:43:04PM -0700, Alistair Francis wrote:
> The SO_TIMESTAMP_OLD returns a timeval that matches the struct
> kernel_old_timeval_t instead of the struct timeval. This is different
> on new 32-bit architectures (like RV32) where timeval uses 64-bit time_t
> while kernel_old_timeval_t uses 32-bit.
> 
> To fix overflow errors let's case the data to a struct
> kernel_old_timeval_t instead of the libc stuct timeval.
> 
> Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
> ---
>  tests/msg_control.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/msg_control.c b/tests/msg_control.c
> index ea601506..325542bb 100644
> --- a/tests/msg_control.c
> +++ b/tests/msg_control.c
> @@ -31,6 +31,9 @@
>  #include "xlat/scmvals.h"
>  #undef XLAT_MACROS_ONLY
>  
> +#include "kernel_timeval.h"
> +#include "kernel_timespec.h"
> +
>  #ifndef SOL_IP
>  # define SOL_IP 0
>  #endif
> @@ -214,7 +217,7 @@ test_scm_rights3(struct msghdr *const mh, void *const page, const size_t nfds)
>  static void
>  test_scm_timestamp_old(struct msghdr *const mh, void *const page)
>  {
> -	static const struct timeval tv = {
> +	static const kernel_old_timeval_t tv = {
>  		.tv_sec = 123456789,
>  		.tv_usec = 987654
>  	};
> @@ -261,7 +264,7 @@ test_scm_timestamp_old(struct msghdr *const mh, void *const page)
>  static void
>  test_scm_timestampns_old(struct msghdr *const mh, void *const page)
>  {
> -	static const struct timespec ts = {
> +	static const kernel_timespec_t ts = {

This doesn't look correct, the type has to be struct __kernel_old_timespec
or equivalent.

>  		.tv_sec = 123456789,
>  		.tv_nsec = 987654321
>  	};
> @@ -309,7 +312,7 @@ test_scm_timestampns_old(struct msghdr *const mh, void *const page)
>  static void
>  test_scm_timestamping_old(struct msghdr *const mh, void *const page)
>  {
> -	static const struct timespec ts[] = {
> +	static const kernel_timespec_t ts[] = {

Likewise.


-- 
ldv


More information about the Strace-devel mailing list