Rewrite casting to be more safe.
This commit is contained in:
1 parent
6c888f9b68
commit
bf9714e00a
1 file changed
+1
-3
+1
-3
@@ -84,11 +84,9 @@
|
||||
/*
|
||||
* From a pointer to a 'field_type' 'field' of a 'type'structure,
|
||||
* return pointer to the structure.
|
||||
* Note: Lot of cast. Can be unsafe.
|
||||
*/
|
||||
#define ILISTI_TYPE_FROM_FIELD(type, ptr, field_type, field) \
|
||||
( ( (void)((ptr) == (field_type*)(ptr))) , \
|
||||
((type *)(void*)( (char *)(ptr) - offsetof(type, field) )) )
|
||||
((type *)(void*)( (char *)M_ASSIGN_CAST(field_type*, (ptr)) - offsetof(type, field) ))
|
||||
|
||||
#define ILISTI_DEF2(name, type, oplist, check_instance) \
|
||||
typedef struct M_C3(ilist_head_, name, _s) M_C3(ilist_, name, _t)[1]; \
|
||||
|
||||
Reference in new issue
Block a user