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 7F44A431FAF for ; Thu, 12 Apr 2012 01:02:29 -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 4GpkA7WFyGZ9 for ; Thu, 12 Apr 2012 01:02:21 -0700 (PDT) Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 778A8431FAE for ; Thu, 12 Apr 2012 01:02:21 -0700 (PDT) Received: by qcsk26 with SMTP id k26so1328663qcs.26 for ; Thu, 12 Apr 2012 01:02:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:x-gm-message-state; bh=DRB71CSZOX2WgFOFU4c+gC7k1b/2jSlhJMRtQ4ltaGE=; b=YqFJpcR9XrrGL58AO1LsONVbna6kvdjr8IJTrosleT1SONaK8xiCHrxNCDXqXeJwZM yHOyzJks+h2IMVKyVAr/EkOENl5YWXgnTJProH0HyMFLqDk0pQiFKjLBq16570bLf+qO 8PcGbKv+p8MiQtEgCU5Cpm7r5opfJAvACqPwLJL72gMrXHemI/ge/ygznvDXMjJudD6d xXWesY8e6CZETLBGN1qZ+tOsbyYrAsbqtSAF528P8vyknQvcY8hmG9Go402C+H+Qykbq tIytdsVucnU3K5LJl5ZIQIgYehkhRv2WwHY15byxIXvMy8nb+zAuReI7eaOPIPA1hoVA UacQ== Received: by 10.224.221.75 with SMTP id ib11mr2610027qab.21.1334217739927; Thu, 12 Apr 2012 01:02:19 -0700 (PDT) Received: from localhost ([92.243.24.172]) by mx.google.com with ESMTPS id cs10sm10466237qab.8.2012.04.12.01.02.17 (version=SSLv3 cipher=OTHER); Thu, 12 Apr 2012 01:02:18 -0700 (PDT) From: Jani Nikula To: Austin Clements , Vladimir Marek , Notmuch Mail Subject: Re: [PATCH 4/4] Explicitly type void* pointers In-Reply-To: <87vcl6nfda.fsf@awakening.csail.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> User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1 (i686-pc-linux-gnu) Date: Thu, 12 Apr 2012 08:02:12 +0000 Message-ID: <87aa2hxtrv.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQl3XkMe5Epw3Hd9TfIVATcin2Ntgpcu1FQ4n7AcqDB0tcYSs+bEG23kBpsm3ON0d/DCWvvn 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 08:02:29 -0000 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. Thanks for the review. BR, Jani.