diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2013-08-18 13:16:53 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-21 21:23:16 +0200 |
commit | 4fbe3eb2a88141235cdc6e8b76079e7faf56b380 (patch) | |
tree | 6c49f1769c3e7ebbf8472c6953690ca0888e7d60 /src/corelib/global | |
parent | 2e9345b627dedb7cf224ab71479c76bd302ee294 (diff) |
Mark qFuzzy* and qIsNull as Q_REQUIRED_RESULT
Calling them and not using the return value makes no sense.
And it's even worse -- in autotests people might call those
functions without wrapping them in QVERIFY(), effectively
not testing anything.
Change-Id: I2c90d1c85963ff1f35f00653d536a9252c2fcc48
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f9629ff430..41f21bb0dd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -681,11 +681,13 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO) #endif +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT; Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT; Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); @@ -694,6 +696,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) /*! \internal */ +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT; Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; @@ -702,6 +705,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) /*! \internal */ +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT; Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; @@ -712,6 +716,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ +static inline bool qIsNull(double d) Q_REQUIRED_RESULT; static inline bool qIsNull(double d) { union U { @@ -728,6 +733,7 @@ static inline bool qIsNull(double d) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ +static inline bool qIsNull(float f) Q_REQUIRED_RESULT; static inline bool qIsNull(float f) { union U { |