Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-05-29 15:49:39 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-05-29 15:49:39 +0400
commit9e05f6571f824bd4a99bb4fe5af5ec15688a9649 (patch)
tree258cb4a162bdcad89b4cdbf5d5f86ad352ebd999 /source
parente99801dc706b7ff4cea0656e408c20835638dd6b (diff)
Make sure bool will always have the same size in C and C++
There were an issues with data structures defined in headers and being used by both C and C++ on systems with stdbool unavailable. This happened because bool in this case will be defined as unsigned int, which is 4 bytes. But C++'s bool is only 1 byte and this lead to alignment issues. Now bool is always 1 byte, also made sure there's no situation like bool foo = BitField & BitFlag, which could give overflow issues. Use (BitField & BitFlag) != 0 instead. Fixes #35553: Compositor broken (Backdrop & Preview)
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_sys_types.h7
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c2
-rw-r--r--source/blender/editors/animation/anim_draw.c6
-rw-r--r--source/blender/editors/interface/interface_widgets.c4
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c2
-rw-r--r--source/blender/imbuf/intern/png.c2
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c2
9 files changed, 13 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_sys_types.h b/source/blender/blenlib/BLI_sys_types.h
index 9c72433a415..7a7da5c097b 100644
--- a/source/blender/blenlib/BLI_sys_types.h
+++ b/source/blender/blenlib/BLI_sys_types.h
@@ -119,11 +119,8 @@ typedef uint64_t u_int64_t;
# ifdef __cplusplus
typedef bool _BLI_Bool;
# else
-/* using char here may cause nasty tricky bugs, e.g.
- * bool is_bit_flag = RNA_property_flag(prop) & PROP_ENUM_FLAG;
- * as PROP_ENUM_FLAG is farther than 8th bit, do_translate would be always false!
- */
-# define _BLI_Bool unsigned int
+/* Make sure bool is alays defined with the same size for both C and C++ */
+# define _BLI_Bool unsigned char
# endif
# else
# define _BLI_Bool _Bool
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 6502346d88a..79dacaad2fa 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -573,7 +573,7 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
bool is_any_error = 0;
for (i = 0; i < 3; i++) {
- const bool is_dirty = (flag_types[i] & bm->elem_index_dirty);
+ const bool is_dirty = (flag_types[i] & bm->elem_index_dirty) != 0;
int index = 0;
bool is_error = false;
int err_val = 0;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 12acc85e443..2e580a57a01 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -399,9 +399,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt)
{
/* mapping factor is stored in f1, flags are stored in i1 */
- const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS);
- const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS);
- const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS);
+ const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS) != 0;
+ const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS) != 0;
+ const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS) != 0;
float fac = ked->f1;
/* adjust BezTriple handles only if allowed to */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index bbc528a0a18..c8062cd3ed2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3411,7 +3411,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (wt) {
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
int roundboxalign, state;
- bool disabled = FALSE;
+ bool disabled = false;
roundboxalign = widget_roundbox_set(but, rect);
@@ -3420,7 +3420,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
if (but->dt != UI_EMBOSSP)
- disabled = TRUE;
+ disabled = true;
if (disabled)
ui_widget_color_disabled(wt);
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 34ce81c3af8..0b1f244a1b5 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -258,7 +258,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
World *wrld = NULL;
Brush *brush = NULL;
ID *pinid = sbuts->pinid;
- bool limited_mode = sbuts->flag & SB_TEX_USER_LIMITED;
+ bool limited_mode = (sbuts->flag & SB_TEX_USER_LIMITED) != 0;
/* get data from context */
if (pinid) {
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 5957f743665..642b1b936c4 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -1086,7 +1086,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly)
#if 0
bool do_rotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == false);
- bool do_translate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM));
+ bool do_translate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)) != 0;
#endif
bool do_rotate = (fly->pan_view == false);
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index a7e05612472..e07eef1868e 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -132,7 +132,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY;
FILE *fp = NULL;
- bool is_16bit = (ibuf->ftype & PNG_16BIT);
+ bool is_16bit = (ibuf->ftype & PNG_16BIT) != 0;
bool has_float = (ibuf->rect_float != NULL);
int channels_in_float = ibuf->channels ? ibuf->channels : 4;
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 9b0d6c136fd..7cd10491c89 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -110,7 +110,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
MDeformVert *dvert = NULL;
BevelModifierData *bmd = (BevelModifierData *) md;
const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f);
- const bool vertex_only = bmd->flags & BME_BEVEL_VERT;
+ const bool vertex_only = (bmd->flags & BME_BEVEL_VERT) != 0;
const bool do_clamp = !(bmd->flags & BME_BEVEL_OVERLAP_OK);
bm = DM_to_bmesh(dm);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 517b30467ce..d35121e8ae5 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -472,7 +472,7 @@ void RE_FreePersistentData(void)
/* disprect is optional, if NULL it assumes full window render */
void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *srl, int winx, int winy, rcti *disprect)
{
- bool had_freestyle = (re->r.mode & R_EDGE_FRS);
+ bool had_freestyle = (re->r.mode & R_EDGE_FRS) != 0;
re->ok = TRUE; /* maybe flag */