Re: [PATCH 4/4] Explicitly type void* pointers

Subject: Re: [PATCH 4/4] Explicitly type void* pointers

Date: Mon, 9 Apr 2012 20:15:43 +0200

To: Notmuch Mail

Cc:

From: Vladimir Marek


Hi,

> Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
> that's supposed to provide type safety (at least with GCC), and I'd be
> hesitant about adding the casts. Please look in your talloc.h.

It does not compile. It might be that I'm using Sun/Oracle CC instead of
gcc. The error looks like this:

"lib/database.cc", line 1368: Error: Cannot assign void* to const char*.


When looking into talloc documentation, the definition seems to be:

void* talloc_steal ( const void * new_ctx, const void * ptr )

http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c


When looking into talloc.h, it says:

/* try to make talloc_set_destructor() and talloc_steal() type safe,
   if we have a recent gcc */

So, maybe the way to satisfy everyone would be:

notmuch_message_t *tmp_message = message;
talloc_steal(notmuch, tmp_message);
return(tmp_message);

Or alternatively,

#if (__GNUC__ >= 3)
       return talloc_steal (notmuch, message);
#else
       return (notmuch_message_t*) talloc_steal (notmuch, message);
#fi


Of course I'm happy either way :)

Thank you
-- 
	Vlad

Thread: