diff options
| author | 2018-10-09 14:42:49 -0400 | |
|---|---|---|
| committer | 2018-10-09 14:46:26 -0400 | |
| commit | 8723cc87982825754f314b0c18910319a3ced716 (patch) | |
| tree | 8b6446d7ff58f9c272202024dfe53a1831517b76 /src/core/telemetry_session.cpp | |
| parent | Merge pull request #1423 from DarkLordZach/romfs-file-exts (diff) | |
| download | yuzu-8723cc87982825754f314b0c18910319a3ced716.tar.gz yuzu-8723cc87982825754f314b0c18910319a3ced716.tar.xz yuzu-8723cc87982825754f314b0c18910319a3ced716.zip | |
telemetry_session: Use a std::array in GenerateTelemetryId()
We don't need to potentially heap-allocate a std::string instance here,
given the data is known ahead of time. We can just place it within an
array and pass this to the mbedtls functions.
Diffstat (limited to 'src/core/telemetry_session.cpp')
| -rw-r--r-- | src/core/telemetry_session.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index f29fff1e7..68edb24f5 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | ||
| 6 | |||
| 5 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 6 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 7 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| @@ -28,11 +30,11 @@ static u64 GenerateTelemetryId() { | |||
| 28 | mbedtls_entropy_context entropy; | 30 | mbedtls_entropy_context entropy; |
| 29 | mbedtls_entropy_init(&entropy); | 31 | mbedtls_entropy_init(&entropy); |
| 30 | mbedtls_ctr_drbg_context ctr_drbg; | 32 | mbedtls_ctr_drbg_context ctr_drbg; |
| 31 | std::string personalization = "yuzu Telemetry ID"; | 33 | constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}}; |
| 32 | 34 | ||
| 33 | mbedtls_ctr_drbg_init(&ctr_drbg); | 35 | mbedtls_ctr_drbg_init(&ctr_drbg); |
| 34 | ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, | 36 | ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, |
| 35 | reinterpret_cast<const unsigned char*>(personalization.c_str()), | 37 | reinterpret_cast<const unsigned char*>(personalization.data()), |
| 36 | personalization.size()) == 0); | 38 | personalization.size()) == 0); |
| 37 | ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id), | 39 | ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id), |
| 38 | sizeof(u64)) == 0); | 40 | sizeof(u64)) == 0); |