From: Simon Marchi Date: Fri, 17 Jan 2020 14:51:10 +0000 (-0500) Subject: gdb: remove use of iterate_over_inferiors in py-inferior.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d9bc85b65b3daab0c3579be0efc3b33c1ef24620;p=binutils-gdb.git gdb: remove use of iterate_over_inferiors in py-inferior.c Use range-based for instead of iterate_over_inferiors in one spot in the Python code. gdb/ChangeLog: * python/py-inferior.c (build_inferior_list): Remove. (gdbpy_ref): Use range-based for loop to iterate over inferiors. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5301385ecbf..2de025dd630 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-01-17 Simon Marchi + + * python/py-inferior.c (build_inferior_list): Remove. + (gdbpy_ref): Use range-based for loop to iterate over inferiors. + 2020-01-16 Christian Biesinger * btrace.c (btrace_compute_ftrace_1): Fix spelling error (Unkown). diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 4adc5d6f998..fd7d8a8aa70 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -462,18 +462,6 @@ infpy_get_progspace (PyObject *self, void *closure) return pspace_to_pspace_object (pspace).release (); } -static int -build_inferior_list (struct inferior *inf, void *arg) -{ - PyObject *list = (PyObject *) arg; - gdbpy_ref inferior = inferior_to_inferior_object (inf); - - if (inferior == NULL) - return 0; - - return PyList_Append (list, (PyObject *) inferior.get ()) ? 1 : 0; -} - /* Implementation of gdb.inferiors () -> (gdb.Inferior, ...). Returns a tuple of all inferiors. */ PyObject * @@ -483,8 +471,16 @@ gdbpy_inferiors (PyObject *unused, PyObject *unused2) if (list == NULL) return NULL; - if (iterate_over_inferiors (build_inferior_list, list.get ())) - return NULL; + for (inferior *inf : all_inferiors ()) + { + gdbpy_ref inferior = inferior_to_inferior_object (inf); + + if (inferior == NULL) + continue; + + if (PyList_Append (list.get (), (PyObject *) inferior.get ()) != 0) + return NULL; + } return PyList_AsTuple (list.get ()); }