Hi,

We realized on our machine, the timespec.time_t (long int) is of 4 bytes,
which would cause overflow when converting to internal tmv_t, if the second
value is bigger than 2pow(31)-1.

 <https://en.wikipedia.org/wiki/Year_2038_problem>
https://en.wikipedia.org/wiki/Year_2038_problem

 

How do we solve this problem in general? Would below conversion to unsigned
is a proper fix?

 

Thanks,

Vincent

 

diff --git a/tmv.h b/tmv.h

index cca4da7..2e34ff4 100644

--- a/tmv.h

+++ b/tmv.h

@@ -139,7 +139,7 @@ static inline struct Timestamp tmv_to_Timestamp(tmv_t x)

static inline tmv_t timespec_to_tmv(struct timespec ts)

{

        tmv_t t;

-       t.ns = ts.tv_sec * NS_PER_SEC + ts.tv_nsec;

+       t.ns = (unsigned long int)ts.tv_sec * NS_PER_SEC + ts.tv_nsec;

        return t;

}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to