From aa03383838dbe062c91ba4860807c57eefd27fa1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 May 2024 13:07:02 +1000 Subject: [PATCH] Cleanup: resolve cppcheck funcArgNamesDifferent warnings in blenlib --- source/blender/blenlib/BLI_args.h | 2 +- source/blender/blenlib/BLI_array_utils.h | 6 +- source/blender/blenlib/BLI_buffer.h | 2 +- source/blender/blenlib/BLI_fileops.h | 6 +- source/blender/blenlib/BLI_kdtree_impl.h | 7 +- source/blender/blenlib/BLI_math_geom.h | 24 +++---- source/blender/blenlib/BLI_memiter.h | 4 +- source/blender/blenlib/BLI_scanfill.h | 4 +- source/blender/blenlib/BLI_string.h | 4 +- .../blenlib/intern/BLI_mempool_private.h | 2 +- source/blender/blenlib/intern/fileops_c.cc | 22 +++---- .../blenlib/intern/length_parameterize.cc | 12 ++-- source/blender/blenlib/intern/listbase.cc | 12 ++-- source/blender/blenlib/intern/math_geom.cc | 64 +++++++++---------- source/blender/blenlib/intern/string.c | 18 +++--- 15 files changed, 97 insertions(+), 92 deletions(-) diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h index 50a4ed54468..1c96fb38978 100644 --- a/source/blender/blenlib/BLI_args.h +++ b/source/blender/blenlib/BLI_args.h @@ -62,7 +62,7 @@ void BLI_args_add_case(struct bArgs *ba, BA_ArgCallback cb, void *data); -void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data); +void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data); void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg); void BLI_args_print_other_doc(struct bArgs *ba); diff --git a/source/blender/blenlib/BLI_array_utils.h b/source/blender/blenlib/BLI_array_utils.h index 191e2a3e96e..951e4245db1 100644 --- a/source/blender/blenlib/BLI_array_utils.h +++ b/source/blender/blenlib/BLI_array_utils.h @@ -21,7 +21,7 @@ extern "C" { * * Access via #BLI_array_reverse */ -void _bli_array_reverse(void *arr, uint arr_len, size_t arr_stride); +void _bli_array_reverse(void *arr_v, uint arr_len, size_t arr_stride); #define BLI_array_reverse(arr, arr_len) _bli_array_reverse(arr, arr_len, sizeof(*(arr))) /** @@ -30,7 +30,7 @@ void _bli_array_reverse(void *arr, uint arr_len, size_t arr_stride); * * Access via #BLI_array_wrap */ -void _bli_array_wrap(void *arr, uint arr_len, size_t arr_stride, int dir); +void _bli_array_wrap(void *arr_v, uint arr_len, size_t arr_stride, int dir); #define BLI_array_wrap(arr, arr_len, dir) _bli_array_wrap(arr, arr_len, sizeof(*(arr)), dir) /** @@ -128,7 +128,7 @@ bool _bli_array_iter_span(const void *arr, /** * Simple utility to check memory is zeroed. */ -bool _bli_array_is_zeroed(const void *arr, uint arr_len, size_t arr_stride); +bool _bli_array_is_zeroed(const void *arr_v, uint arr_len, size_t arr_stride); #define BLI_array_is_zeroed(arr, arr_len) _bli_array_is_zeroed(arr, arr_len, sizeof(*(arr))) /** diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h index a3e910af79b..c5cc8701604 100644 --- a/source/blender/blenlib/BLI_buffer.h +++ b/source/blender/blenlib/BLI_buffer.h @@ -78,7 +78,7 @@ void BLI_buffer_reinit(BLI_Buffer *buffer, size_t new_count); * * Callers use #BLI_buffer_append_array. */ -void _bli_buffer_append_array(BLI_Buffer *buffer, void *data, size_t count); +void _bli_buffer_append_array(BLI_Buffer *buffer, void *new_data, size_t count); #define BLI_buffer_append_array(buffer_, type_, data_, count_) \ { \ type_ *__tmp = (data_); \ diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 2c2cfe039ca..de5bc8dfc6a 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -213,7 +213,7 @@ bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); /** * \return true on success (i.e. given path now exists on FS), false otherwise. */ -bool BLI_dir_create_recursive(const char *dir) ATTR_NONNULL(); +bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL(); /** * Returns the number of free bytes on the volume containing the specified path. * @@ -248,12 +248,12 @@ bool BLI_change_working_dir(const char *dir); * \{ */ /** - * Scans the contents of the directory named `dir`, and allocates and fills in an + * Scans the contents of the directory named `dirname`, and allocates and fills in an * array of entries describing them in `r_filelist`. * * \return The length of `r_filelist` array. */ -unsigned int BLI_filelist_dir_contents(const char *dir, struct direntry **r_filelist); +unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist); /** * Deep-duplicate of a single direntry. */ diff --git a/source/blender/blenlib/BLI_kdtree_impl.h b/source/blender/blenlib/BLI_kdtree_impl.h index 9773b557892..bbbc83d1794 100644 --- a/source/blender/blenlib/BLI_kdtree_impl.h +++ b/source/blender/blenlib/BLI_kdtree_impl.h @@ -27,7 +27,10 @@ typedef struct KDTreeNearest { float co[KD_DIMS]; } KDTreeNearest; -KDTree *BLI_kdtree_nd_(new)(unsigned int maxsize); +/** + * \param nodes_len_capacity: The maximum length this KD-tree may hold. + */ +KDTree *BLI_kdtree_nd_(new)(unsigned int nodes_len_capacity); void BLI_kdtree_nd_(free)(KDTree *tree); void BLI_kdtree_nd_(balance)(KDTree *tree) ATTR_NONNULL(1); @@ -62,7 +65,7 @@ void BLI_kdtree_nd_(range_search_cb)( int BLI_kdtree_nd_(calc_duplicates_fast)(const KDTree *tree, float range, bool use_index_order, - int *doubles); + int *duplicates); int BLI_kdtree_nd_(deduplicate)(KDTree *tree); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index cba1d734ec7..add29287922 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -468,9 +468,9 @@ int isect_seg_seg_v2_point_ex(const float v0[2], const float v2[2], const float v3[2], float endpoint_bias, - float vi[2]); + float r_vi[2]); int isect_seg_seg_v2_point( - const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2]); + const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2]); bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], @@ -534,8 +534,8 @@ int isect_line_line_epsilon_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], - float i1[3], - float i2[3], + float r_i1[3], + float r_i2[3], float epsilon); int isect_line_line_v3(const float v1[3], const float v2[3], @@ -749,12 +749,12 @@ bool isect_tri_tri_v3(const float t_a0[3], float r_i1[3], float r_i2[3]); -bool isect_tri_tri_v2(const float p1[2], - const float q1[2], - const float r1[2], - const float p2[2], - const float q2[2], - const float r2[2]); +bool isect_tri_tri_v2(const float t_a0[2], + const float t_a1[2], + const float t_a2[2], + const float t_b0[2], + const float t_b1[2], + const float t_b2[2]); /** * Water-tight ray-cast (requires pre-calculation). @@ -865,7 +865,7 @@ void isect_ray_aabb_v3_precalc(struct IsectRayAABB_Precalc *data, bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], - float *tmin); + float *r_tmin); /** * Test a bounding box (AABB) for ray intersection. * Assumes the ray is already local to the boundbox space. @@ -1135,7 +1135,7 @@ void projmat_dimensions(const float winmat[4][4], float *r_top, float *r_near, float *r_far); -void projmat_dimensions_db(const float winmat[4][4], +void projmat_dimensions_db(const float winmat_fl[4][4], double *r_left, double *r_right, double *r_bottom, diff --git a/source/blender/blenlib/BLI_memiter.h b/source/blender/blenlib/BLI_memiter.h index ffdb3bd8365..91a8dfca86f 100644 --- a/source/blender/blenlib/BLI_memiter.h +++ b/source/blender/blenlib/BLI_memiter.h @@ -34,13 +34,13 @@ typedef struct BLI_memiter BLI_memiter; */ BLI_memiter *BLI_memiter_create(unsigned int chunk_size_min) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL; -void *BLI_memiter_alloc(BLI_memiter *mi, unsigned int size) +void *BLI_memiter_alloc(BLI_memiter *mi, unsigned int elem_size) /* WARNING: `ATTR_MALLOC` attribute on #BLI_memiter_alloc causes crash, see: D2756. */ ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1); void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void *data_from) ATTR_NONNULL(1, 3); void *BLI_memiter_calloc(BLI_memiter *mi, - unsigned int size) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL + unsigned int elem_size) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1); void BLI_memiter_destroy(BLI_memiter *mi) ATTR_NONNULL(1); void BLI_memiter_clear(BLI_memiter *mi) ATTR_NONNULL(1); diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index 516a3510274..b4344563780 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -114,8 +114,8 @@ void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena); * \return false if no changes were made. */ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx, - ListBase *fillvertbase, - ListBase *filledgebase); + ListBase *remvertbase, + ListBase *remedgebase); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index abbb0c6ac13..fa382997d39 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -488,10 +488,10 @@ bool BLI_str_startswith(const char *__restrict str, * * \param str: The string to search within. * \param end: The string we look for at the end. - * \return If str ends with end. + * \return If `str` ends with `end`. */ bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1, 2); -bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t length) +bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t str_len) ATTR_NONNULL(1, 2); /** diff --git a/source/blender/blenlib/intern/BLI_mempool_private.h b/source/blender/blenlib/intern/BLI_mempool_private.h index 317ecc84994..646af946895 100644 --- a/source/blender/blenlib/intern/BLI_mempool_private.h +++ b/source/blender/blenlib/intern/BLI_mempool_private.h @@ -49,7 +49,7 @@ void mempool_iter_threadsafe_destroy(ParallelMempoolTaskData *iter_arr) ATTR_NON * #BLI_mempool_threadsafe_iter.curchunk_threaded_shared for threaded iteration support. * (threaded section noted in comments). */ -void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *iter); +void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *ts_iter); #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/fileops_c.cc b/source/blender/blenlib/intern/fileops_c.cc index 114a06bb136..968205df4eb 100644 --- a/source/blender/blenlib/intern/fileops_c.cc +++ b/source/blender/blenlib/intern/fileops_c.cc @@ -1159,7 +1159,7 @@ static int delete_single_file(const char *from, const char * /*to*/) } # ifdef __APPLE__ -static int delete_soft(const char *file, const char **error_message) +static int delete_soft(const char *filepath, const char **error_message) { int ret = -1; @@ -1172,7 +1172,7 @@ static int delete_soft(const char *file, const char **error_message) Class NSStringClass = objc_getClass("NSString"); SEL stringWithUTF8StringSel = sel_registerName("stringWithUTF8String:"); id pathString = ((id(*)(Class, SEL, const char *))objc_msgSend)( - NSStringClass, stringWithUTF8StringSel, file); + NSStringClass, stringWithUTF8StringSel, filepath); Class NSFileManagerClass = objc_getClass("NSFileManager"); SEL defaultManagerSel = sel_registerName("defaultManager"); @@ -1199,7 +1199,7 @@ static int delete_soft(const char *file, const char **error_message) return ret; } # else -static int delete_soft(const char *file, const char **error_message) +static int delete_soft(const char *filepath, const char **error_message) { const char *args[5]; const char *process_failed; @@ -1214,7 +1214,7 @@ static int delete_soft(const char *file, const char **error_message) { args[0] = "kioclient5"; args[1] = "move"; - args[2] = file; + args[2] = filepath; args[3] = "trash:/"; args[4] = nullptr; process_failed = "kioclient5 reported failure"; @@ -1222,7 +1222,7 @@ static int delete_soft(const char *file, const char **error_message) else { args[0] = "gio"; args[1] = "trash"; - args[2] = file; + args[2] = filepath; args[3] = nullptr; process_failed = "gio reported failure"; } @@ -1298,11 +1298,11 @@ int BLI_delete(const char *path, bool dir, bool recursive) return remove(path); } -int BLI_delete_soft(const char *file, const char **error_message) +int BLI_delete_soft(const char *filepath, const char **error_message) { - BLI_assert(!BLI_path_is_rel(file)); + BLI_assert(!BLI_path_is_rel(filepath)); - return delete_soft(file, error_message); + return delete_soft(filepath, error_message); } /** @@ -1326,14 +1326,14 @@ static bool check_the_same(const char *path_a, const char *path_b) /** * Sets the mode and ownership of file to the values from st. */ -static int set_permissions(const char *file, const struct stat *st) +static int set_permissions(const char *filepath, const struct stat *st) { - if (chown(file, st->st_uid, st->st_gid)) { + if (chown(filepath, st->st_uid, st->st_gid)) { perror("chown"); return -1; } - if (chmod(file, st->st_mode)) { + if (chmod(filepath, st->st_mode)) { perror("chmod"); return -1; } diff --git a/source/blender/blenlib/intern/length_parameterize.cc b/source/blender/blenlib/intern/length_parameterize.cc index 924648c49a3..812ce18ed05 100644 --- a/source/blender/blenlib/intern/length_parameterize.cc +++ b/source/blender/blenlib/intern/length_parameterize.cc @@ -7,29 +7,31 @@ namespace blender::length_parameterize { -void sample_uniform(const Span lengths, +void sample_uniform(const Span accumulated_segment_lengths, const bool include_last_point, MutableSpan r_segment_indices, MutableSpan r_factors) { const int count = r_segment_indices.size(); BLI_assert(count > 0); - BLI_assert(lengths.size() >= 1); - BLI_assert(std::is_sorted(lengths.begin(), lengths.end())); + BLI_assert(accumulated_segment_lengths.size() >= 1); + BLI_assert( + std::is_sorted(accumulated_segment_lengths.begin(), accumulated_segment_lengths.end())); if (count == 1) { r_segment_indices[0] = 0; r_factors[0] = 0.0f; return; } - const float total_length = lengths.last(); + const float total_length = accumulated_segment_lengths.last(); const float step_length = total_length / (count - include_last_point); threading::parallel_for(IndexRange(count), 512, [&](const IndexRange range) { SampleSegmentHint hint; for (const int i : range) { /* Use minimum to avoid issues with floating point accuracy. */ const float sample_length = std::min(total_length, i * step_length); - sample_at_length(lengths, sample_length, r_segment_indices[i], r_factors[i], &hint); + sample_at_length( + accumulated_segment_lengths, sample_length, r_segment_indices[i], r_factors[i], &hint); } }); } diff --git a/source/blender/blenlib/intern/listbase.cc b/source/blender/blenlib/intern/listbase.cc index dac2206ea7f..6703bb35524 100644 --- a/source/blender/blenlib/intern/listbase.cc +++ b/source/blender/blenlib/intern/listbase.cc @@ -560,21 +560,21 @@ void *BLI_rfindlink(const ListBase *listbase, int number) return link; } -void *BLI_findlinkfrom(Link *start, int steps) +void *BLI_findlinkfrom(Link *start, int step) { Link *link = nullptr; - if (steps >= 0) { + if (step >= 0) { link = start; - while (link != nullptr && steps != 0) { - steps--; + while (link != nullptr && step != 0) { + step--; link = link->next; } } else { link = start; - while (link != nullptr && steps != 0) { - steps++; + while (link != nullptr && step != 0) { + step++; link = link->prev; } } diff --git a/source/blender/blenlib/intern/math_geom.cc b/source/blender/blenlib/intern/math_geom.cc index 0b5c22f944c..fd996008c82 100644 --- a/source/blender/blenlib/intern/math_geom.cc +++ b/source/blender/blenlib/intern/math_geom.cc @@ -432,60 +432,60 @@ void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], con madd_v3_v3v3fl(r_close, pt, plane, -side); } -float dist_signed_squared_to_plane_v3(const float pt[3], const float plane[4]) +float dist_signed_squared_to_plane_v3(const float p[3], const float plane[4]) { const float len_sq = len_squared_v3(plane); - const float side = plane_point_side_v3(plane, pt); + const float side = plane_point_side_v3(plane, p); const float fac = side / len_sq; return copysignf(len_sq * (fac * fac), side); } -float dist_squared_to_plane_v3(const float pt[3], const float plane[4]) +float dist_squared_to_plane_v3(const float p[3], const float plane[4]) { const float len_sq = len_squared_v3(plane); - const float side = plane_point_side_v3(plane, pt); + const float side = plane_point_side_v3(plane, p); const float fac = side / len_sq; /* only difference to code above - no 'copysignf' */ return len_sq * (fac * fac); } -float dist_signed_squared_to_plane3_v3(const float pt[3], const float plane[3]) +float dist_signed_squared_to_plane3_v3(const float p[3], const float plane[3]) { const float len_sq = len_squared_v3(plane); - const float side = dot_v3v3(plane, pt); /* only difference with 'plane[4]' version */ + const float side = dot_v3v3(plane, p); /* only difference with 'plane[4]' version */ const float fac = side / len_sq; return copysignf(len_sq * (fac * fac), side); } -float dist_squared_to_plane3_v3(const float pt[3], const float plane[3]) +float dist_squared_to_plane3_v3(const float p[3], const float plane[3]) { const float len_sq = len_squared_v3(plane); - const float side = dot_v3v3(plane, pt); /* only difference with 'plane[4]' version */ + const float side = dot_v3v3(plane, p); /* only difference with 'plane[4]' version */ const float fac = side / len_sq; /* only difference to code above - no 'copysignf' */ return len_sq * (fac * fac); } -float dist_signed_to_plane_v3(const float pt[3], const float plane[4]) +float dist_signed_to_plane_v3(const float p[3], const float plane[4]) { const float len_sq = len_squared_v3(plane); - const float side = plane_point_side_v3(plane, pt); + const float side = plane_point_side_v3(plane, p); const float fac = side / len_sq; return sqrtf(len_sq) * fac; } -float dist_to_plane_v3(const float pt[3], const float plane[4]) +float dist_to_plane_v3(const float p[3], const float plane[4]) { - return fabsf(dist_signed_to_plane_v3(pt, plane)); + return fabsf(dist_signed_to_plane_v3(p, plane)); } -float dist_signed_to_plane3_v3(const float pt[3], const float plane[3]) +float dist_signed_to_plane3_v3(const float p[3], const float plane[3]) { const float len_sq = len_squared_v3(plane); - const float side = dot_v3v3(plane, pt); /* only difference with 'plane[4]' version */ + const float side = dot_v3v3(plane, p); /* only difference with 'plane[4]' version */ const float fac = side / len_sq; return sqrtf(len_sq) * fac; } -float dist_to_plane3_v3(const float pt[3], const float plane[3]) +float dist_to_plane3_v3(const float p[3], const float plane[3]) { - return fabsf(dist_signed_to_plane3_v3(pt, plane)); + return fabsf(dist_signed_to_plane3_v3(p, plane)); } float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]) @@ -1530,12 +1530,12 @@ int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], } int isect_point_quad_v2( - const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2]) + const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { - float side12 = line_point_side_v2(v1, v2, pt); - float side23 = line_point_side_v2(v2, v3, pt); - float side34 = line_point_side_v2(v3, v4, pt); - float side41 = line_point_side_v2(v4, v1, pt); + float side12 = line_point_side_v2(v1, v2, p); + float side23 = line_point_side_v2(v2, v3, p); + float side34 = line_point_side_v2(v3, v4, p); + float side41 = line_point_side_v2(v4, v1, p); if (side12 >= 0.0f && side23 >= 0.0f && side34 >= 0.0f && side41 >= 0.0f) { return 1; } @@ -3073,7 +3073,7 @@ void isect_ray_aabb_v3_precalc(IsectRayAABB_Precalc *data, bool isect_ray_aabb_v3(const IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], - float *tmin_out) + float *r_tmin) { /* Adapted from http://www.gamedev.net/community/forums/topic.asp?topic_id=459973 */ @@ -3115,8 +3115,8 @@ bool isect_ray_aabb_v3(const IsectRayAABB_Precalc *data, * keeping this here for future reference. */ // if (tzmax < tmax) tmax = tzmax; - if (tmin_out) { - (*tmin_out) = tmin; + if (r_tmin) { + (*r_tmin) = tmin; } return true; @@ -4503,7 +4503,7 @@ void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3]) /***************************** View & Projection *****************************/ -void orthographic_m4(float matrix[4][4], +void orthographic_m4(float mat[4][4], const float left, const float right, const float bottom, @@ -4519,13 +4519,13 @@ void orthographic_m4(float matrix[4][4], if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) { return; } - unit_m4(matrix); - matrix[0][0] = 2.0f / Xdelta; - matrix[3][0] = -(right + left) / Xdelta; - matrix[1][1] = 2.0f / Ydelta; - matrix[3][1] = -(top + bottom) / Ydelta; - matrix[2][2] = -2.0f / Zdelta; /* NOTE: negate Z. */ - matrix[3][2] = -(farClip + nearClip) / Zdelta; + unit_m4(mat); + mat[0][0] = 2.0f / Xdelta; + mat[3][0] = -(right + left) / Xdelta; + mat[1][1] = 2.0f / Ydelta; + mat[3][1] = -(top + bottom) / Ydelta; + mat[2][2] = -2.0f / Zdelta; /* NOTE: negate Z. */ + mat[3][2] = -(farClip + nearClip) / Zdelta; } void perspective_m4(float mat[4][4], diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 56de8b25eb1..a1605321fb2 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -878,12 +878,12 @@ bool BLI_str_startswith(const char *__restrict str, const char *__restrict start return (*start == '\0'); } -bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t slength) +bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t str_len) { - size_t elength = strlen(end); + size_t end_len = strlen(end); - if (elength < slength) { - const char *iter = &str[slength - elength]; + if (end_len < str_len) { + const char *iter = &str[str_len - end_len]; while (*iter) { if (*iter++ != *end++) { return false; @@ -896,8 +896,8 @@ bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, s bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) { - const size_t slength = strlen(str); - return BLI_strn_endswith(str, end, slength); + const size_t str_len = strlen(str); + return BLI_strn_endswith(str, end, str_len); } /** \} */ @@ -906,12 +906,12 @@ bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) /** \name String Length * \{ */ -size_t BLI_strnlen(const char *s, const size_t maxlen) +size_t BLI_strnlen(const char *str, const size_t maxlen) { size_t len; - for (len = 0; len < maxlen; len++, s++) { - if (!*s) { + for (len = 0; len < maxlen; len++, str++) { + if (!*str) { break; } }