From patchwork Tue Jul 22 18:55:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 2133 Received: (qmail 24871 invoked by alias); 22 Jul 2014 18:55:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 24765 invoked by uid 89); 22 Jul 2014 18:55:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 22 Jul 2014 18:55:26 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6MItOgN026961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 22 Jul 2014 14:55:24 -0400 Received: from barimba.redhat.com (ovpn-113-154.phx2.redhat.com [10.3.113.154]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6MItMWQ000387; Tue, 22 Jul 2014 14:55:23 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 01/13] constify cli-dump.c Date: Tue, 22 Jul 2014 12:55:07 -0600 Message-Id: <1406055319-26380-2-git-send-email-tromey@redhat.com> In-Reply-To: <1406055319-26380-1-git-send-email-tromey@redhat.com> References: <1406055319-26380-1-git-send-email-tromey@redhat.com> This does some minor constification in cli-dump.c. 2014-07-22 Tom Tromey * cli/cli-dump.c (scan_expression_with_cleanup): Return const. Make "cmd" const. (scan_filename_with_cleanup): Likewise. (dump_memory_to_file, dump_value_to_file, restore_binary_file): Make arguments const. (restore_command): Update. --- gdb/ChangeLog | 9 +++++++++ gdb/cli/cli-dump.c | 35 ++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index aec732e..7929dc1 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -35,8 +35,8 @@ #include "filestuff.h" -static char * -scan_expression_with_cleanup (char **cmd, const char *def) +static const char * +scan_expression_with_cleanup (const char **cmd, const char *def) { if ((*cmd) == NULL || (**cmd) == '\0') { @@ -48,19 +48,19 @@ scan_expression_with_cleanup (char **cmd, const char *def) else { char *exp; - char *end; + const char *end; end = (*cmd) + strcspn (*cmd, " \t"); exp = savestring ((*cmd), end - (*cmd)); make_cleanup (xfree, exp); - (*cmd) = skip_spaces (end); + (*cmd) = skip_spaces_const (end); return exp; } } static char * -scan_filename_with_cleanup (char **cmd, const char *defname) +scan_filename_with_cleanup (const char **cmd, const char *defname) { char *filename; char *fullname; @@ -78,13 +78,13 @@ scan_filename_with_cleanup (char **cmd, const char *defname) else { /* FIXME: should parse a possibly quoted string. */ - char *end; + const char *end; - (*cmd) = skip_spaces (*cmd); + (*cmd) = skip_spaces_const (*cmd); end = *cmd + strcspn (*cmd, " \t"); filename = savestring ((*cmd), end - (*cmd)); make_cleanup (xfree, filename); - (*cmd) = skip_spaces (end); + (*cmd) = skip_spaces_const (end); } gdb_assert (filename != NULL); @@ -206,16 +206,16 @@ dump_bfd_file (const char *filename, const char *mode, } static void -dump_memory_to_file (char *cmd, char *mode, char *file_format) +dump_memory_to_file (const char *cmd, const char *mode, const char *file_format) { struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); CORE_ADDR lo; CORE_ADDR hi; ULONGEST count; - char *filename; + const char *filename; void *buf; - char *lo_exp; - char *hi_exp; + const char *lo_exp; + const char *hi_exp; /* Open the file. */ filename = scan_filename_with_cleanup (&cmd, NULL); @@ -262,11 +262,11 @@ dump_memory_command (char *cmd, char *mode) } static void -dump_value_to_file (char *cmd, char *mode, char *file_format) +dump_value_to_file (const char *cmd, const char *mode, const char *file_format) { struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); struct value *val; - char *filename; + const char *filename; /* Open the file. */ filename = scan_filename_with_cleanup (&cmd, NULL); @@ -503,7 +503,7 @@ restore_section_callback (bfd *ibfd, asection *isec, void *args) } static void -restore_binary_file (char *filename, struct callback_data *data) +restore_binary_file (const char *filename, struct callback_data *data) { struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); FILE *file = fopen_with_cleanup (filename, FOPEN_RB); @@ -555,12 +555,13 @@ restore_binary_file (char *filename, struct callback_data *data) } static void -restore_command (char *args, int from_tty) +restore_command (char *args_in, int from_tty) { char *filename; struct callback_data data; bfd *ibfd; int binary_flag = 0; + const char *args = args_in; if (!target_has_execution) noprocess (); @@ -580,7 +581,7 @@ restore_command (char *args, int from_tty) { binary_flag = 1; args += strlen (binary_string); - args = skip_spaces (args); + args = skip_spaces_const (args); } /* Parse offset (optional). */ if (args != NULL && *args != '\0')