This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value
- From: Doug Evans <xdje42 at gmail dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 27 Oct 2015 08:54:13 -0700
- Subject: Re: [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value
- Authentication-results: sourceware.org; auth=none
- References: <1445831204-16588-1-git-send-email-simon dot marchi at polymtl dot ca> <1445831204-16588-5-git-send-email-simon dot marchi at polymtl dot ca> <m3k2qab3v4 dot fsf at sspiff dot org> <CAFXXi0kxpDNB7EwPK-ot4qFBetPxgENbknD8861EB3mvF_vZTw at mail dot gmail dot com> <m3y4epa9e4 dot fsf at sspiff dot org> <CAFXXi0m1DjU2YQuEnuVk7ZVTHwTijZnUC902qeaw95ifDJCiWA at mail dot gmail dot com>
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!