aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/uuid.cxx23
-rw-r--r--libbutl/uuid.hxx16
2 files changed, 20 insertions, 19 deletions
diff --git a/libbutl/uuid.cxx b/libbutl/uuid.cxx
index 377afb7..2132808 100644
--- a/libbutl/uuid.cxx
+++ b/libbutl/uuid.cxx
@@ -5,7 +5,7 @@
#include <errno.h> // ENOTSUP
-#include <cstdio> // sprintf() scanf()
+#include <cstdio> // snprintf() sscanf()
#include <cstring> // strlen()
#include <stdexcept>
#include <system_error>
@@ -19,16 +19,17 @@ namespace butl
{
array<char, 37> r;
- sprintf (r.data (),
- (upper
- ? "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"
- : "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),
- time_low,
- time_mid,
- time_hiv,
- clock_seq_hir,
- clock_seq_low,
- node[0], node[1], node[2], node[3], node[4], node[5]);
+ snprintf (r.data (),
+ 37,
+ (upper
+ ? "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"
+ : "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),
+ time_low,
+ time_mid,
+ time_hiv,
+ clock_seq_hir,
+ clock_seq_low,
+ node[0], node[1], node[2], node[3], node[4], node[5]);
return r;
}
diff --git a/libbutl/uuid.hxx b/libbutl/uuid.hxx
index 47a814c..862f02d 100644
--- a/libbutl/uuid.hxx
+++ b/libbutl/uuid.hxx
@@ -48,12 +48,12 @@ namespace butl
{
// Normally not accessed directly (see RFC4122 Section 4.1.2).
//
- std::uint32_t time_low = 0;
- std::uint16_t time_mid = 0;
- std::uint16_t time_hiv = 0; // hi_and_version
- std::uint8_t clock_seq_hir = 0; // hi_and_reserved
- std::uint8_t clock_seq_low = 0;
- std::uint8_t node[6] = {0, 0, 0, 0, 0, 0};
+ std::uint32_t time_low = 0;
+ std::uint16_t time_mid = 0;
+ std::uint16_t time_hiv = 0; // hi_and_version
+ std::uint8_t clock_seq_hir = 0; // hi_and_reserved
+ std::uint8_t clock_seq_low = 0;
+ std::uint8_t node[6] = {0, 0, 0, 0, 0, 0};
// System UUID generator. See the uuid_generator interface for details.
//
@@ -183,7 +183,7 @@ namespace butl
~uuid_generator () = default;
// Generate a UUID. If strong is true (default), generate a strongly-
- // unique UUID. Throw std::runtime_error to report errors, including if
+ // unique UUID. Throw std::system_error to report errors, including if
// strong uniqueness cannot be guaranteed.
//
// A weak UUID is not guaranteed to be unique, neither universialy nor
@@ -207,7 +207,7 @@ namespace butl
// Optional explicit initialization and termination. Note that it is not
// thread-safe and must only be performed once (normally from main())
// before/after any calls to generate(), respectively. Both functions may
- // throw std::runtime_error to report errors.
+ // throw std::system_error to report errors.
//
static void
initialize ();