[PATCH v7 09/14] tests/msg_control: Use the old time_t struct for old timestamps
Alistair Francis
alistair.francis at wdc.com
Fri Apr 17 16:47:19 UTC 2020
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..090a89b4 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_old_timespec_t ts = {
.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_old_timespec_t ts[] = {
{ .tv_sec = 123456789, .tv_nsec = 987654321 },
{ .tv_sec = 123456790, .tv_nsec = 987654320 },
{ .tv_sec = 123456791, .tv_nsec = 987654319 }
--
2.26.0
More information about the Strace-devel
mailing list