Fix build breakage due to event loop simplification
authorPedro Alves <palves@redhat.com>
Wed, 4 Feb 2015 10:05:58 +0000 (11:05 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 4 Feb 2015 10:05:58 +0000 (11:05 +0100)
commit 70b66289 (Simplify event-loop core, remove two-step event
processing) causes a build failure when compiling GDB with gcc/-O2:

 gdb/event-loop.c: In function ‘gdb_do_one_event’:
 gdb/event-loop.c:296:10: error: ‘res’ may be used uninitialized in this function
 [-Werror=maybe-uninitialized]
if (res > 0)
   ^

GCC isn't realizing that event_source_head can never be > 2 and that
therefore 'res' is always initialized in all possible paths.  Adding a
default case that internal_error's makes GCC realize that.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

Fix build breakage.
* event-loop.c (gdb_do_one_event): Add default switch case.

gdb/ChangeLog
gdb/event-loop.c

index 2266c1116346bf26589169a3a2a32a3e7c9b9bcb..1116853641c787630ebb9a9e0baefd1e16db95f2 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-04  Pedro Alves  <palves@redhat.com>
+
+       Fix build breakage.
+       * event-loop.c (gdb_do_one_event): Add default switch case.
+
 2015-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Filter out inferior gcc option -fpreprocessed.
index 7425b3acaa09fd0b9b8b0ea9b04bb25013f9eb1e..a2b41a75daf2f1d1fff9acdbee5614b7b26a4c00 100644 (file)
@@ -287,6 +287,10 @@ gdb_do_one_event (void)
          /* Are there any asynchronous event handlers ready?  */
          res = check_async_event_handlers ();
          break;
+       default:
+         internal_error (__FILE__, __LINE__,
+                         "unexpected event_source_head %d",
+                         event_source_head);
        }
 
       event_source_head++;