From patchwork Mon Sep 24 12:17:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 29523 Received: (qmail 3452 invoked by alias); 24 Sep 2018 12:17:56 -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 3443 invoked by uid 89); 24 Sep 2018 12:17:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=mainc, UD:main.c, main.c X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (50.116.127.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Sep 2018 12:17:54 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway36.websitewelcome.com (Postfix) with ESMTP id BA47F40110E37 for ; Mon, 24 Sep 2018 06:23:32 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 4PnzgiS8nSjJA4Po9gIY2r; Mon, 24 Sep 2018 07:17:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=hUyid9eR7rXlFwJrze02+Y6Edv4xotK4CuZX09+tsHs=; b=V2k5q4JJ/BER6zKdKfdNDuOewn 5AGFP2muSWNP0OHae2PHhyBsXsBjtC/ir1KPDoKle7pVVlQLtg90gpVBopuJCGjYaT2XtrTnZDDOc BKDF+yokXzBOy2fdtANDgJ+Ae; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:33708 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g4Pnz-000GhG-5g; Mon, 24 Sep 2018 07:17:35 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Add "const" to a few locals in gdb Date: Mon, 24 Sep 2018 06:17:32 -0600 Message-Id: <20180924121732.11081-1-tom@tromey.com> I noticed that some code in gdb was doing: char *mumble = getenv (...) However, using "const char *" here would be clearer. This patch fixes the instances I could readily build. Tested by rebuilding. gdb/ChangeLog 2018-09-24 Tom Tromey * common/pathstuff.c (get_standard_cache_dir): Make "xdg_cache_home" and "home" const. * top.c (init_history): Make "tmpenv" const. * main.c (get_init_files): Make "homedir" const. --- gdb/ChangeLog | 7 +++++++ gdb/common/pathstuff.c | 4 ++-- gdb/main.c | 2 +- gdb/top.c | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8005c02554..13fac9256f4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2018-09-24 Tom Tromey + + * common/pathstuff.c (get_standard_cache_dir): Make + "xdg_cache_home" and "home" const. + * top.c (init_history): Make "tmpenv" const. + * main.c (get_init_files): Make "homedir" const. + 2018-09-23 Tom Tromey PR python/18852: diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index 3dd58e31aa4..82905c9e687 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -171,7 +171,7 @@ get_standard_cache_dir () #endif #ifndef __APPLE__ - char *xdg_cache_home = getenv ("XDG_CACHE_HOME"); + const char *xdg_cache_home = getenv ("XDG_CACHE_HOME"); if (xdg_cache_home != NULL) { /* Make sure the path is absolute and tilde-expanded. */ @@ -180,7 +180,7 @@ get_standard_cache_dir () } #endif - char *home = getenv ("HOME"); + const char *home = getenv ("HOME"); if (home != NULL) { /* Make sure the path is absolute and tilde-expanded. */ diff --git a/gdb/main.c b/gdb/main.c index 61644cd0d7d..1552e95f4cd 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -208,7 +208,7 @@ get_init_files (const char **system_gdbinit, if (!initialized) { struct stat homebuf, cwdbuf, s; - char *homedir; + const char *homedir; if (SYSTEM_GDBINIT[0]) { diff --git a/gdb/top.c b/gdb/top.c index 0a4d36cbea4..4a0fedb6a87 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1846,7 +1846,7 @@ set_verbose (const char *args, int from_tty, struct cmd_list_element *c) void init_history (void) { - char *tmpenv; + const char *tmpenv; tmpenv = getenv ("GDBHISTSIZE"); if (tmpenv)