This is the mail archive of the gdb-patches@sourceware.org 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]

[PATCH 28/40] use explicit returns to avoid checker confusion


The checker does not understand the idiom

if (except.reason < 0) {
   do_cleanups (whatever);
   GDB_PY_HANDLE_EXCEPTION (except);
}

because it doesn't realize that the nested 'if' actually has the same
condition.

This fixes instances of this to be more explicit.

	* python/py-breakpoint.c (bppy_get_commands): Use
	explicit, unconditional return.
	* python/py-frame.c (frapy_read_var): Likewise.
	* python/python.c (gdbpy_decode_line): Likewise.
---
 gdb/python/py-breakpoint.c | 2 +-
 gdb/python/py-frame.c      | 2 +-
 gdb/python/python.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index d099892..fd13811 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -492,7 +492,7 @@ bppy_get_commands (PyObject *self, void *closure)
   if (except.reason < 0)
     {
       do_cleanups (chain);
-      GDB_PY_HANDLE_EXCEPTION (except);
+      return gdbpy_convert_exception (except);
     }
 
   cmdstr = ui_file_xstrdup (string_file, &length);
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 33d0bd0..10a50ea 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -472,7 +472,7 @@ frapy_read_var (PyObject *self, PyObject *args)
       if (except.reason < 0)
 	{
 	  do_cleanups (cleanup);
-	  GDB_PY_HANDLE_EXCEPTION (except);
+	  return gdbpy_convert_exception (except);
 	}
 
       if (!var)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 67d06e5..c4be31b 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -644,7 +644,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
     {
       do_cleanups (cleanups);
       /* We know this will always throw.  */
-      GDB_PY_HANDLE_EXCEPTION (except);
+      return gdbpy_convert_exception (except);
     }
 
   if (sals.nelts)
-- 
1.8.1.4


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