[PATCH 4/4] Profile: fix a couple of warnings

Lubomir I. Ivanov neolit123 at gmail.com
Thu Mar 12 17:32:51 PDT 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

profilewidget2.cpp:1398:25: warning: the omitted middle operand in
?: will always be 'true', suggest explicit middle operand [-Wparentheses]

profilewidget2.cpp:1403:39: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---

mingw-gcc-4.8.2

the second one is reasonable, but i'm not sure about the first one.
the patch makes it safer, but uglier and slower if that matters.

please, discard or comment if see fit.
---
 qt-ui/profile/profilewidget2.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index e314c33..8e3641b 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1391,10 +1391,10 @@ void ProfileWidget2::changeGas()
 
 	// backup the things on the dataModel, since we will clear that out.
 	struct gasmix gasmix;
-	int seconds = timeAxis->valueAt(scenePos);
+	qreal sec_val = timeAxis->valueAt(scenePos);
 
 	// no gas changes before the dive starts
-	seconds = seconds > 0 ?: 0;
+	unsigned int seconds = (sec_val < 0.0) ? 0 : (unsigned int)sec_val;
 
 	// if there is a gas change at this time stamp, remove it before adding the new one
 	struct event *gasChangeEvent = current_dc->events;
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list