[PATCH 3/3] libgst: Address clang compiler warning

Holger Hans Peter Freyther <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>
Use if () {} else {} instead of an else if() {} that would
always be true. First we compare cur_time to < next_poll_ms
so in the else branch it must be >=.

events.c:218:20: warning: variable 'ms' is used uninitialized whenever 'if' condition is false
      [-Wsometimes-uninitialized]
          else if (cur_time >= next_poll_ms)
                   ^~~~~~~~~~~~~~~~~~~~~~~~
events.c:233:11: note: uninitialized use occurs here
      if (ms == INFINITE)
          ^~
events.c:218:16: note: remove the 'if' if its condition is always true
          else if (cur_time >= next_poll_ms)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
events.c:207:18: note: initialize the variable 'ms' to silence this warning
      unsigned ms;
                 ^
                  = 0

2015-08-02  Holger Hans Peter Freyther  <[email protected]>

	* events.c: Use else instead of else if in
	poll_timer_thread.
---
 libgst/ChangeLog | 5 +++++
 libgst/events.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index cc0fdb1..cbb26c6 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-02  Holger Hans Peter Freyther  <[email protected]>
+
+	* events.c: Use else instead of else if in
+	poll_timer_thread.
+
 2015-05-21  Holger Hans Peter Freyther  <[email protected]>
 
 	* cint.c: Change to use #if instead of #ifdef and update
diff --git a/libgst/events.c b/libgst/events.c
index 2333672..57b33f4 100644
--- a/libgst/events.c
+++ b/libgst/events.c
@@ -215,7 +215,7 @@ poll_timer_thread (void *unused)
           cur_time = _gst_get_milli_time ();
           if (cur_time < next_poll_ms)
             ms = MIN(0, next_poll_ms - cur_time);
-          else if (cur_time >= next_poll_ms)
+          else
             {
               ms = EVENT_LOOP_POLL_INTERVAL;
               next_poll_ms = cur_time + ms;
-- 
2.3.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.