mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-23 08:00:17 +00:00
model: fix const correctness of ConstBrushModel internals
Couldn't find a neat way to make the container_of macro const agnostic, so just have a const and non-const version. Silences a bunch of -Wcast-qual warnings so that real problems are easier to spot. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
979342e2de
commit
580204e255
@ -471,7 +471,7 @@ static inline const brushmodel_t *
|
||||
ConstBrushModel(const model_t *model)
|
||||
{
|
||||
assert(model && model->type == mod_brush);
|
||||
return container_of(model, brushmodel_t, model);
|
||||
return const_container_of(model, brushmodel_t, model);
|
||||
}
|
||||
|
||||
static inline brushmodel_t *
|
||||
|
@ -45,7 +45,11 @@ typedef enum { false, true } qboolean;
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#define const_container_of(ptr, type, member) ({ \
|
||||
typeof( ((const type *)0)->member ) *__mptr = (ptr); \
|
||||
(const type *)( (const char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#endif /* QTYPES_H */
|
||||
|
Loading…
Reference in New Issue
Block a user