Cleanup: fixes for building with recent clang

This commit is contained in:
2015-01-14 05:10:18 +11:00
parent ef80914c99
commit b09563ca8c
17 changed files with 45 additions and 38 deletions

View File

@@ -3327,7 +3327,7 @@ static void dm_debug_info_layers(DynStr *dynstr, DerivedMesh *dm, CustomData *cd
CustomData_file_write_info(type, &structname, &structnum);
BLI_dynstr_appendf(dynstr,
" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
name, structname, type, (void *)pt, size, pt_size);
name, structname, type, (const void *)pt, size, pt_size);
}
}
}
@@ -3391,7 +3391,7 @@ void DM_debug_print(DerivedMesh *dm)
void DM_debug_print_cdlayers(CustomData *data)
{
int i;
CustomDataLayer *layer;
const CustomDataLayer *layer;
printf("{\n");
@@ -3403,7 +3403,7 @@ void DM_debug_print_cdlayers(CustomData *data)
int structnum;
CustomData_file_write_info(layer->type, &structname, &structnum);
printf(" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
name, structname, layer->type, (void *)layer->data, size, (int)(MEM_allocN_len(layer->data) / size));
name, structname, layer->type, (const void *)layer->data, size, (int)(MEM_allocN_len(layer->data) / size));
}
printf("}\n");

View File

@@ -262,8 +262,8 @@ void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst)
{
ModifierTypeInfo *mti = modifierType_getInfo(md_src->type);
const size_t data_size = sizeof(ModifierData);
const char *md_src_data = ((char *)md_src) + data_size;
char *md_dst_data = ((char *)md_dst) + data_size;
const char *md_src_data = ((const char *)md_src) + data_size;
char *md_dst_data = ((char *)md_dst) + data_size;
BLI_assert(data_size <= (size_t)mti->structSize);
memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
}

View File

@@ -1059,8 +1059,9 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
const MDisps *md = &mdisps[mpoly[i].loopstart + j];
int hidden_gridsize = BKE_ccg_gridsize(md->level);
int factor = BKE_ccg_factor(level, md->level);
BLI_bitmap *hidden = md->hidden;
if (!md->hidden)
if (!hidden)
continue;
for (y = 0; y < gridSize; y++) {
@@ -1069,7 +1070,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
offset = (y * factor) * hidden_gridsize + (x * factor);
if (BLI_BITMAP_TEST(md->hidden, offset))
if (BLI_BITMAP_TEST(hidden, offset))
mvert[vndx].flag |= ME_HIDE;
}
}

View File

@@ -66,23 +66,23 @@ typedef unsigned int BLI_bitmap;
/* get the value of a single bit at '_index' */
#define BLI_BITMAP_TEST(_bitmap, _index) \
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
(CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] & \
(1u << ((_index) & _BITMAP_MASK))))
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index) \
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
(CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \
(BLI_BITMAP_TEST(_bitmap, _index) != 0))
/* set the value of a single bit at '_index' */
#define BLI_BITMAP_ENABLE(_bitmap, _index) \
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
(CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] |= \
(1u << ((_index) & _BITMAP_MASK))))
/* clear the value of a single bit at '_index' */
#define BLI_BITMAP_DISABLE(_bitmap, _index) \
(CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
(CHECK_TYPE_ANY(_bitmap, BLI_bitmap *, const BLI_bitmap *), \
((_bitmap)[(_index) >> _BITMAP_POWER] &= \
~(1u << ((_index) & _BITMAP_MASK))))

View File

@@ -124,17 +124,17 @@ bool BLI_ghashutil_ptrcmp(const void *a, const void *b);
unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n);
#define BLI_ghashutil_strhash(key) ( \
CHECK_TYPE_INLINE(key, char *), \
CHECK_TYPE_ANY(key, char *, const char *, const char * const), \
BLI_ghashutil_strhash_p(key))
unsigned int BLI_ghashutil_strhash_p(const void *key);
bool BLI_ghashutil_strcmp(const void *a, const void *b);
#define BLI_ghashutil_inthash(key) ( \
CHECK_TYPE_INLINE(&(key), int *), \
CHECK_TYPE_ANY(&(key), int *, const int *), \
BLI_ghashutil_uinthash((unsigned int)key))
unsigned int BLI_ghashutil_uinthash(unsigned int key);
#define BLI_ghashutil_inthash_v4(key) ( \
CHECK_TYPE_INLINE(key, int *), \
CHECK_TYPE_ANY(key, int *, const int *), \
BLI_ghashutil_uinthash_v4((const unsigned int *)key))
unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]);
#define BLI_ghashutil_inthash_v4_p \

View File

@@ -436,8 +436,8 @@ extern "C" {
/* assuming a static array */
#if defined(__GNUC__) && !defined(__cplusplus)
# define ARRAY_SIZE(arr) \
((sizeof(struct {int isnt_array : ((void *)&(arr) == &(arr)[0]);}) * 0) + \
# define ARRAY_SIZE(arr) \
((sizeof(struct {int isnt_array : ((const void *)&(arr) == &(arr)[0]);}) * 0) + \
(sizeof(arr) / sizeof(*(arr))))
#else
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))

View File

@@ -97,7 +97,7 @@ static GSet *erot_gset_new(void)
static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2])
{
BLI_assert(BM_edge_is_manifold((BMEdge *)e));
BLI_assert(BM_edge_is_manifold(e));
BLI_assert(BM_vert_in_edge(e, e->l->prev->v) == false);
BLI_assert(BM_vert_in_edge(e, e->l->radial_next->prev->v) == false);

View File

@@ -857,7 +857,7 @@ bool BM_mesh_intersect(
{UNPACK3(looptris[i][2]->v->co)},
};
BLI_bvhtree_insert(tree_a, i, (float *)t_cos, 3);
BLI_bvhtree_insert(tree_a, i, (const float *)t_cos, 3);
}
}
BLI_bvhtree_balance(tree_a);
@@ -874,7 +874,7 @@ bool BM_mesh_intersect(
{UNPACK3(looptris[i][2]->v->co)},
};
BLI_bvhtree_insert(tree_b, i, (float *)t_cos, 3);
BLI_bvhtree_insert(tree_b, i, (const float *)t_cos, 3);
}
}
BLI_bvhtree_balance(tree_b);

View File

@@ -56,14 +56,20 @@ void cpack(unsigned int x);
# define glMultMatrixf(x) \
glMultMatrixf(_Generic((x), \
float *: (float *)(x), \
float [16]: (float *)(x), \
float (*)[4]: (float *)(x), \
float [4][4]: (float *)(x), \
const float *: (float *)(x), \
const float (*)[4]: (float *)(x)) \
const float [16]: (float *)(x), \
const float (*)[4]: (float *)(x), \
const float [4][4]: (float *)(x)) \
)
# define glLoadMatrixf(x) \
glLoadMatrixf(_Generic((x), \
float *: (float *)(x), \
float (*)[4]: (float *)(x)) \
float [16]: (float *)(x), \
float (*)[4]: (float *)(x), \
float [4][4]: (float *)(x)) \
)
#else
# define glMultMatrixf(x) glMultMatrixf((float *)(x))

View File

@@ -1334,7 +1334,7 @@ static float project_paint_uvpixel_mask(
/* now we can use the normal as a mask */
if (ps->is_ortho) {
angle = angle_normalized_v3v3((float *)ps->viewDir, no);
angle = angle_normalized_v3v3(ps->viewDir, no);
}
else {
/* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */

View File

@@ -96,11 +96,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
static int vergname(const void *v1, const void *v2)
{
char **x1, **x2;
x1 = (char **)v1;
x2 = (char **)v2;
const char * const *x1 = v1, * const *x2 = v2;
return BLI_natstrcmp(*x1, *x2);
}

View File

@@ -4751,7 +4751,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
TransData2D *td2d = NULL;
TransDataSeq *tdsq = NULL;
TransSeq *ts = NULL;
float xmouse, ymouse;
int xmouse;
int count = 0;
@@ -4762,7 +4762,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
t->customFree = freeSeqData;
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
xmouse = (int)UI_view2d_region_to_view_x(v2d, t->imval[0]);
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {

View File

@@ -3402,8 +3402,8 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
static int p_compare_geometric_uv(const void *a, const void *b)
{
const PVert *v1 = *(const PVert **)a;
const PVert *v2 = *(const PVert **)b;
const PVert *v1 = *(const PVert * const *)a;
const PVert *v2 = *(const PVert * const *)b;
if (v1->uv[0] < v2->uv[0])
return -1;
@@ -3788,11 +3788,14 @@ static PBool p_node_intersect(SmoothNode *node, float co[2])
/* smoothing */
static int p_compare_float(const void *a, const void *b)
static int p_compare_float(const void *a_, const void *b_)
{
if (*((float *)a) < *((float *)b))
const float a = *(const float *)a_;
const float b = *(const float *)b_;
if (a < b)
return -1;
else if (*((float *)a) == *((float *)b))
else if (a == b)
return 0;
else
return 1;

View File

@@ -535,6 +535,7 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
namespace OGF {
#if 0
inline static real angle(WOEdge *h)
{
const Vec3r& n1 = h->GetbFace()->GetNormal();
@@ -549,6 +550,7 @@ inline static real angle(WOEdge *h)
}
return ::asin(sine);
}
#endif
// precondition1: P is inside the sphere
// precondition2: P,V points to the outside of the sphere (i.e. OP.V > 0)

View File

@@ -243,8 +243,7 @@ typedef struct PreviewImage {
#ifdef GS
# undef GS
#endif
// #define GS(a) (*((short *)(a)))
#define GS(a) (CHECK_TYPE_INLINE(a, char *), (*((short *)(a))))
#define GS(a) (CHECK_TYPE_ANY(a, char *, const char *, char [66], const char[66]), (*((const short *)(a))))
#define ID_NEW(a) if ( (a) && (a)->id.newid ) (a) = (void *)(a)->id.newid
#define ID_NEW_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; }

View File

@@ -1628,7 +1628,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
int i;
if (eprop->item) {
if (eprop->item && eprop->totitem) {
fprintf(f, "enum {\n");
for (i = 0; i < eprop->totitem; i++)

View File

@@ -541,7 +541,7 @@ void WM_event_print(const wmEvent *event)
event->shift, event->ctrl, event->alt, event->oskey, event->keymodifier,
event->x, event->y, event->ascii,
BLI_str_utf8_size(event->utf8_buf), event->utf8_buf,
event->keymap_idname, (void *)event);
event->keymap_idname, (const void *)event);
if (ISNDOF(event->type)) {
const wmNDOFMotionData *ndof = event->customdata;