From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106985 invoked by alias); 4 Apr 2017 17:26:01 -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 106662 invoked by uid 89); 4 Apr 2017 17:26:00 -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:25:59 +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 1E0787E9DA for ; Tue, 4 Apr 2017 17:25:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1E0787E9DA Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1E0787E9DA Received: from cascais.lan (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34D9018247 for ; Tue, 4 Apr 2017 17:25:58 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 03/18] -Wwrite-strings: Don't initialize string command variables to empty string Date: Tue, 04 Apr 2017 17:26:00 -0000 Message-Id: <1491326751-16180-4-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/msg00029.txt.bz2 -Wwrite-strings flags these initializations as requiring a cast. However, these variables are command variables, and as such point to heap-allocated memory. The initial allocation is always done when the corresponding command is registered. E.g.,: dprintf_function = xstrdup ("printf"); add_setshow_string_cmd ("dprintf-function", class_support, &dprintf_function, _("\ Set the function to use for dynamic printf"), _("\ Show the function to use for dynamic printf"), NULL, update_dprintf_commands, NULL, &setlist, &showlist); That's why we never reach a bogus attempt to free these string literals. So, just drop the incorrect initializations. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * breakpoint.c (dprintf_function, dprintf_channel): Don't initialize. * tracepoint.c (default_collect): Don't initialize. --- gdb/breakpoint.c | 4 ++-- gdb/tracepoint.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ab6e9c8..f0db3e4 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -345,7 +345,7 @@ static const char *dprintf_style = dprintf_style_gdb; copied into the command, so it can be anything that GDB can evaluate to a callable address, not necessarily a function name. */ -static char *dprintf_function = ""; +static char *dprintf_function; /* The channel to use for dynamic printf if the preferred style is to call into the inferior; if a nonempty string, it will be passed to @@ -355,7 +355,7 @@ static char *dprintf_function = ""; "stderr", this could be an app-specific expression like "mystreams[curlogger]". */ -static char *dprintf_channel = ""; +static char *dprintf_channel; /* True if dprintf commands should continue to operate even if GDB has disconnected. */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2da6fdd..87ef141 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -139,7 +139,7 @@ static struct traceframe_info *traceframe_info; static struct cmd_list_element *tfindlist; /* List of expressions to collect by default at each tracepoint hit. */ -char *default_collect = ""; +char *default_collect; static int disconnected_tracing; -- 2.5.5