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-02-08 03:50:14 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-02-21 12:30:43 +0300
commit05f631b7ad6c4f06defc0792bd7e59aad5def7ee (patch)
tree7bbac1a2cb8613c390802556f39be9f1f2291a11
parent3cfccf11997e9dc2f07000b9d802f0a6038e8ec1 (diff)
Cleanup: use an intermediate value for cast_primitive_type
Assign the actual value before casting to large uint64_t/double types. This improves readability, especially in cases where both pointer and integer casts were used in one expression, to make matters worse clang-format treated these casts as a multiplication. This also made debugging/printing the values more of a hassle. No functional changes (GCC produced identical output).
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 6c88d5f7230..f7f3d8e0eb4 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -756,45 +756,65 @@ static void cast_primitive_type(const eSDNA_Type old_type,
for (int a = 0; a < array_len; a++) {
switch (old_type) {
- case SDNA_TYPE_CHAR:
- old_value_i = *old_data;
+ case SDNA_TYPE_CHAR: {
+ const char value = *old_data;
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_UCHAR:
- old_value_i = *((unsigned char *)old_data);
+ }
+ case SDNA_TYPE_UCHAR: {
+ const uchar value = *((uchar *)old_data);
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_SHORT:
- old_value_i = *((short *)old_data);
+ }
+ case SDNA_TYPE_SHORT: {
+ const short value = *((short *)old_data);
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_USHORT:
- old_value_i = *((unsigned short *)old_data);
+ }
+ case SDNA_TYPE_USHORT: {
+ const ushort value = *((unsigned short *)old_data);
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_INT:
- old_value_i = *((int *)old_data);
+ }
+ case SDNA_TYPE_INT: {
+ const int value = *((int *)old_data);
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_FLOAT:
- old_value_f = *((float *)old_data);
+ }
+ case SDNA_TYPE_FLOAT: {
+ const float value = *((float *)old_data);
+ old_value_f = value;
old_value_i = (uint64_t)(int64_t)old_value_f;
break;
- case SDNA_TYPE_DOUBLE:
- old_value_f = *((double *)old_data);
+ }
+ case SDNA_TYPE_DOUBLE: {
+ const double value = *((double *)old_data);
+ old_value_f = value;
old_value_i = (uint64_t)(int64_t)old_value_f;
break;
- case SDNA_TYPE_INT64:
- old_value_i = (uint64_t) * ((int64_t *)old_data);
+ }
+ case SDNA_TYPE_INT64: {
+ const int64_t value = *((int64_t *)old_data);
+ old_value_i = (uint64_t)value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_UINT64:
- old_value_i = *((uint64_t *)old_data);
+ }
+ case SDNA_TYPE_UINT64: {
+ const uint64_t value = *((uint64_t *)old_data);
+ old_value_i = value;
old_value_f = (double)old_value_i;
break;
- case SDNA_TYPE_INT8:
- old_value_i = (uint64_t) * ((int8_t *)old_data);
+ }
+ case SDNA_TYPE_INT8: {
+ const int8_t value = *((int8_t *)old_data);
+ old_value_i = (uint64_t)value;
old_value_f = (double)old_value_i;
+ }
}
switch (new_type) {