From 6ec60c976f6fa990ed1c7efa0ceb7e7634d163c7 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 19 Aug 2011 03:01:16 +0300 Subject: talloc.[ch]: remove "type safety" hack that violates C types The destructors used by talloc take a "void *" first parameter. However talloc.h had a #define hack that treated the destructor as a function taking first parameter of type "typeof(ptr)" where ptr is the pointer the destructor is set for. I suppose this was done to add some kind of "type safety" against adding a destructor expecting another type of pointer; however this hack is questionable and violates the real C level typing. Remove the hack from the header and adjust talloc.c to avoid a warning about a C type violation that became visible after removing the hack. --- talloc.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'talloc.h') diff --git a/talloc.h b/talloc.h index 8c6d405040..b60e0fb040 100644 --- a/talloc.h +++ b/talloc.h @@ -70,20 +70,15 @@ typedef void TALLOC_CTX; if we have a recent gcc */ #if (__GNUC__ >= 3) #define _TALLOC_TYPEOF(ptr) __typeof__(ptr) -#define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) /* this extremely strange macro is to avoid some braindamaged warning stupidity in gcc 4.1.x */ #define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_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 +#define talloc_set_destructor(ptr, function) \ + _talloc_set_destructor((ptr), (function)) #define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) #define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) -- cgit v1.2.3