diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-23 02:58:25 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-23 02:58:25 +0300 |
commit | 1160a3a3f83cafda98e7bf6fb111bdacc5f28a63 (patch) | |
tree | b969f2508aac0cb59cd3fe81119dc1301a84bfb0 /source | |
parent | d2a3b99ff7abb3d7deb30da4554b1cda6ff32766 (diff) |
Cleanup: Clang tidy
Mainly duplicate includes and else after return.
Diffstat (limited to 'source')
17 files changed, 50 insertions, 66 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index f86e947910b..3d546c5c36a 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -55,8 +55,6 @@ #include "BLO_read_write.h" -#include "BKE_gpencil.h" - static CLG_LogRef LOG = {"bke.gpencil"}; static void greasepencil_copy_data(Main *UNUSED(bmain), diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 792474d30ea..0445a1540c7 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -25,8 +25,6 @@ #include "BLI_polyfill_2d.h" #include "BLI_span.hh" -#include "BLT_translation.h" - #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_material_types.h" diff --git a/source/blender/blenkernel/intern/subdiv_modifier.c b/source/blender/blenkernel/intern/subdiv_modifier.c index f5423dccc0f..57af0192d59 100644 --- a/source/blender/blenkernel/intern/subdiv_modifier.c +++ b/source/blender/blenkernel/intern/subdiv_modifier.c @@ -44,15 +44,14 @@ bool BKE_subsurf_modifier_runtime_init(SubsurfModifierData *smd, const bool use_ return false; } - else { - /* Allocate runtime data if it did not exist yet. */ - if (runtime_data == NULL) { - runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime"); - smd->modifier.runtime = runtime_data; - } - runtime_data->settings = settings; - return true; + + /* Allocate runtime data if it did not exist yet. */ + if (runtime_data == NULL) { + runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime"); + smd->modifier.runtime = runtime_data; } + runtime_data->settings = settings; + return true; } static ModifierData *modifier_get_last_enabled_for_mode(const Scene *scene, diff --git a/source/blender/blenlib/tests/BLI_kdtree_test.cc b/source/blender/blenlib/tests/BLI_kdtree_test.cc index f8675ef332d..d040ea15172 100644 --- a/source/blender/blenlib/tests/BLI_kdtree_test.cc +++ b/source/blender/blenlib/tests/BLI_kdtree_test.cc @@ -4,7 +4,7 @@ #include "BLI_kdtree.h" -#include <math.h> +#include <cmath> /* -------------------------------------------------------------------- */ /* Tests */ diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index 8c6ef34ef26..1c785fa6452 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -9,8 +9,6 @@ #include "BKE_context.h" #include "BKE_curves.hh" -#include "DNA_meshdata_types.h" - #include "ED_view3d.h" #include "UI_interface.h" diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 0f2b02ed3ab..ce6b397af15 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -90,13 +90,13 @@ static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool, if (STREQ(tool->runtime->data_block, "DRAW")) { return GP_BRUSH_PRESET_PENCIL; } - else if (STREQ(tool->runtime->data_block, "FILL")) { + if (STREQ(tool->runtime->data_block, "FILL")) { return GP_BRUSH_PRESET_FILL_AREA; } - else if (STREQ(tool->runtime->data_block, "ERASE")) { + if (STREQ(tool->runtime->data_block, "ERASE")) { return GP_BRUSH_PRESET_ERASER_SOFT; } - else if (STREQ(tool->runtime->data_block, "TINT")) { + if (STREQ(tool->runtime->data_block, "TINT")) { return GP_BRUSH_PRESET_TINT; } break; @@ -105,28 +105,28 @@ static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool, if (STREQ(tool->runtime->data_block, "SMOOTH")) { return GP_BRUSH_PRESET_SMOOTH_STROKE; } - else if (STREQ(tool->runtime->data_block, "STRENGTH")) { + if (STREQ(tool->runtime->data_block, "STRENGTH")) { return GP_BRUSH_PRESET_STRENGTH_STROKE; } - else if (STREQ(tool->runtime->data_block, "THICKNESS")) { + if (STREQ(tool->runtime->data_block, "THICKNESS")) { return GP_BRUSH_PRESET_THICKNESS_STROKE; } - else if (STREQ(tool->runtime->data_block, "GRAB")) { + if (STREQ(tool->runtime->data_block, "GRAB")) { return GP_BRUSH_PRESET_GRAB_STROKE; } - else if (STREQ(tool->runtime->data_block, "PUSH")) { + if (STREQ(tool->runtime->data_block, "PUSH")) { return GP_BRUSH_PRESET_PUSH_STROKE; } - else if (STREQ(tool->runtime->data_block, "TWIST")) { + if (STREQ(tool->runtime->data_block, "TWIST")) { return GP_BRUSH_PRESET_TWIST_STROKE; } - else if (STREQ(tool->runtime->data_block, "PINCH")) { + if (STREQ(tool->runtime->data_block, "PINCH")) { return GP_BRUSH_PRESET_PINCH_STROKE; } - else if (STREQ(tool->runtime->data_block, "RANDOMIZE")) { + if (STREQ(tool->runtime->data_block, "RANDOMIZE")) { return GP_BRUSH_PRESET_RANDOMIZE_STROKE; } - else if (STREQ(tool->runtime->data_block, "CLONE")) { + if (STREQ(tool->runtime->data_block, "CLONE")) { return GP_BRUSH_PRESET_CLONE_STROKE; } break; @@ -138,23 +138,22 @@ static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool, if (STREQ(tool->runtime->data_block, "DRAW")) { return GP_BRUSH_PRESET_VERTEX_DRAW; } - else if (STREQ(tool->runtime->data_block, "BLUR")) { + if (STREQ(tool->runtime->data_block, "BLUR")) { return GP_BRUSH_PRESET_VERTEX_BLUR; } - else if (STREQ(tool->runtime->data_block, "AVERAGE")) { + if (STREQ(tool->runtime->data_block, "AVERAGE")) { return GP_BRUSH_PRESET_VERTEX_AVERAGE; } - else if (STREQ(tool->runtime->data_block, "SMEAR")) { + if (STREQ(tool->runtime->data_block, "SMEAR")) { return GP_BRUSH_PRESET_VERTEX_SMEAR; } - else if (STREQ(tool->runtime->data_block, "REPLACE")) { + if (STREQ(tool->runtime->data_block, "REPLACE")) { return GP_BRUSH_PRESET_VERTEX_REPLACE; } break; } default: return GP_BRUSH_PRESET_UNKNOWN; - break; } return GP_BRUSH_PRESET_UNKNOWN; } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 0693b445fe5..fe96257dc01 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -858,7 +858,7 @@ void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush); float SCULPT_raycast_init(struct ViewContext *vc, - const float mouse[2], + const float mval[2], float ray_start[3], float ray_end[3], float ray_normal[3], diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index 871de39b1dd..d1babda642e 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -86,9 +86,7 @@ void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const do_skip = false; break; } - else { - is_system_override = true; - } + is_system_override = true; } } diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 8dcf2ceb679..964ac5f650b 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -4914,7 +4914,7 @@ static int uv_select_similar_exec(bContext *C, wmOperator *op) if (selectmode & UV_SELECT_EDGE) { return uv_select_similar_edge_exec(C, op); } - else if (selectmode & UV_SELECT_FACE) { + if (selectmode & UV_SELECT_FACE) { return uv_select_similar_face_exec(C, op); } if (selectmode & UV_SELECT_ISLAND) { diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 33873b5daa7..a58c2ba4c44 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2481,22 +2481,21 @@ static ImBuf *imbuf_ensure_editable(ImBuf *ibuf, ImBuf *colormanaged_ibuf, bool IMB_metadata_copy(colormanaged_ibuf, ibuf); return colormanaged_ibuf; } - else { - /* Render pipeline is constructing image buffer itself, - * but it's re-using byte and float buffers from render result make copy of this buffers - * here sine this buffers would be transformed to other color space here. */ - if (ibuf->rect && (ibuf->mall & IB_rect) == 0) { - ibuf->rect = MEM_dupallocN(ibuf->rect); - ibuf->mall |= IB_rect; - } - if (ibuf->rect_float && (ibuf->mall & IB_rectfloat) == 0) { - ibuf->rect_float = MEM_dupallocN(ibuf->rect_float); - ibuf->mall |= IB_rectfloat; - } + /* Render pipeline is constructing image buffer itself, + * but it's re-using byte and float buffers from render result make copy of this buffers + * here sine this buffers would be transformed to other color space here. */ + if (ibuf->rect && (ibuf->mall & IB_rect) == 0) { + ibuf->rect = MEM_dupallocN(ibuf->rect); + ibuf->mall |= IB_rect; + } - return ibuf; + if (ibuf->rect_float && (ibuf->mall & IB_rectfloat) == 0) { + ibuf->rect_float = MEM_dupallocN(ibuf->rect_float); + ibuf->mall |= IB_rectfloat; } + + return ibuf; } ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index ec25b67af5f..13bf3697946 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -22,7 +22,6 @@ #include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include <math.h> void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf) { diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index cffa61977f7..06f9202a1c6 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -524,8 +524,8 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath, unsigned int i = JPEG_APP1_MAX; /* All EXIF data is within this 64K header segment. Skip ahead until next SOI for thumbnail. */ while (!((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI)) && - !feof(infile) && i--) - ; + !feof(infile) && i--) { + } if (i > 0 && !feof(infile)) { /* We found a JPEG thumbnail inside this image. */ ImBuf *ibuf = NULL; diff --git a/source/blender/io/common/intern/path_util.cc b/source/blender/io/common/intern/path_util.cc index 902cf552bf0..18632b410f8 100644 --- a/source/blender/io/common/intern/path_util.cc +++ b/source/blender/io/common/intern/path_util.cc @@ -39,7 +39,7 @@ std::string path_reference(StringRefNull filepath, if (mode == PATH_REFERENCE_ABSOLUTE) { return filepath_abs; } - else if (mode == PATH_REFERENCE_RELATIVE) { + if (mode == PATH_REFERENCE_RELATIVE) { char rel_path[PATH_MAX]; BLI_strncpy(rel_path, filepath_abs, PATH_MAX); BLI_path_rel(rel_path, base_dst.c_str()); @@ -49,7 +49,7 @@ std::string path_reference(StringRefNull filepath, } return rel_path + 2; /* Skip blender's internal "//" prefix. */ } - else if (mode == PATH_REFERENCE_STRIP) { + if (mode == PATH_REFERENCE_STRIP) { return BLI_path_basename(filepath_abs); } BLI_assert_msg(false, "Invalid path reference mode"); diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 36e1a40953c..46749b03169 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -87,11 +87,9 @@ static Material *find_existing_material( if (mat_iter != mat_map.end()) { return mat_iter->second; } - else { - /* We can't find the Blender material which was previously created for this USD - * material, which should never happen. */ - BLI_assert_unreachable(); - } + /* We can't find the Blender material which was previously created for this USD + * material, which should never happen. */ + BLI_assert_unreachable(); } } else { diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc index 4126be6966a..6300e5c657c 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.cc +++ b/source/blender/io/usd/intern/usd_writer_volume.cc @@ -100,7 +100,7 @@ std::optional<std::string> USDVolumeWriter::resolve_vdb_file(const Volume *volum vdb_file_path = construct_vdb_file_path(volume); if (!BKE_volume_save( - volume, usd_export_context_.bmain, NULL, vdb_file_path.value_or("").c_str())) { + volume, usd_export_context_.bmain, nullptr, vdb_file_path.value_or("").c_str())) { return std::nullopt; } } diff --git a/source/blender/io/usd/tests/usd_imaging_test.cc b/source/blender/io/usd/tests/usd_imaging_test.cc index 497319c59bd..5cd3c042e59 100644 --- a/source/blender/io/usd/tests/usd_imaging_test.cc +++ b/source/blender/io/usd/tests/usd_imaging_test.cc @@ -42,8 +42,8 @@ TEST_F(USDImagingTest, CapsuleAdapterTest) } pxr::UsdImagingCapsuleAdapter capsule_adapter; - pxr::VtValue points_value = capsule_adapter.GetMeshPoints(capsule.GetPrim(), - pxr::UsdTimeCode::Default()); + pxr::VtValue points_value = pxr::UsdImagingCapsuleAdapter::GetMeshPoints( + capsule.GetPrim(), pxr::UsdTimeCode::Default()); if (!points_value.IsHolding<pxr::VtArray<pxr::GfVec3f>>()) { FAIL() << "Mesh points value holding unexpected type."; return; @@ -52,7 +52,7 @@ TEST_F(USDImagingTest, CapsuleAdapterTest) pxr::VtArray<pxr::GfVec3f> points = points_value.Get<pxr::VtArray<pxr::GfVec3f>>(); EXPECT_FALSE(points.empty()); - pxr::VtValue topology_value = capsule_adapter.GetMeshTopology(); + pxr::VtValue topology_value = pxr::UsdImagingCapsuleAdapter::GetMeshTopology(); if (!topology_value.IsHolding<pxr::HdMeshTopology>()) { FAIL() << "Mesh topology value holding unexpected type."; diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c index 2a7857b3059..33d9ff0b041 100644 --- a/source/blender/python/gpu/gpu_py_framebuffer.c +++ b/source/blender/python/gpu/gpu_py_framebuffer.c @@ -21,11 +21,9 @@ #include "../mathutils/mathutils.h" #include "gpu_py.h" -#include "gpu_py_texture.h" - -#include "gpu_py.h" #include "gpu_py_buffer.h" #include "gpu_py_framebuffer.h" /* own include */ +#include "gpu_py_texture.h" /* -------------------------------------------------------------------- */ /** \name GPUFrameBuffer Common Utilities |