From patchwork Mon Apr 6 17:26:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 6019 Received: (qmail 13361 invoked by alias); 6 Apr 2015 17:26:52 -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 13352 invoked by uid 89); 6 Apr 2015 17:26:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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; Mon, 06 Apr 2015 17:26:50 +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 (Postfix) with ESMTPS id 9D644BBF5E for ; Mon, 6 Apr 2015 17:26:49 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-21.ams2.redhat.com [10.36.116.21]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t36HQmtj017231; Mon, 6 Apr 2015 13:26:48 -0400 Subject: [PATCH v2 3/9] Code cleanup: compile: Constify some parameters From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Phil Muldoon Date: Mon, 06 Apr 2015 19:26:47 +0200 Message-ID: <20150406172647.31404.85083.stgit@host1.jankratochvil.net> In-Reply-To: <20150406172623.31404.58833.stgit@host1.jankratochvil.net> References: <20150406172623.31404.58833.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes gdb/ChangeLog 2015-03-26 Jan Kratochvil * compile/compile.c (compile_to_object): Make the cmd_string parameter const. Use new variables for the const compatibility. (eval_compile_command): Make the cmd_string parameter const. * compile/compile.h (eval_compile_command): Make the cmd_string parameter const. --- gdb/compile/compile.c | 15 +++++++++------ gdb/compile/compile.h | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 3cbbc29..621de66 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -415,11 +415,12 @@ print_callback (void *ignore, const char *message) freeing both strings. */ static char * -compile_to_object (struct command_line *cmd, char *cmd_string, +compile_to_object (struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, char **source_filep) { char *code; + const char *input; char *source_file, *object_file; struct compile_instance *compiler; struct cleanup *cleanup, *inner_cleanup; @@ -459,6 +460,7 @@ compile_to_object (struct command_line *cmd, char *cmd_string, { struct ui_file *stream = mem_fileopen (); struct command_line *iter; + char *stream_buf; make_cleanup_ui_file_delete (stream); for (iter = cmd->body_list[0]; iter; iter = iter->next) @@ -467,15 +469,16 @@ compile_to_object (struct command_line *cmd, char *cmd_string, fputs_unfiltered ("\n", stream); } - code = ui_file_xstrdup (stream, NULL); - make_cleanup (xfree, code); + stream_buf = ui_file_xstrdup (stream, NULL); + make_cleanup (xfree, stream_buf); + input = stream_buf; } else if (cmd_string != NULL) - code = cmd_string; + input = cmd_string; else error (_("Neither a simple expression, or a multi-line specified.")); - code = current_language->la_compute_program (compiler, code, gdbarch, + code = current_language->la_compute_program (compiler, input, gdbarch, expr_block, expr_pc); make_cleanup (xfree, code); if (compile_debug) @@ -556,7 +559,7 @@ compile_command (char *args, int from_tty) /* See compile.h. */ void -eval_compile_command (struct command_line *cmd, char *cmd_string, +eval_compile_command (struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, void *scope_data) { char *object_file, *source_file; diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h index 93c4786..a973167 100644 --- a/gdb/compile/compile.h +++ b/gdb/compile/compile.h @@ -28,7 +28,8 @@ struct dynamic_prop; expression command. GDB returns either a CMD, or a CMD_STRING, but never both. */ -extern void eval_compile_command (struct command_line *cmd, char *cmd_string, +extern void eval_compile_command (struct command_line *cmd, + const char *cmd_string, enum compile_i_scope_types scope, void *scope_data);