Re: [PATCH 3/3] Simplify event-loop core, remove two-step event processing

Message ID 54D25832.1010007@arm.com
State Superseded
Headers

Commit Message

Alex Velenko Feb. 4, 2015, 5:34 p.m. UTC
  On 03/02/15 22:48, Patrick Palka wrote:
> This patch causes a build failure when compiling GDB with GCC 4.9:
>
> /home/patrick/code/binutils-gdb/gdb/event-loop.c: In function
> ‘gdb_do_one_event’:
> /home/patrick/code/binutils-gdb/gdb/event-loop.c:296:10: error: ‘res’
> may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>         if (res > 0)
>            ^
>

Hi,
Event-loop.c "gdb_do_one_event" function did not initialize variable "res".
This caused gdb_binutils to fail building. This patch fixes it.

Builds with this patch, does not build without it.

Is patch ok? If ok, could you, please, commit (I can't)?

Kind regards,
Alex

gdb/

2015-02-04  Alex Velenko  <Alex.Velenko@arm.com>

   * event-loop.c (gdb_do_one_event): variable "res" initialized.
---
  gdb/event-loop.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Pedro Alves Feb. 4, 2015, 6:17 p.m. UTC | #1
On 02/04/2015 06:34 PM, Alex Velenko wrote:
> On 03/02/15 22:48, Patrick Palka wrote:
>> This patch causes a build failure when compiling GDB with GCC 4.9:
>>
>> /home/patrick/code/binutils-gdb/gdb/event-loop.c: In function
>> ‘gdb_do_one_event’:
>> /home/patrick/code/binutils-gdb/gdb/event-loop.c:296:10: error: ‘res’
>> may be used uninitialized in this function
>> [-Werror=maybe-uninitialized]
>>         if (res > 0)
>>            ^
>>
> 
> Hi,
> Event-loop.c "gdb_do_one_event" function did not initialize variable "res".
> This caused gdb_binutils to fail building. This patch fixes it.

Thanks!  However, this fixed it for me:

 https://sourceware.org/ml/gdb-patches/2015-02/msg00075.html

Can you make sure you have that in your tree?

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 7425b3a..1e2dc45 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -270,7 +270,7 @@  gdb_do_one_event (void)
       round-robin fashion.  */
    for (current = 0; current < number_of_sources; current++)
      {
-      int res;
+      int res = 0;

        switch (event_source_head)
  	{