[PATCH] Cleanup num_found usage in gdb_wait_for_event

Simon Marchi simon.marchi@ericsson.com
Wed Apr 29 19:16:00 GMT 2015


Probably an artifact from the past, managing num_found in those loops is
not need.

Regtested on Ubuntu 14.04 x64, although only with use_poll == 1.

gdb/ChangeLog:

	* event-loop.c (gdb_wait_for_event): Cleanup uneeded usages of
	num_found.
---
 gdb/event-loop.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 79e41fd..c7ad8b8 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -751,24 +751,22 @@ gdb_wait_for_event (int block)
   if (use_poll)
     {
 #ifdef HAVE_POLL
-      for (i = 0; (i < gdb_notifier.num_fds) && (num_found > 0); i++)
+      for (i = 0; i < gdb_notifier.num_fds; i++)
 	{
-	  if ((gdb_notifier.poll_fds + i)->revents)
-	    num_found--;
-	  else
+	  if (!gdb_notifier.poll_fds[i].revents)
 	    continue;
 
 	  for (file_ptr = gdb_notifier.first_file_handler;
 	       file_ptr != NULL;
 	       file_ptr = file_ptr->next_file)
 	    {
-	      if (file_ptr->fd == (gdb_notifier.poll_fds + i)->fd)
+	      if (file_ptr->fd == gdb_notifier.poll_fds[i].fd)
 		break;
 	    }
 
 	  if (file_ptr)
 	    {
-	      int mask = (gdb_notifier.poll_fds + i)->revents;
+	      int mask = gdb_notifier.poll_fds[i].revents;
 
 	      handle_file_event (file_ptr, mask);
 	      return 1;
@@ -782,7 +780,7 @@ gdb_wait_for_event (int block)
   else
     {
       for (file_ptr = gdb_notifier.first_file_handler;
-	   (file_ptr != NULL) && (num_found > 0);
+	   file_ptr != NULL;
 	   file_ptr = file_ptr->next_file)
 	{
 	  int mask = 0;
@@ -796,8 +794,6 @@ gdb_wait_for_event (int block)
 
 	  if (!mask)
 	    continue;
-	  else
-	    num_found--;
 
 	  handle_file_event (file_ptr, mask);
 	  return 1;
-- 
2.1.4



More information about the Gdb-patches mailing list