This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Minor simplification of (Python) find_thread_object

On 2017-01-21 23:50, Simon Marchi wrote:
Since the reference to the Inferior Python object is managed by
gdbpy_ref (RAII), we can return directly from the loop.  It's just a
leftover from the cleanups era.


	* python/py-inferior.c (find_thread_object): Return directly
	from the loop.  Remove "found" variable.
 gdb/python/py-inferior.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 9e10d62c51..f3ae82ed54 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -264,13 +264,7 @@ find_thread_object (ptid_t ptid)
for (thread = ((inferior_object *)(inf_obj.get ()))->threads; thread;
        thread = thread->next)
     if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
-      {
-	found = thread->thread_obj;
-	break;
-      }
-  if (found)
-    return found;
+      return thread->thread_obj;

   return NULL;

Self-review: I have just noticed that the "found" variable declaration can be removed.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]