From 6d12bc9e918d47f39135750f9d99f901f88efc44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Apr 2022 14:25:58 +1000 Subject: Cleanup: use boolean arguments and return values --- source/blender/blenkernel/BKE_particle.h | 12 +++++------ source/blender/blenkernel/intern/particle.c | 12 +++++------ source/blender/blenkernel/intern/pointcache.c | 17 +++++++-------- .../blender/editors/sculpt_paint/paint_vertex.cc | 2 +- source/blender/geometry/intern/uv_parametrizer.c | 2 +- source/blender/imbuf/intern/rectop.c | 6 +++--- source/blender/imbuf/intern/scaling.c | 22 +++++++++----------- source/blender/python/BPY_extern.h | 2 +- source/blender/python/intern/bpy_app_handlers.c | 2 +- source/blender/render/intern/pipeline.c | 24 +++++++++++----------- 10 files changed, 50 insertions(+), 51 deletions(-) diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index b622d7ba85c..123fdbb8bac 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -391,12 +391,12 @@ void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, bool editupdate, bool use_render_params); -int do_guides(struct Depsgraph *depsgraph, - struct ParticleSettings *part, - struct ListBase *effectors, - ParticleKey *state, - int index, - float time); +bool do_guides(struct Depsgraph *depsgraph, + struct ParticleSettings *part, + struct ListBase *effectors, + ParticleKey *state, + int index, + float time); void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors); float psys_get_timestep(struct ParticleSimulationData *sim); float psys_get_child_time(struct ParticleSystem *psys, diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index cc4738b1faa..bbb08155bfc 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2390,12 +2390,12 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) } } -int do_guides(Depsgraph *depsgraph, - ParticleSettings *part, - ListBase *effectors, - ParticleKey *state, - int index, - float time) +bool do_guides(Depsgraph *depsgraph, + ParticleSettings *part, + ListBase *effectors, + ParticleKey *state, + int index, + float time) { CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d5d304343df..34720bf7d6b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1399,7 +1399,8 @@ static size_t ptcache_filename_ext_append(PTCacheID *pid, return len; } -static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext) +static int ptcache_filename( + PTCacheID *pid, char *filename, int cfra, const bool do_path, const bool do_ext) { int len = 0; char *idname; @@ -1464,7 +1465,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) } } - ptcache_filename(pid, filename, cfra, 1, 1); + ptcache_filename(pid, filename, cfra, true, true); if (mode == PTCACHE_FILE_READ) { fp = BLI_fopen(filename, "rb"); @@ -2630,7 +2631,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) return; } - len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */ + len = ptcache_filename(pid, filename, cfra, false, false); /* no path */ /* append underscore terminator to ensure we don't match similar names * from objects whose names start with the same prefix */ @@ -2712,7 +2713,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) case PTCACHE_CLEAR_FRAME: if (pid->cache->flag & PTCACHE_DISK_CACHE) { if (BKE_ptcache_id_exist(pid, cfra)) { - ptcache_filename(pid, filename, cfra, 1, 1); /* no path */ + ptcache_filename(pid, filename, cfra, true, true); /* no path */ BLI_delete(filename, false, false); } } @@ -2753,7 +2754,7 @@ bool BKE_ptcache_id_exist(PTCacheID *pid, int cfra) if (pid->cache->flag & PTCACHE_DISK_CACHE) { char filename[MAX_PTCACHE_FILE]; - ptcache_filename(pid, filename, cfra, 1, 1); + ptcache_filename(pid, filename, cfra, true, true); return BLI_exists(filename); } @@ -3500,7 +3501,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c /* get "from" filename */ BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name)); - len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */ + len = ptcache_filename(pid, old_filename, 0, false, false); /* no path */ ptcache_path(pid, path); dir = opendir(path); @@ -3522,7 +3523,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c if (frame != -1) { BLI_join_dirfile(old_path_full, sizeof(old_path_full), path, de->d_name); - ptcache_filename(pid, new_path_full, frame, 1, 1); + ptcache_filename(pid, new_path_full, frame, true, true); BLI_rename(old_path_full, new_path_full); } } @@ -3555,7 +3556,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) ptcache_path(pid, path); - len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */ + len = ptcache_filename(pid, filename, 1, false, false); /* no path */ dir = opendir(path); if (dir == NULL) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 1ae9f7a8afb..5aeacb15e00 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -412,7 +412,7 @@ static float wpaint_blend(const VPaint *wp, const float alpha, float paintval, const float UNUSED(brush_alpha_value), - const short do_flip) + const bool do_flip) { const Brush *brush = wp->paint.brush; IMB_BlendMode blend = (IMB_BlendMode)brush->blend; diff --git a/source/blender/geometry/intern/uv_parametrizer.c b/source/blender/geometry/intern/uv_parametrizer.c index dd97a996b18..e25fff0d6b8 100644 --- a/source/blender/geometry/intern/uv_parametrizer.c +++ b/source/blender/geometry/intern/uv_parametrizer.c @@ -203,7 +203,7 @@ typedef struct PHandle { RNG *rng; float blend; - char do_aspect; + bool do_aspect; } PHandle; /* PHash diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index cb1c5ea2e8d..2f864534d61 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -515,7 +515,7 @@ void IMB_rectblend(ImBuf *dbuf, const unsigned short *cmaskrect = curvemask, *cmr; unsigned short *dmaskrect = dmask, *dmr; const unsigned short *texmaskrect = texmask, *tmr; - int do_float, do_char, srcskip, destskip, origskip, x; + int srcskip, destskip, origskip, x; IMB_blend_func func = NULL; IMB_blend_func_float func_float = NULL; @@ -535,8 +535,8 @@ void IMB_rectblend(ImBuf *dbuf, return; } - do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect); - do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float); + const bool do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect); + const bool do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float); if (do_char) { drect = dbuf->rect + ((size_t)desty) * dbuf->x + destx; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index afb0845c23b..f4abc668402 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -171,14 +171,13 @@ static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) uchar *p1, *p2, *_p1, *dest; short a, r, g, b; int x, y; - int do_rect, do_float; float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf; p1 = p2 = NULL; p1f = p2f = NULL; - do_rect = (ibuf1->rect != NULL); - do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL); + const bool do_rect = (ibuf1->rect != NULL); + const bool do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL); _p1 = (uchar *)ibuf1->rect; dest = (uchar *)ibuf2->rect; @@ -264,7 +263,6 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) int *p1, *dest1, *dest2; float *p1f, *dest1f, *dest2f; int x, y; - int do_rect, do_float; if (ibuf1 == NULL) { return NULL; @@ -273,8 +271,8 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) return NULL; } - do_rect = (ibuf1->rect != NULL); - do_float = (ibuf1->rect_float != NULL); + const bool do_rect = (ibuf1->rect != NULL); + const bool do_float = (ibuf1->rect_float != NULL); ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags); if (ibuf2 == NULL) { @@ -358,8 +356,8 @@ MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsign void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) { int x, y; - const short do_rect = (ibuf1->rect != NULL); - const short do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL); + const bool do_rect = (ibuf1->rect != NULL); + const bool do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL); if (do_rect && (ibuf2->rect == NULL)) { imb_addrectImBuf(ibuf2); @@ -892,8 +890,8 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) { - const int do_rect = (ibuf->rect != NULL); - const int do_float = (ibuf->rect_float != NULL); + const bool do_rect = (ibuf->rect != NULL); + const bool do_float = (ibuf->rect_float != NULL); const size_t rect_size = IMB_get_rect_len(ibuf) * 4; uchar *rect, *_newrect, *newrect; @@ -1033,8 +1031,8 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) { - const int do_rect = (ibuf->rect != NULL); - const int do_float = (ibuf->rect_float != NULL); + const bool do_rect = (ibuf->rect != NULL); + const bool do_float = (ibuf->rect_float != NULL); const size_t rect_size = IMB_get_rect_len(ibuf) * 4; uchar *rect, *_newrect, *newrect; diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index c052fc0e8da..0ab26fde34f 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -67,7 +67,7 @@ void BPY_text_free_code(struct Text *text); void BPY_modules_update(void); void BPY_modules_load_user(struct bContext *C); -void BPY_app_handlers_reset(short do_all); +void BPY_app_handlers_reset(bool do_all); /** * Update function, it gets rid of python-drivers global dictionary: `bpy.app.driver_namespace`, diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 319ca7baea1..bf427d9639a 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -244,7 +244,7 @@ PyObject *BPY_app_handlers_struct(void) return ret; } -void BPY_app_handlers_reset(const short do_all) +void BPY_app_handlers_reset(const bool do_all) { PyGILState_STATE gilstate; int pos = 0; diff --git a/source/blender/render/intern/pipeline.c b/source/blender/render/intern/pipeline.c index cf400bdfc77..6c06cd663fa 100644 --- a/source/blender/render/intern/pipeline.c +++ b/source/blender/render/intern/pipeline.c @@ -155,12 +155,12 @@ static void render_callback_exec_id(Render *re, Main *bmain, ID *id, eCbEvent ev /** \name Allocation & Free * \{ */ -static int do_write_image_or_movie(Render *re, - Main *bmain, - Scene *scene, - bMovieHandle *mh, - const int totvideos, - const char *name_override); +static bool do_write_image_or_movie(Render *re, + Main *bmain, + Scene *scene, + bMovieHandle *mh, + const int totvideos, + const char *name_override); /* default callbacks, set in each new render */ static void result_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr)) @@ -2020,12 +2020,12 @@ bool RE_WriteRenderViewsMovie(ReportList *reports, return ok; } -static int do_write_image_or_movie(Render *re, - Main *bmain, - Scene *scene, - bMovieHandle *mh, - const int totvideos, - const char *name_override) +static bool do_write_image_or_movie(Render *re, + Main *bmain, + Scene *scene, + bMovieHandle *mh, + const int totvideos, + const char *name_override) { char name[FILE_MAX]; RenderResult rres; -- cgit v1.2.3