Fix find_charset_names.

Message ID 20191021234945.255086-1-tamur@google.com
State New, archived
Headers

Commit Message

Terekhov, Mikhail via Gdb-patches Oct. 21, 2019, 11:49 p.m. UTC
  The patch f2aec7f6d14 changed the return type of relocate_gdb_directory to
std::string, but the change is not reflected in find_charset_names function.
(Probably missed because the broken code is behind an #ifdef).

gdb/ChangeLog

	* charset.c: Reflect API change.
---
 gdb/charset.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Comments

Tom Tromey Oct. 22, 2019, 5:12 p.m. UTC | #1
>>>>> Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes:

> The patch f2aec7f6d14 changed the return type of relocate_gdb_directory to
> std::string, but the change is not reflected in find_charset_names function.
> (Probably missed because the broken code is behind an #ifdef).

> gdb/ChangeLog

> 	* charset.c: Reflect API change.

Normally you'd mention the function here, like:

	* charset.c (find_charset_names): ...

This patch is ok with this change.

Tom
  
Terekhov, Mikhail via Gdb-patches Oct. 22, 2019, 5:14 p.m. UTC | #2
On Mon, Oct 21, 2019 at 6:50 PM Ali Tamur via gdb-patches
<gdb-patches@sourceware.org> wrote:
>
> The patch f2aec7f6d14 changed the return type of relocate_gdb_directory to
> std::string, but the change is not reflected in find_charset_names function.
> (Probably missed because the broken code is behind an #ifdef).

Thanks for fixing my mistake here!

Christian

> gdb/ChangeLog
>
>         * charset.c: Reflect API change.
> ---
>  gdb/charset.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/charset.c b/gdb/charset.c
> index 7568e47cf9..a93fe99c41 100644
> --- a/gdb/charset.c
> +++ b/gdb/charset.c
> @@ -816,10 +816,9 @@ find_charset_names (void)
>
>  #ifdef ICONV_BIN
>    {
> -    char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
> -                                             ICONV_BIN_RELOCATABLE);
> -    iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
> -    xfree (iconv_dir);
> +    std::string iconv_dir = relocate_gdb_directory (ICONV_BIN,
> +                                                   ICONV_BIN_RELOCATABLE);
> +    iconv_program = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", NULL);
>    }
>  #else
>    iconv_program = xstrdup ("iconv");
> --
> 2.23.0.866.gb869b98d4c-goog
>
  

Patch

diff --git a/gdb/charset.c b/gdb/charset.c
index 7568e47cf9..a93fe99c41 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -816,10 +816,9 @@  find_charset_names (void)
 
 #ifdef ICONV_BIN
   {
-    char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
-					      ICONV_BIN_RELOCATABLE);
-    iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
-    xfree (iconv_dir);
+    std::string iconv_dir = relocate_gdb_directory (ICONV_BIN,
+						    ICONV_BIN_RELOCATABLE);
+    iconv_program = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", NULL);
   }
 #else
   iconv_program = xstrdup ("iconv");