Fix ignored-qualifiers warning
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Tue, 30 Dec 2025 09:13:52 +0000 (10:13 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 31 Dec 2025 11:11:25 +0000 (12:11 +0100)
Original warning:
src/timefunc.hxx:418:30: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]

The function 'get_msec' was declared to return 'const long' but the const on
return by value is meaningless (the return value is a prvalue, not an lvalue).
Changed to 'long get_msec()' and also changed implementation to access
value.tv_nsec directly to avoid calling non-const get_nsec from const method.

src/timefunc.hxx

index 1a8911e..765443d 100644 (file)
@@ -415,8 +415,8 @@ namespace clock {
             inline CONSTEXPR const long &get_nsec (void) const NOEXCEPT
             { return this->value.tv_nsec; }
 
-            inline CONSTEXPR const long get_msec (void) const NOEXCEPT
-            { return this->get_nsec () / 1000000; }
+            inline CONSTEXPR long get_msec (void) const NOEXCEPT
+            { return this->value.tv_nsec / 1000000; }
 
             int64_t as_nanosec (void) const NOEXCEPT;