From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108715 invoked by alias); 4 Apr 2017 17:26:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 108081 invoked by uid 89); 4 Apr 2017 17:26:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Tue, 04 Apr 2017 17:26:01 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CD2B3DBC1 for ; Tue, 4 Apr 2017 17:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7CD2B3DBC1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7CD2B3DBC1 Received: from cascais.lan (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5CF818247 for ; Tue, 4 Apr 2017 17:26:00 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 05/18] -Wwrite-strings: Constify warning_pre_print Date: Tue, 04 Apr 2017 17:26:00 -0000 Message-Id: <1491326751-16180-6-git-send-email-palves@redhat.com> In-Reply-To: <1491326751-16180-1-git-send-email-palves@redhat.com> References: <1491326751-16180-1-git-send-email-palves@redhat.com> X-SW-Source: 2017-04/txt/msg00040.txt.bz2 -Wwrite-strings flags a warning here: char *warning_pre_print = "\nwarning: "; * main.c (captured_main_1): Use gdb::unique_xmalloc_ptr to manage the memory of the temporary warning_pre_print override. * utils.c (warning_pre_print): Constify. * utils.h (warning_pre_print): Constify. --- gdb/main.c | 6 ++++-- gdb/utils.c | 2 +- gdb/utils.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index 30e27c2..df4b111 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -545,7 +545,9 @@ captured_main_1 (struct captured_main_args *context) #endif /* Prefix warning messages with the command name. */ - warning_pre_print = xstrprintf ("%s: warning: ", gdb_program_name); + gdb::unique_xmalloc_ptr tmp_warn_preprint + (xstrprintf ("%s: warning: ", gdb_program_name)); + warning_pre_print = tmp_warn_preprint.get (); if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf))) perror_warning_with_name (_("error finding working directory")); @@ -972,7 +974,7 @@ captured_main_1 (struct captured_main_args *context) } /* Set off error and warning messages with a blank line. */ - xfree (warning_pre_print); + tmp_warn_preprint.reset (); warning_pre_print = _("\nwarning: "); /* Read and execute the system-wide gdbinit file, if it exists. diff --git a/gdb/utils.c b/gdb/utils.c index 39798cc..6b8f2f7 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -122,7 +122,7 @@ show_sevenbit_strings (struct ui_file *file, int from_tty, /* String to be printed before warning messages, if any. */ -char *warning_pre_print = "\nwarning: "; +const char *warning_pre_print = "\nwarning: "; int pagination_enabled = 1; static void diff --git a/gdb/utils.h b/gdb/utils.h index fb75f2e..2380bd7 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -298,7 +298,7 @@ extern void (*deprecated_error_begin_hook) (void); /* Message to be printed before the warning message, when a warning occurs. */ -extern char *warning_pre_print; +extern const char *warning_pre_print; extern void error_stream (const string_file &) ATTRIBUTE_NORETURN; -- 2.5.5