From f23be49188cec903446bea97261c3ea3774dea28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 Aug 2006 01:27:22 +0000 Subject: r17645: gcc 4.1.x has started producing "value computed is not used" warnings in very annoying ways for talloc_steal. This rather strange looking cpp approach avoids these warnings. It's really a problem in gcc, but better to do this than put up with the huge flood of warnings. (This used to be commit 8236a0ac5e80c30e52fccc0ef41a6c808ea43420) --- source4/lib/talloc/talloc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index c6d20c820f..b873bdb8aa 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -62,10 +62,14 @@ typedef void TALLOC_CTX; _talloc_set_destructor((ptr), (void *)_talloc_destructor_fn); \ } while(0) #define _TALLOC_CHECK_TYPE(type,val) +/* this extremely strange macro is to avoid some braindamaged warning + stupidity in gcc 4.1.x */ +#define talloc_steal(ctx, ptr) ({ __typeof__(ptr) __talloc_steal_ret = (__typeof__(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) #else #define talloc_set_destructor(ptr, function) \ _talloc_set_destructor((ptr), (int (*)(void *))(function)) #define _TALLOC_TYPEOF(ptr) void * +#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) #endif /* useful macros for creating type checked pointers */ @@ -90,7 +94,6 @@ typedef void TALLOC_CTX; #define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) #define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) #if TALLOC_DEPRECATED #define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -- cgit