Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0D1C3431FAF for ; Thu, 12 Apr 2012 10:57:34 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NNtKva1dsRw4 for ; Thu, 12 Apr 2012 10:57:33 -0700 (PDT) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 4FE23431FAE for ; Thu, 12 Apr 2012 10:57:33 -0700 (PDT) X-AuditID: 1209190f-b7f8a6d000000914-b8-4f87178ca6c5 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 38.BF.02324.C87178F4; Thu, 12 Apr 2012 13:57:32 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q3CHvVtR014123; Thu, 12 Apr 2012 13:57:32 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3CHvUJm010169 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 12 Apr 2012 13:57:31 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1SIOGv-0004T4-V9; Thu, 12 Apr 2012 13:57:30 -0400 Date: Thu, 12 Apr 2012 13:57:29 -0400 From: Austin Clements To: Jani Nikula Subject: Re: [PATCH 4/4] Explicitly type void* pointers Message-ID: <20120412175729.GH13549@mit.edu> References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com> <1333966665-10469-5-git-send-email-Vladimir.Marek@oracle.com> <20120409181543.GC10554@pub.czech.sun.com> <87mx6ka8y1.fsf@nikula.org> <87vcl6nfda.fsf@awakening.csail.mit.edu> <87aa2hxtrv.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87aa2hxtrv.fsf@nikula.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42IRYrdT1+0Rb/c3OL3BwqJpurPF9ZszmS06 bu9mc2D2uHX/NbvHs1W3mD0+Pr3FEsAcxWWTkpqTWZZapG+XwJWxpvMZU8Fv4YqZezvZGhh3 8XcxcnBICJhI3Pir0MXICWSKSVy4t56ti5GLQ0hgH6PE9tsbmSGcDYwSW+ZeZ4dwTjJJ3P90 F6psCaPE739dbCD9LAKqEm0Hn7KD2GwCGhLb9i9nBLFFBBQlNp/cD2YzC8RLPLr8hRXEFhYw l/j4fwIziM0roCPxbM8yqHVPmCTeNPazQyQEJU7OfMIC0awlcePfSyaQu5kFpCWW/+MACXMC 7WrY/4YJxBYVUJGYcnIb2wRGoVlIumch6Z6F0L2AkXkVo2xKbpVubmJmTnFqsm5xcmJeXmqR rolebmaJXmpK6SZGUKhzSvLvYPx2UOkQowAHoxIP74tnbf5CrIllxZW5hxglOZiURHk/C7X7 C/El5adUZiQWZ8QXleakFh9ilOBgVhLh/fMYqJw3JbGyKrUoHyYlzcGiJM6rpvXOT0ggPbEk NTs1tSC1CCYrw8GhJMH7HWSoYFFqempFWmZOCUKaiYMTZDgP0PDVIDW8xQWJucWZ6RD5U4yK UuK8/MJACQGQREZpHlwvLBW9YhQHekWY9z1IOw8wjcF1vwIazAQ0mE8B5OrikkSElFQDo+hJ lomBsqpXDGvmhEycfn7zrxBVe7+Eu0YTludN05/NPPnihmAJl7JbR8MnTj5ZuXJ1ZZ2i9cR9 997UT3mWmCP1886TWf8XdIvNY5vjvXGl6+VvqWVJcdxa+ddX5X307lr37PraqU+uTL38hUVT 6KHNfkb/aTMD8mYWVaQU9dY2qCbmTA0IXq/EUpyRaKjFXFScCAABk71WIAMAAA== Cc: Notmuch Mail X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2012 17:57:34 -0000 Quoth Jani Nikula on Apr 12 at 8:02 am: > On Wed, 11 Apr 2012 17:11:13 -0400, Austin Clements wrote: > > On Mon, 09 Apr 2012, Jani Nikula wrote: > > > Vladimir Marek writes: > > > I'm throwing in a third alternative below. Does it work for you? I think > > > it's both prettier and uglier than the above at the same time! ;) > > > > > > A middle ground would be to change the callers to use > > > "notmuch_talloc_steal", and just #define notmuch_talloc_steal > > > talloc_steal if __GNUC__ >= 3. > > > > > > One could argue upstream talloc should have this, but OTOH it's a C > > > library. > > > > > > BR, > > > Jani. > > > > > > > > > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h > > > index ea836f7..83b46e8 100644 > > > --- a/lib/notmuch-private.h > > > +++ b/lib/notmuch-private.h > > > @@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx, > > > > > > NOTMUCH_END_DECLS > > > > > > +#ifdef __cplusplus > > > +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in > > > + * C++. In talloc_steal, an explicit cast is provided for type safety > > > + * in some GCC versions. Otherwise, a cast is required. Provide a > > > + * template function for this to maintain type safety, and redefine > > > + * talloc_steal to use it. > > > + */ > > > +#if !(__GNUC__ >= 3) > > > +template > > > +T *notmuch_talloc_steal(const void *new_ctx, const T *ptr) > > > +{ > > > + return static_cast(talloc_steal(new_ctx, ptr)); > > > +} > > > +#undef talloc_steal > > > +#define talloc_steal notmuch_talloc_steal > > > +#endif > > > +#endif > > > + > > > #endif > > > > This looks good to me. I was originally concerned that this depended on > > talloc_steal being a macro, but I realized that's not actually the case. > > Care to roll a real patch? > > Sure. > > One question: the template must be outside NOTMUCH_{BEGIN,END}_DECLS > (which are just macros for extern "C" block) but should it be within the > #pragma GCC visibility push(hidden) and pop directives? I'm not familiar > with that. Hmm. I'm not sure, but it can't hurt to have it inside the visibility directives. My guess would be that it will affect the visibility of the symbols produced when the template is instantiated, which we don't want to be visible outside the library. (As long as that doesn't mess up the linker's handling of weak symbols.) > Thanks for the review. > > > BR, > Jani.