This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Minor simplification of (Python) find_thread_object
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 23 Jan 2017 20:32:21 -0000
- Subject: [binutils-gdb] Minor simplification of (Python) find_thread_object
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=60685cd0b99c575a32c3d004b4af568dd0309bcb
commit 60685cd0b99c575a32c3d004b4af568dd0309bcb
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Mon Jan 23 15:31:40 2017 -0500
Minor simplification of (Python) find_thread_object
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.
gdb/ChangeLog:
* python/py-inferior.c (find_thread_object): Return directly
from the loop. Remove "found" variable.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/python/py-inferior.c | 9 +--------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c2f7654..8704fb0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-23 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * python/py-inferior.c (find_thread_object): Return directly
+ from the loop. Remove "found" variable.
+
2017-01-21 Joel Brobecker <brobecker@adacore.com>
GDB 7.12.1 released.
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 9e10d62..b2aaf25 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -251,7 +251,6 @@ find_thread_object (ptid_t ptid)
{
int pid;
struct threadlist_entry *thread;
- thread_object *found = NULL;
pid = ptid_get_pid (ptid);
if (pid == 0)
@@ -264,13 +263,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;
}