This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 03/40] fix print_command_1
- From: Tom Tromey <tromey at redhat dot com>
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 09 May 2013 12:49:14 -0600
- Subject: [PATCH 03/40] fix print_command_1
- References: <cover dot 1368124285 dot git dot tromey at redhat dot com>
This is a stylistic patch to make it so the checker can analyze
print_command_1. This amounts to installing an outer cleanup and
unconditionally invoking it.
* printcmd.c (print_command_1): Unconditionally call do_cleanups.
---
gdb/printcmd.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2cc33d0..7beb334 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -936,11 +936,10 @@ static void
print_command_1 (const char *exp, int voidprint)
{
struct expression *expr;
- struct cleanup *old_chain = 0;
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
char format = 0;
struct value *val;
struct format_data fmt;
- int cleanup = 0;
if (exp && *exp == '/')
{
@@ -960,8 +959,7 @@ print_command_1 (const char *exp, int voidprint)
if (exp && *exp)
{
expr = parse_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
- cleanup = 1;
+ make_cleanup (free_current_contents, &expr);
val = evaluate_expression (expr);
}
else
@@ -996,8 +994,7 @@ print_command_1 (const char *exp, int voidprint)
annotate_value_end ();
}
- if (cleanup)
- do_cleanups (old_chain);
+ do_cleanups (old_chain);
}
static void
--
1.8.1.4