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:
authorSybren A. Stüvel <sybren@blender.org>2021-09-17 15:51:34 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-09-17 15:51:43 +0300
commit8ee7f62a635f2df24be96e5102c69b4783b0cdfc (patch)
tree3f2a79dcb71861f1f4efd68ecfce33540ff9251f
parent365443412c87c568cb46a8c94cb63bcb78355250 (diff)
Cleanup: clang-tidy warnings in UUID code
Use C++ version of C headers, and avoid static function call on instance. No functional changes.
-rw-r--r--source/blender/blenlib/intern/uuid.cc62
1 files changed, 32 insertions, 30 deletions
diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc
index a0fbc1a61ff..7f1ec0e677b 100644
--- a/source/blender/blenlib/intern/uuid.cc
+++ b/source/blender/blenlib/intern/uuid.cc
@@ -20,8 +20,9 @@
#include "BLI_uuid.h"
+#include <cstdio>
+#include <cstring>
#include <random>
-#include <string.h>
/* Ensure the UUID struct doesn't have any padding, to be compatible with memcmp(). */
static_assert(sizeof(UUID) == 16, "expect UUIDs to be 128 bit exactly");
@@ -32,8 +33,8 @@ UUID BLI_uuid_generate_random()
std::mt19937_64 rng;
/* Ensure the RNG really can output 64-bit values. */
- static_assert(rng.min() == 0LL);
- static_assert(rng.max() == 0xffffffffffffffffLL);
+ static_assert(std::mt19937_64::min() == 0LL);
+ static_assert(std::mt19937_64::max() == 0xffffffffffffffffLL);
struct timespec ts;
timespec_get(&ts, TIME_UTC);
@@ -65,41 +66,42 @@ UUID BLI_uuid_generate_random()
bool BLI_uuid_equal(const UUID uuid1, const UUID uuid2)
{
- return memcmp(&uuid1, &uuid2, sizeof(uuid1)) == 0;
+ return std::memcmp(&uuid1, &uuid2, sizeof(uuid1)) == 0;
}
void BLI_uuid_format(char *buffer, const UUID uuid)
{
- sprintf(buffer,
- "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- uuid.time_low,
- uuid.time_mid,
- uuid.time_hi_and_version,
- uuid.clock_seq_hi_and_reserved,
- uuid.clock_seq_low,
- uuid.node[0],
- uuid.node[1],
- uuid.node[2],
- uuid.node[3],
- uuid.node[4],
- uuid.node[5]);
+ std::sprintf(buffer,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid.time_low,
+ uuid.time_mid,
+ uuid.time_hi_and_version,
+ uuid.clock_seq_hi_and_reserved,
+ uuid.clock_seq_low,
+ uuid.node[0],
+ uuid.node[1],
+ uuid.node[2],
+ uuid.node[3],
+ uuid.node[4],
+ uuid.node[5]);
}
bool BLI_uuid_parse_string(UUID *uuid, const char *buffer)
{
- const int num_fields_parsed = sscanf(buffer,
- "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
- &uuid->time_low,
- &uuid->time_mid,
- &uuid->time_hi_and_version,
- &uuid->clock_seq_hi_and_reserved,
- &uuid->clock_seq_low,
- &uuid->node[0],
- &uuid->node[1],
- &uuid->node[2],
- &uuid->node[3],
- &uuid->node[4],
- &uuid->node[5]);
+ const int num_fields_parsed = std::sscanf(
+ buffer,
+ "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
+ &uuid->time_low,
+ &uuid->time_mid,
+ &uuid->time_hi_and_version,
+ &uuid->clock_seq_hi_and_reserved,
+ &uuid->clock_seq_low,
+ &uuid->node[0],
+ &uuid->node[1],
+ &uuid->node[2],
+ &uuid->node[3],
+ &uuid->node[4],
+ &uuid->node[5]);
return num_fields_parsed == 11;
}