[PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value
Doug Evans
xdje42@gmail.com
Tue Oct 27 17:35:00 GMT 2015
Simon Marchi <simon.marchi@polymtl.ca> writes:
> On 26 October 2015 at 12:21, Doug Evans <xdje42@gmail.com> wrote:
>> The function comment for gdbscm_with_guile says:
>>
>> /* A wrapper around scm_with_guile that prints backtraces and exceptions
>> according to "set guile print-stack".
>> The result if NULL if no exception occurred, otherwise it is a statically
>> allocated error message (caller must *not* free). */
>>
>> If we're going to return an error message,
>> why make it a void * and not a char * (const as appropriate)?
>>
>> The lower level guile API uses a void * because it doesn't specify what
>> the result is. But in this use of it we do specify what the result is.
>
> It totally makes sense. Here is the updated patch (probably garbled
> by gmail, sorry about that):
>
>
> From 2defdf7de52146ea7508d0dda2f0c59e7fdd42fe Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon dot marchi at polymtl dot ca>
> Date: Sun, 25 Oct 2015 23:46:37 -0400
> Subject: [PATCH] guile: Change return value of gdbscm_with_guile for const
> char *
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The documentation of gdbscm_with_guile says that it returns a statically
> allocated string (IOW, a const char *). We can reflect that in its
> return value type, and get rid of C++ build errors.
>
> Initially fixes:
>
> /home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c: In function
> ‘void* gdbscm_disasm_read_memory_worker(void*)’:
> /home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c:93:12: error:
> invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
> return "seek error";
>
> gdb/ChangeLog:
>
> * guile/guile-internal.h (gdbscm_with_guile): Change return
> types to const char *.
> * guile/scm-safe-call.c (gdbscm_with_guile): Likewise.
> (struct c_data) <func>: Likewise.
> (struct c_data) <result>: Change type to const char *.
> (scscm_eval_scheme_string): Change return type to
> const char *.
> (scscm_source_scheme_script): Likewise.
> (gdbscm_safe_eval_string): Change type of result variable to
> const char * and remove cast.
> (gdbscm_safe_source_script): Likewise.
> * guile/scm-disasm.c (gdbscm_disasm_read_memory_worker):
> Change return type to const char *.
> (gdbscm_disasm_read_memory): Change type of status to
> const char *.
LGTM.
Thanks!
More information about the Gdb-patches
mailing list