diff options
author | Tom Tromey <tom@tromey.com> | 2017-01-12 08:59:26 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-02-10 12:24:34 -0700 |
commit | 2bb8f231957e2beecfb689a896252b8d9fb67e23 (patch) | |
tree | 5f6758d1a942b1012bdaa99f5e8edee604038c0e /gdb/python/py-linetable.c | |
parent | 1bdfaf42ac152bb30e2b3ae3ab67b241835bba44 (diff) | |
download | binutils-2bb8f231957e2beecfb689a896252b8d9fb67e23.zip binutils-2bb8f231957e2beecfb689a896252b8d9fb67e23.tar.gz binutils-2bb8f231957e2beecfb689a896252b8d9fb67e23.tar.bz2 |
Remove some gotos from Python
This patch slightly refactors a couple of spots in the Python code to
avoid some gotos.
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/python.c (do_start_initialization): New function, from
_initialize_python.
(_initialize_python): Call do_start_initialization.
* python/py-linetable.c (ltpy_iternext): Use explicit returns, not
goto.
Diffstat (limited to 'gdb/python/py-linetable.c')
-rw-r--r-- | gdb/python/py-linetable.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index d8597e4..a5e57b0 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -407,7 +407,10 @@ ltpy_iternext (PyObject *self) LTPY_REQUIRE_VALID (iter_obj->source, symtab); if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems) - goto stop_iteration; + { + PyErr_SetNone (PyExc_StopIteration); + return NULL; + } item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]); @@ -419,7 +422,10 @@ ltpy_iternext (PyObject *self) /* Exit if the internal value is the last item in the line table. */ if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems) - goto stop_iteration; + { + PyErr_SetNone (PyExc_StopIteration); + return NULL; + } item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]); } @@ -427,10 +433,6 @@ ltpy_iternext (PyObject *self) iter_obj->current_index++; return obj; - - stop_iteration: - PyErr_SetNone (PyExc_StopIteration); - return NULL; } /* Implementation of gdb.LineTableIterator.is_valid (self) -> Boolean. |