[Bf-blender-cvs] [aeb2c2afaf0] master: Cleanup: Clang tidy

Hans Goudey noreply at git.blender.org
Thu Mar 24 05:25:03 CET 2022


Commit: aeb2c2afaf00d1c1ef6cce73b106d5400e52566e
Author: Hans Goudey
Date:   Wed Mar 23 23:24:54 2022 -0500
Branches: master
https://developer.blender.org/rBaeb2c2afaf00d1c1ef6cce73b106d5400e52566e

Cleanup: Clang tidy

- Deprecated headers
- Else after return
- Inconsistent parameter names (I used the most recently modified)
- Raw string literals

===================================================================

M	source/blender/blenkernel/intern/curve.cc
M	source/blender/blenkernel/intern/image.cc
M	source/blender/blenkernel/intern/image_format.cc
M	source/blender/blenkernel/intern/image_save.cc
M	source/blender/editors/render/render_preview.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M	source/blender/editors/space_outliner/tree/tree_element_rna.cc
M	source/blender/editors/transform/transform_snap.c
M	source/blender/imbuf/intern/colormanagement.c
M	source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M	source/blender/modifiers/intern/MOD_meshsequencecache.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc
index 354ddd7d167..02710982564 100644
--- a/source/blender/blenkernel/intern/curve.cc
+++ b/source/blender/blenkernel/intern/curve.cc
@@ -4718,11 +4718,11 @@ static NURBSValidationStatus nurb_check_valid(const int pnts,
   if (pnts <= 1) {
     return NURBSValidationStatus::AtLeastTwoPointsRequired;
   }
-  else if (type == CU_NURBS) {
+  if (type == CU_NURBS) {
     if (pnts < order) {
       return NURBSValidationStatus::MorePointsThanOrderRequired;
     }
-    else if (flag & CU_NURB_BEZIER) {
+    if (flag & CU_NURB_BEZIER) {
       int points_needed = 0;
       if (flag & CU_NURB_CYCLIC) {
         const int remainder = pnts % (order - 1);
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc
index 0e3c913189c..296364e71ca 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -239,7 +239,7 @@ static void image_foreach_cache(ID *id,
 
   auto gputexture_offset = [image](int target, int eye, int resolution) {
     constexpr size_t base_offset = offsetof(Image, gputexture);
-    const auto first = &image->gputexture[0][0][0];
+    struct GPUTexture **first = &image->gputexture[0][0][0];
     const size_t array_offset = sizeof(*first) *
                                 (&image->gputexture[target][eye][resolution] - first);
     return base_offset + array_offset;
@@ -489,9 +489,9 @@ static void image_add_view(Image *ima, const char *viewname, const char *filepat
 /** \name Image Cache
  * \{ */
 
-typedef struct ImageCacheKey {
+struct ImageCacheKey {
   int index;
-} ImageCacheKey;
+};
 
 static unsigned int imagecache_hashhash(const void *key_v)
 {
@@ -3325,14 +3325,14 @@ void BKE_image_ensure_tile_token(char *filename)
    * with other digit sequences, we can leverage the supported range of roughly
    * 1000 through 2000 to provide better detection.
    */
-  std::regex pattern("(^|.*?\\D)([12]\\d{3})(\\D.*)");
+  std::regex pattern(R"((^|.*?\D)([12]\d{3})(\D.*))");
   if (std::regex_search(path, match, pattern)) {
     BLI_strncpy(filename, match.format("$1<UDIM>$3").c_str(), FILE_MAX);
     return;
   }
 
   /* General u##_v### "uvtile" pattern. */
-  pattern = std::regex("(.*)(u\\d{1,2}_v\\d{1,3})(\\D.*)");
+  pattern = std::regex(R"((.*)(u\d{1,2}_v\d{1,3})(\D.*))");
   if (std::regex_search(path, match, pattern)) {
     BLI_strncpy(filename, match.format("$1<UVTILE>$3").c_str(), FILE_MAX);
     return;
@@ -5053,7 +5053,7 @@ void BKE_image_user_file_path_ex(ImageUser *iuser, Image *ima, char *filepath, b
 bool BKE_image_has_alpha(Image *image)
 {
   void *lock;
-  ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
+  ImBuf *ibuf = BKE_image_acquire_ibuf(image, nullptr, &lock);
   const int planes = (ibuf ? ibuf->planes : 0);
   BKE_image_release_ibuf(image, ibuf, lock);
 
diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc
index 44aa9e21195..2b5712a1597 100644
--- a/source/blender/blenkernel/intern/image_format.cc
+++ b/source/blender/blenkernel/intern/image_format.cc
@@ -5,7 +5,7 @@
  * \ingroup bke
  */
 
-#include <string.h>
+#include <cstring>
 
 #include "DNA_defaults.h"
 #include "DNA_scene_types.h"
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc
index f530183f967..913b5553632 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -486,7 +486,7 @@ static float *image_exr_from_scene_linear_to_output(float *rect,
 
 bool BKE_image_render_write_exr(ReportList *reports,
                                 const RenderResult *rr,
-                                const char *filepath,
+                                const char *filename,
                                 const ImageFormatData *imf,
                                 const bool save_as_render,
                                 const char *view,
@@ -630,11 +630,11 @@ bool BKE_image_render_write_exr(ReportList *reports,
 
   errno = 0;
 
-  BLI_make_existing_file(filepath);
+  BLI_make_existing_file(filename);
 
   int compress = (imf ? imf->exr_codec : 0);
   bool success = IMB_exr_begin_write(
-      exrhandle, filepath, rr->rectx, rr->recty, compress, rr->stamp_data);
+      exrhandle, filename, rr->rectx, rr->recty, compress, rr->stamp_data);
   if (success) {
     IMB_exr_write_channels(exrhandle);
   }
diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc
index 16a3e799779..ef0f0b6225c 100644
--- a/source/blender/editors/render/render_preview.cc
+++ b/source/blender/editors/render/render_preview.cc
@@ -1679,19 +1679,19 @@ class PreviewLoadJob {
   PreviewLoadJob();
   ~PreviewLoadJob();
 
-  static PreviewLoadJob &ensure_job(wmWindowManager *, wmWindow *);
-  static void load_jobless(PreviewImage *, eIconSizes);
+  static PreviewLoadJob &ensure_job(wmWindowManager *wm, wmWindow *win);
+  static void load_jobless(PreviewImage *preview, eIconSizes icon_size);
 
-  void push_load_request(PreviewImage *, eIconSizes);
+  void push_load_request(PreviewImage *preview, eIconSizes icon_size);
 
  private:
-  static void run_fn(void *, short *, short *, float *);
-  static void update_fn(void *);
-  static void end_fn(void *);
-  static void free_fn(void *);
+  static void run_fn(void *customdata, short *stop, short *do_update, float *progress);
+  static void update_fn(void *customdata);
+  static void end_fn(void *customdata);
+  static void free_fn(void *customdata);
 
   /** Mark a single requested preview as being done, remove the request. */
-  static void finish_request(RequestedPreview &);
+  static void finish_request(RequestedPreview &request);
 };
 
 PreviewLoadJob::PreviewLoadJob() : todo_queue_(BLI_thread_queue_init())
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc
index 51997cd9e1e..945bb09c0c6 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_3d_brush.cc
@@ -65,7 +65,7 @@ static std::optional<float3> find_curves_brush_position(const CurvesGeometry &cu
         /* New candidate is in inner radius while old one is not. */
         return true;
       }
-      else if (b.depth_sq_cu < a.depth_sq_cu) {
+      if (b.depth_sq_cu < a.depth_sq_cu) {
         /* Both candidates are in inner radius, but new one is closer to the camera. */
         return true;
       }
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index 2f39e6eec20..e444b3de2d5 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -55,7 +55,7 @@ class AddOperation : public CurvesSculptStrokeOperation {
   friend struct AddOperationExecutor;
 
  public:
-  ~AddOperation()
+  ~AddOperation() override
   {
     if (curve_roots_kdtree_ != nullptr) {
       BLI_kdtree_3d_free(curve_roots_kdtree_);
diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.cc b/source/blender/editors/space_outliner/tree/tree_element_rna.cc
index abc7cd8f8ce..914104f1f06 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc
@@ -52,7 +52,7 @@ bool TreeElementRNACommon::isRNAValid() const
   return rna_ptr_.data != nullptr;
 }
 
-bool TreeElementRNACommon::expandPoll(const SpaceOutliner &) const
+bool TreeElementRNACommon::expandPoll(const SpaceOutliner &UNUSED(space_outliner)) const
 {
   return isRNAValid();
 }
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 7ace6343985..bf898b9053f 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -567,10 +567,10 @@ static char snap_flag_from_spacetype(TransInfo *t)
   if (t->spacetype == SPACE_NODE) {
     return ts->snap_flag_node;
   }
-  else if (t->spacetype == SPACE_IMAGE) {
+  if (t->spacetype == SPACE_IMAGE) {
     return ts->snap_uv_flag;
   }
-  else if (t->spacetype == SPACE_SEQ) {
+  if (t->spacetype == SPACE_SEQ) {
     return ts->snap_flag_seq;
   }
   return ts->snap_flag;
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 2e8c5cc4a40..193fda01816 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -2449,12 +2449,12 @@ void IMB_colormanagement_imbuf_make_display_space(
 ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
                                            bool save_as_render,
                                            bool allocate_result,
-                                           const ImageFormatData *imf)
+                                           const ImageFormatData *image_format)
 {
   ImBuf *colormanaged_ibuf = ibuf;
-  const bool is_movie = BKE_imtype_is_movie(imf->imtype);
-  const bool requires_linear_float = BKE_imtype_requires_linear_float(imf->imtype);
-  const bool do_alpha_under = imf->planes != R_IMF_PLANES_RGBA;
+  const bool is_movie = BKE_imtype_is_movie(image_format->imtype);
+  const bool requires_linear_float = BKE_imtype_requires_linear_float(image_format->imtype);
+  const bool do_alpha_under = image_format->planes != R_IMF_PLANES_RGBA;
 
   if (ibuf->rect_float && ibuf->rect &&
       (ibuf->userflags & (IB_DISPLAY_BUFFER_INVALID | IB_RECT_INVALID)) != 0) {
@@ -2464,9 +2464,9 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
 
   const bool do_colormanagement_display = save_as_render && (is_movie || !requires_linear_float);
   const bool do_colormanagement_linear = save_as_render && requires_linear_float &&
-                                         imf->linear_colorspace_settings.name[0] &&
+                                         image_format->linear_colorspace_settings.name[0] &&
                    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list