diff options
author | Tom Tromey <tromey@redhat.com> | 2013-05-30 16:24:36 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2013-05-30 16:24:36 +0000 |
commit | 5b3fca71ae2013ecb997f9d71c3fc7dfdf69936d (patch) | |
tree | 18f8aa52e4b42f2ea624240679e698f6aef8d181 /gdb/cli/cli-cmds.c | |
parent | af83e3f886c6e098f997d6f03dcf5e807a14a4f2 (diff) | |
download | gdb-5b3fca71ae2013ecb997f9d71c3fc7dfdf69936d.zip gdb-5b3fca71ae2013ecb997f9d71c3fc7dfdf69936d.tar.gz gdb-5b3fca71ae2013ecb997f9d71c3fc7dfdf69936d.tar.bz2 |
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.
Diffstat (limited to 'gdb/cli/cli-cmds.c')
-rw-r--r-- | gdb/cli/cli-cmds.c | 10 |
1 files changed, 8 insertions, 2 deletions
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 |