Commit 796f708f authored by Dmitry Shulga's avatar Dmitry Shulga

MDEV-24115 Fix -Wconversion in Timeval::Timeval() on Mac OS X

The data member tv_usec of the struct timeval is declared as suseconds_t
on MacOS. Size of suseconds_t is 4 bytes. On the other hand, size of ulong
is 8 bytes on 64-bit MacOS, so attempt to assign a value of wider type
(usec) to a value (tv_usec) of narrower type leads to error.
parent f0c99037
......@@ -871,7 +871,13 @@ class Timeval: public timeval
Timeval(my_time_t sec, ulong usec)
{
tv_sec= sec;
tv_usec= usec;
/*
Since tv_usec is not always of type ulong, cast usec parameter
explicitly to uint to avoid compiler warnings about losing
integer precision.
*/
DBUG_ASSERT(usec < 1000000);
tv_usec= (uint)usec;
}
explicit Timeval(const timeval &tv)
:timeval(tv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment