Skip to content

Commit 898e0fa

Browse files
Add utility for getting the string representation of a UUID
Allows for the loader_log call to not have 16+ parameters.
1 parent 50399a2 commit 898e0fa

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

loader/log.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,10 @@ void loader_log_asm_function_not_supported(const struct loader_instance *inst, V
274274
const char *func_name) {
275275
loader_log(inst, msg_type, msg_code, "Function %s not supported for this physical device", func_name);
276276
}
277+
278+
void loader_log_generate_uuid_string(const uint8_t uuid[16], char output[UUID_STR_LEN]) {
279+
assert(uuid && output);
280+
snprintf(output, UUID_STR_LEN, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", uuid[0], uuid[1],
281+
uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13],
282+
uuid[14], uuid[15]);
283+
}

loader/log.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ void loader_log_asm_function_not_supported(const struct loader_instance *inst, V
8383
const char *func_name) ASM_NAME("loader_log_asm_function_not_supported");
8484

8585
#undef ASM_NAME
86+
87+
#define UUID_STR_LEN 37 // always 32 digits, 4 dashes, and 1 null terminator
88+
89+
void loader_log_generate_uuid_string(const uint8_t uuid[16], char output[UUID_STR_LEN]);

0 commit comments

Comments
 (0)