X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fuuid.cpp;h=dd59edc31c79e532f6b14bb8caa84d731fa430ef;hb=52cb8c0f651ade8d057a264eea1de534ead36517;hp=a820a8a4191defbef75ae63c2085540f8f5dfcae;hpb=328c2fe7297c941aa9cbcfa4ce944fca1bd7300f;p=lttng-tools.git diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index a820a8a41..dd59edc31 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp @@ -26,6 +26,18 @@ void lttng_uuid_to_str(const lttng_uuid& uuid, char *uuid_str) sprintf(uuid_str, LTTNG_UUID_FMT, LTTNG_UUID_FMT_VALUES(uuid)); } +std::string lttng::utils::uuid_to_str(const lttng_uuid& uuid) +{ + std::string uuid_str(LTTNG_UUID_STR_LEN, '\0'); + + ::lttng_uuid_to_str(uuid, &uuid_str[0]); + + /* Don't include '\0' in the C++ string. */ + uuid_str.resize(uuid_str.size() - 1); + + return uuid_str; +} + int lttng_uuid_from_str(const char *str_in, lttng_uuid& uuid_out) { int ret = 0; @@ -45,6 +57,7 @@ int lttng_uuid_from_str(const char *str_in, lttng_uuid& uuid_out) if (sscanf(str_in, LTTNG_UUID_FMT, LTTNG_UUID_SCAN_VALUES(uuid_scan)) != LTTNG_UUID_LEN) { ret = -1; + goto end; } uuid_out = uuid_scan;