Cleanup: Clang tidy

- Deprecated headers
- Else after return
- Inconsistent parameter names (I used the most recently modified)
- Raw string literals
This commit is contained in:
Hans Goudey 2022-03-23 23:24:54 -05:00
parent e253f9f66d
commit aeb2c2afaf
12 changed files with 43 additions and 40 deletions

View File

@ -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);

View File

@ -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);

View File

@ -5,7 +5,7 @@
* \ingroup bke
*/
#include <string.h>
#include <cstring>
#include "DNA_defaults.h"
#include "DNA_scene_types.h"

View File

@ -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);
}

View File

@ -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())

View File

@ -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;
}

View File

@ -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_);

View File

@ -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();
}

View File

@ -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;

View File

@ -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] &&
!IMB_colormanagement_space_name_is_scene_linear(
imf->linear_colorspace_settings.name);
image_format->linear_colorspace_settings.name);
if (do_colormanagement_display || do_colormanagement_linear || do_alpha_under) {
if (allocate_result) {
@ -2529,7 +2529,8 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
* should be pretty safe since this image buffer is supposed to be used for
* saving only and ftype would be overwritten a bit later by BKE_imbuf_write
*/
colormanaged_ibuf->ftype = BKE_imtype_to_ftype(imf->imtype, &colormanaged_ibuf->foptions);
colormanaged_ibuf->ftype = BKE_imtype_to_ftype(image_format->imtype,
&colormanaged_ibuf->foptions);
/* if file format isn't able to handle float buffer itself,
* we need to allocate byte buffer and store color managed
@ -2543,8 +2544,10 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
}
/* perform color space conversions */
colormanagement_imbuf_make_display_space(
colormanaged_ibuf, &imf->view_settings, &imf->display_settings, make_byte);
colormanagement_imbuf_make_display_space(colormanaged_ibuf,
&image_format->view_settings,
&image_format->display_settings,
make_byte);
if (colormanaged_ibuf->rect_float) {
/* float buffer isn't linear anymore,
@ -2552,7 +2555,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
* no space conversion should happen if ibuf->float_colorspace != NULL
*/
colormanaged_ibuf->float_colorspace = display_transform_get_colorspace(
&imf->view_settings, &imf->display_settings);
&image_format->view_settings, &image_format->display_settings);
}
}
else if (do_colormanagement_linear) {
@ -2565,7 +2568,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
if (colormanaged_ibuf->rect_float) {
const char *from_colorspace = (ibuf->float_colorspace) ? ibuf->float_colorspace->name :
global_role_scene_linear;
const char *to_colorspace = imf->linear_colorspace_settings.name;
const char *to_colorspace = image_format->linear_colorspace_settings.name;
IMB_colormanagement_transform(colormanaged_ibuf->rect_float,
colormanaged_ibuf->x,

View File

@ -89,7 +89,7 @@ std::pair<Mesh *, bool> OBJMesh::triangulate_mesh_eval()
if (export_mesh_eval_->totpoly <= 0) {
return {export_mesh_eval_, false};
}
const BMeshCreateParams bm_create_params = {0u};
const BMeshCreateParams bm_create_params = {false};
BMeshFromMeshParams bm_convert_params{};
bm_convert_params.calc_face_normal = true;
bm_convert_params.calc_vert_normal = true;
@ -382,8 +382,8 @@ void OBJMesh::store_normal_coords_and_indices()
normal_to_index.reserve(export_mesh_eval_->totpoly);
loop_to_normal_index_.resize(export_mesh_eval_->totloop);
loop_to_normal_index_.fill(-1);
const float(
*lnors)[3] = (const float(*)[3])(CustomData_get_layer(&export_mesh_eval_->ldata, CD_NORMAL));
const float(*lnors)[3] = (const float(*)[3])(
CustomData_get_layer(&export_mesh_eval_->ldata, CD_NORMAL));
for (int poly_index = 0; poly_index < export_mesh_eval_->totpoly; ++poly_index) {
const MPoly &mpoly = export_mesh_eval_->mpoly[poly_index];
bool need_per_loop_normals = lnors != nullptr || (mpoly.flag & ME_SMOOTH);

View File

@ -4,7 +4,7 @@
* \ingroup modifiers
*/
#include <string.h>
#include <cstring>
#include "BLI_math_vector.h"
#include "BLI_string.h"