From 796f708f85d3b8b68d1aa338dfa60cfea8f3cdac Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 17 Nov 2020 19:23:33 +0700 Subject: 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. --- sql/structs.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sql/structs.h') diff --git a/sql/structs.h b/sql/structs.h index c47e4802452..28c0cb6e1a2 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -871,7 +871,13 @@ public: 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) -- cgit v1.2.1