From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110576 invoked by alias); 27 Oct 2015 15:55:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 110565 invoked by uid 89); 27 Oct 2015 15:55:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f41.google.com Received: from mail-pa0-f41.google.com (HELO mail-pa0-f41.google.com) (209.85.220.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 27 Oct 2015 15:55:31 +0000 Received: by pacfv9 with SMTP id fv9so236370725pac.3 for ; Tue, 27 Oct 2015 08:55:29 -0700 (PDT) X-Received: by 10.66.254.130 with SMTP id ai2mr28633795pad.89.1445961329603; Tue, 27 Oct 2015 08:55:29 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id fe8sm40623808pab.40.2015.10.27.08.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2015 08:55:29 -0700 (PDT) From: Doug Evans To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> <1445831204-16588-5-git-send-email-simon.marchi@polymtl.ca> Date: Tue, 27 Oct 2015 17:35:00 -0000 In-Reply-To: (Simon Marchi's message of "Mon, 26 Oct 2015 21:29:32 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00630.txt.bz2 Simon Marchi writes: > On 26 October 2015 at 12:21, Doug Evans 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 static= ally >> 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 > 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=3DUTF-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 > =E2=80=98void* gdbscm_disasm_read_memory_worker(void*)=E2=80=99: > /home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c:93:12: error: > invalid conversion from =E2=80=98const void*=E2=80=99 to =E2=80=98void*= =E2=80=99 [-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) : Likewise. > (struct c_data) : 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!