summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Shulga <dmitry.shulga@mariadb.com>2020-11-17 19:23:33 +0700
committerDmitry Shulga <dmitry.shulga@mariadb.com>2020-11-17 19:23:33 +0700
commit796f708f85d3b8b68d1aa338dfa60cfea8f3cdac (patch)
treeeca91d5f538f3a8ba11da184462a1c652e20f95d
parentf0c990379565748c7faa6a068b992f61d9ceb46c (diff)
downloadmariadb-git-bb-10.4-MDEV-24115.tar.gz
MDEV-24115 Fix -Wconversion in Timeval::Timeval() on Mac OS Xbb-10.4-MDEV-24115
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.
-rw-r--r--sql/structs.h8
1 files changed, 7 insertions, 1 deletions
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)