Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-25 11:33:28 +0300
committerCampbell Barton <campbell@blender.org>2022-09-25 13:17:08 +0300
commitf68cfd6bb078482c4a779a6e26a56e2734edb5b8 (patch)
tree2878e5b80dba5bdeba186d99661d604eb38879cd /source/blender/blenloader
parentc7b247a118e302a3afc6473797e53b6af28b69e2 (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.cc16
-rw-r--r--source/blender/blenloader/intern/undofile.cc2
-rw-r--r--source/blender/blenloader/intern/versioning_300.cc10
-rw-r--r--source/blender/blenloader/intern/writefile.cc6
4 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index 71708c09c01..46ae207db48 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -193,7 +193,7 @@ typedef struct BHeadN {
struct BHead bhead;
} BHeadN;
-#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))
+#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead))))
/**
* We could change this in the future, for now it's simplest if only data is delayed
@@ -475,7 +475,7 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li
idnext = static_cast<ID *>(id->next);
if (id->lib) {
- if (((uint)id->lib->temp_index < lib_main_array_len) &&
+ if ((uint(id->lib->temp_index) < lib_main_array_len) &&
/* this check should never fail, just in case 'id->lib' is a dangling pointer. */
(lib_main_array[id->lib->temp_index]->curlib == id->lib)) {
Main *mainvar = lib_main_array[id->lib->temp_index];
@@ -591,7 +591,7 @@ static void read_file_bhead_idname_map_create(FileData *fd)
if (code_prev != bhead->code) {
code_prev = bhead->code;
is_link = blo_bhead_is_id_valid_type(bhead) ?
- BKE_idtype_idcode_is_linkable((short)code_prev) :
+ BKE_idtype_idcode_is_linkable(short(code_prev)) :
false;
}
@@ -608,7 +608,7 @@ static void read_file_bhead_idname_map_create(FileData *fd)
if (code_prev != bhead->code) {
code_prev = bhead->code;
is_link = blo_bhead_is_id_valid_type(bhead) ?
- BKE_idtype_idcode_is_linkable((short)code_prev) :
+ BKE_idtype_idcode_is_linkable(short(code_prev)) :
false;
}
@@ -738,7 +738,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
/* this patch is to avoid `intptr_t` being read from not-eight aligned positions
* is necessary on any modern 64bit architecture) */
memcpy(&old, &bhead8->old, 8);
- bhead4->old = (int)(old >> 3);
+ bhead4->old = int(old >> 3);
bhead4->SDNAnr = bhead8->SDNAnr;
bhead4->nr = bhead8->nr;
@@ -862,7 +862,7 @@ static BHeadN *get_bhead(FileData *fd)
#endif
else {
new_bhead = static_cast<BHeadN *>(
- MEM_mallocN(sizeof(BHeadN) + (size_t)bhead.len, "new_bhead"));
+ MEM_mallocN(sizeof(BHeadN) + size_t(bhead.len), "new_bhead"));
if (new_bhead) {
new_bhead->next = new_bhead->prev = nullptr;
#ifdef USE_BHEAD_READ_ON_DEMAND
@@ -872,7 +872,7 @@ static BHeadN *get_bhead(FileData *fd)
new_bhead->is_memchunk_identical = false;
new_bhead->bhead = bhead;
- readsize = fd->file->read(fd->file, new_bhead + 1, (size_t)bhead.len);
+ readsize = fd->file->read(fd->file, new_bhead + 1, size_t(bhead.len));
if (readsize != bhead.len) {
fd->is_eof = true;
@@ -966,7 +966,7 @@ static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
success = false;
}
else {
- if (fd->file->read(fd->file, buf, (size_t)new_bhead->bhead.len) != new_bhead->bhead.len) {
+ if (fd->file->read(fd->file, buf, size_t(new_bhead->bhead.len)) != new_bhead->bhead.len) {
success = false;
}
if (fd->flags & FD_FLAGS_IS_MEMFILE) {
diff --git a/source/blender/blenloader/intern/undofile.cc b/source/blender/blenloader/intern/undofile.cc
index 58c1020f4cb..4c417c41297 100644
--- a/source/blender/blenloader/intern/undofile.cc
+++ b/source/blender/blenloader/intern/undofile.cc
@@ -233,7 +233,7 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath)
for (chunk = static_cast<MemFileChunk *>(memfile->chunks.first); chunk;
chunk = static_cast<MemFileChunk *>(chunk->next)) {
#ifdef _WIN32
- if ((size_t)write(file, chunk->buf, (uint)chunk->size) != chunk->size)
+ if ((size_t)write(file, chunk->buf, uint(chunk->size)) != chunk->size)
#else
if ((size_t)write(file, chunk->buf, chunk->size) != chunk->size)
#endif
diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc
index 02b83d73d1f..f2aa07b6678 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -169,7 +169,7 @@ static void version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data,
MEM_malloc_arrayN(array_len, sizeof(double), __func__));
const float *old_default_array = static_cast<const float *>(IDP_Array(default_value));
for (int i = 0; i < ui_data->default_array_len; i++) {
- ui_data->default_array[i] = (double)old_default_array[i];
+ ui_data->default_array[i] = double(old_default_array[i]);
}
}
else if (default_value->subtype == IDP_DOUBLE) {
@@ -412,9 +412,9 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
else {
v->speed_control_type = SEQ_SPEED_MULTIPLY;
v->speed_fader = globalSpeed *
- ((float)seq->seq1->len /
- max_ff((float)(SEQ_time_right_handle_frame_get(scene, seq->seq1) -
- seq->seq1->start),
+ (float(seq->seq1->len) /
+ max_ff(float(SEQ_time_right_handle_frame_get(scene, seq->seq1) -
+ seq->seq1->start),
1.0f));
}
}
@@ -430,7 +430,7 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
}
else {
v->speed_control_type = SEQ_SPEED_FRAME_NUMBER;
- v->speed_fader_frame_number = (int)(seq->speed_fader * globalSpeed);
+ v->speed_fader_frame_number = int(seq->speed_fader * globalSpeed);
substr = "speed_frame_number";
}
diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc
index 6b7c4489eee..757bce97bf1 100644
--- a/source/blender/blenloader/intern/writefile.cc
+++ b/source/blender/blenloader/intern/writefile.cc
@@ -685,7 +685,7 @@ static void writestruct_at_address_nr(
}
mywrite(wd, &bh, sizeof(BHead));
- mywrite(wd, data, (size_t)bh.len);
+ mywrite(wd, data, size_t(bh.len));
}
static void writestruct_nr(
@@ -709,14 +709,14 @@ static void writedata(WriteData *wd, int filecode, size_t len, const void *adr)
}
/* align to 4 (writes uninitialized bytes in some cases) */
- len = (len + 3) & ~((size_t)3);
+ len = (len + 3) & ~size_t(3);
/* init BHead */
bh.code = filecode;
bh.old = adr;
bh.nr = 1;
bh.SDNAnr = 0;
- bh.len = (int)len;
+ bh.len = int(len);
mywrite(wd, &bh, sizeof(BHead));
mywrite(wd, adr, len);