From 5b3fca71ae2013ecb997f9d71c3fc7dfdf69936d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 30 May 2013 16:24:36 +0000 Subject: some cleanup checker fixes Fix some bugs pointed out by the cleanup checker. This one just fixes some simple CLI reports, where CLI commands know that their caller will do cleanups. This an older style with few instances, so it is simpler to fix them up than to teach the checker about it. * cli/cli-cmds.c (cd_command, alias_command): Call do_cleanups. * cli/cli-dump.c (restore_binary_file): Call do_cleanups. * interps.c (interpreter_exec_cmd): Call do_cleanups. * source.c (show_substitute_path_command): Call do_cleanups. (unset_substitute_path_command, set_substitute_path_command): Likewise. * symfile.c (load_command): Call do_cleanups. --- gdb/cli/cli-cmds.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gdb/cli/cli-cmds.c') diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index cf88b6d..6ee7673 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -357,6 +357,7 @@ cd_command (char *dir, int from_tty) /* Found something other than leading repetitions of "/..". */ int found_real_path; char *p; + struct cleanup *cleanup; /* If the new directory is absolute, repeat is a no-op; if relative, repeat might be useful but is more likely to be a mistake. */ @@ -366,7 +367,7 @@ cd_command (char *dir, int from_tty) dir = "~"; dir = tilde_expand (dir); - make_cleanup (xfree, dir); + cleanup = make_cleanup (xfree, dir); if (chdir (dir) < 0) perror_with_name (dir); @@ -450,6 +451,8 @@ cd_command (char *dir, int from_tty) if (from_tty) pwd_command ((char *) 0, 1); + + do_cleanups (cleanup); } /* Show the current value of the 'script-extension' option. */ @@ -1327,13 +1330,14 @@ alias_command (char *args, int from_tty) char *args2, *equals, *alias, *command; char **alias_argv, **command_argv; dyn_string_t alias_dyn_string, command_dyn_string; + struct cleanup *cleanup; static const char usage[] = N_("Usage: alias [-a] [--] ALIAS = COMMAND"); if (args == NULL || strchr (args, '=') == NULL) error (_(usage)); args2 = xstrdup (args); - make_cleanup (xfree, args2); + cleanup = make_cleanup (xfree, args2); equals = strchr (args2, '='); *equals = '\0'; alias_argv = gdb_buildargv (args2); @@ -1440,6 +1444,8 @@ alias_command (char *args, int from_tty) command_argv[command_argc - 1], class_alias, abbrev_flag, c_command->prefixlist); } + + do_cleanups (cleanup); } /* Print a list of files and line numbers which a user may choose from -- cgit v1.1