Use getenv instead of gdb_environ on mi-cmd-env.c
authorSergio Durigan Junior <sergiodj@redhat.com>
Fri, 16 Jun 2017 22:10:27 +0000 (18:10 -0400)
committerSergio Durigan Junior <sergiodj@redhat.com>
Mon, 19 Jun 2017 04:14:00 +0000 (00:14 -0400)
This is a spinoff of
<https://sourceware.org/ml/gdb-patches/2017-06/msg00437.html>.
mi-cmd-env.c is using the whole gdb_environ machinery in order to
access just one variable, which can be easily replaced by a simple
call to getenv.  This patch does that, and doesn't cause regressions.

gdb/ChangeLog:
2017-06-18  Sergio Durigan Junior  <sergiodj@redhat.com>

* mi/mi-cm-env.c (_initialize_mi_cmd_env): Use getenv instead of
gdb_environ to access an environment variable.

gdb/ChangeLog
gdb/mi/mi-cmd-env.c

index 1bbcb711b0be9f3e3e0e9b8c93603deb5859e498..aaf4b891aeef8a34de4220f4b846c3dd2db656b6 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-19  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * mi/mi-cm-env.c (_initialize_mi_cmd_env): Use getenv instead of
+       gdb_environ to access an environment variable.
+
 2017-06-18  Thomas Petazzoni  <thomas.petazzoni@free-electrons.com>
 
        * nat/linux-ptrace.c (linux_fork_to_function): Add cast to
index 4093178713ff1b1fd93a08ad3e229a38a8799a27..97be139afd342a9417352fea83b060d4a454d2f7 100644 (file)
@@ -270,21 +270,17 @@ mi_cmd_inferior_tty_show (const char *command, char **argv, int argc)
 void 
 _initialize_mi_cmd_env (void)
 {
-  struct gdb_environ *environment;
   const char *env;
 
   /* We want original execution path to reset to, if desired later.
      At this point, current inferior is not created, so cannot use
-     current_inferior ()->environment.  Also, there's no obvious
-     place where this code can be moved such that it surely run
-     before any code possibly mangles original PATH.  */
-  environment = make_environ ();
-  init_environ (environment);
-  env = get_in_environ (environment, path_var_name);
+     current_inferior ()->environment.  We use getenv here because it
+     is not necessary to create a whole new gdb_environ just for one
+     variable.  */
+  env = getenv (path_var_name);
 
   /* Can be null if path is not set.  */
   if (!env)
     env = "";
   orig_path = xstrdup (env);
-  free_environ (environment);
 }
This page took 0.030259 seconds and 4 git commands to generate.