From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28535 invoked by alias); 18 Apr 2012 14:32:08 -0000 Received: (qmail 28508 invoked by uid 22791); 18 Apr 2012 14:32:05 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Apr 2012 14:31:28 +0000 Received: by vbbey12 with SMTP id ey12so6118200vbb.0 for ; Wed, 18 Apr 2012 07:31:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=a5MopE1MayFAfNgK0V7+w/kPh8hXkwGPcmfSo7+M59M=; b=MMQ+bMG8aCzC3bQqdVhdGfRxWV1WrgYW/xTqJIplzVfHG0ScEHv4gnOZuzEQY4iVdX HbNwpiHM9kX+wibyFo5jezdYIIfHf8Tu2cQLar2tgHeDj1zFk6IXztWCg5xUuI5rived RKhyGL+PYqHGplLFDVgb3qK8uLlY/Qsu9cq0Je1+yga0+sUZQNA9pnRndS5bF8MBEjQ6 xKQjXM46AmL4cN32sFtbwIDO+68d2/544v6bMIm+8+yzGeiXa5I7R075m8Z/nn2QqXO2 GbFMi0p1QCR2cjT9Ozqa/5kzkDrZDkZ7x0AjCfmwqcmAKb9MPcQXGtbRc2rc7lMrpfqZ hsXQ== Received: by 10.220.150.14 with SMTP id w14mr1259530vcv.59.1334759487953; Wed, 18 Apr 2012 07:31:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.150.14 with SMTP id w14mr1259520vcv.59.1334759487789; Wed, 18 Apr 2012 07:31:27 -0700 (PDT) Received: by 10.220.115.78 with HTTP; Wed, 18 Apr 2012 07:31:27 -0700 (PDT) In-Reply-To: <4F8ECE4F.1070004@redhat.com> References: <20120416144011.GH2852@adacore.com> <4F8C3350.1030601@redhat.com> <4F8E88E3.1010900@redhat.com> <4F8ECE4F.1070004@redhat.com> Date: Wed, 18 Apr 2012 14:32:00 -0000 Message-ID: Subject: Re: [RFA] Ensure result of make_cleanup is never NULL. From: Doug Evans To: Pedro Alves Cc: Joel Brobecker , gdb-patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQlGiXARMgEFYpF8Vp4/KzwG2zZhSn2HewuK1ek4GJ0xZRL7Dgqzz7DcXVQ2opbUeJtGsdoUibKMYlLffYpW2Cy4PNT049rQQJllwVEW5f0xuxoY3u+K5Xvkq4P2pJhrG/LaK56SVZjNdridTOAMOtlU+v407w== X-IsSubscribed: yes 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 X-SW-Source: 2012-04/txt/msg00572.txt.bz2 On Wed, Apr 18, 2012 at 7:23 AM, Pedro Alves wrote: > On 04/18/2012 03:02 PM, Doug Evans wrote: > >> On Wed, Apr 18, 2012 at 2:26 AM, Pedro Alves wrote: >>> On 04/18/2012 01:43 AM, Doug Evans wrote: >>> >>>> btw, I thought about making cleanup_sentinel const here, for a bit of >>>> extra robustness. >>> >>> >>> Won't that mean you'd need to cast the constness out in most, if >>> not all places that use it? > > > Well, aren't all places using the sentinel, using it throught the macro? > What does this make more robust? Any attempts to modify the sentinel will segv. >> >> --- cleanups.c=3D 2012-04-17 12:02:38.000000000 -0700 >> +++ cleanups.c =A02012-04-18 06:59:46.000000000 -0700 >> @@ -50,10 +50,10 @@ struct cleanup >> =A0 =A0 =A0 [though this won't catch errors that a value of, say, >> =A0 =A0 =A0 ((struct cleanup *) -1) will] >> =A0 =A0 - displays as something useful when printed in gdb. =A0*/ >> -static struct cleanup cleanup_sentinel; >> +static const struct cleanup cleanup_sentinel; >> >> =A0/* Handy macro to use when referring to cleanup_sentinel. =A0*/ >> -#define CLEANUP_SENTINEL (&cleanup_sentinel) >> +#define CLEANUP_SENTINEL ((struct cleanup *) &cleanup_sentinel) >> >> =A0/* Chain of cleanup actions established with make_cleanup, >> =A0 =A0 to be executed if an error happens. =A0*/