This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add "const" to a few locals in gdb


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b5a9bfbebec0a42d3c5b4fe3b7a62bd31cecc440

commit b5a9bfbebec0a42d3c5b4fe3b7a62bd31cecc440
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Sep 24 06:15:17 2018 -0600

    Add "const" to a few locals in gdb
    
    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  <tom@tromey.com>
    
    	* 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.

Diff:
---
 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 e8005c0..13fac92 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-24  Tom Tromey  <tom@tromey.com>
+
+	* 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  <tom@tromey.com>
 
 	PR python/18852:
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
index 3dd58e3..82905c9 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 61644cd..1552e95 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 0a4d36c..4a0fedb 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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]