Skip to content

Commit 0ee0d16

Browse files
committed
Rename UUID constants and remove hal namespace
Refactor uuid.cpp for style and clarity: rename UUID_STRING_LENGTH and cmd to kUuidStringLength and kCmd, respectively; reformat indentation and align preprocessor blocks; and remove the surrounding hal namespace. Functionality is preserved (UUID parsing and machine-id handling unchanged).
1 parent 60d48ef commit 0ee0d16

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

‎lib-linux/src/uuid.cpp‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,41 @@
2929

3030
#include "exec_cmd.h"
3131

32-
namespace hal {
33-
static constexpr auto UUID_STRING_LENGTH = 36;
32+
static constexpr auto kUuidStringLength = 36;
3433

3534
void UuidCopy(uuid_t out) {
36-
char uuid_str[hal::UUID_STRING_LENGTH + 2];
35+
char uuid_str[kUuidStringLength + 2];
3736

38-
#if defined (__APPLE__)
39-
constexpr char cmd[] = "sysctl -n kern.uuid";
37+
#if defined(__APPLE__)
38+
constexpr char kCmd[] = "sysctl -n kern.uuid";
4039
#else
41-
constexpr char cmd[] = "cat /etc/machine-id";
40+
constexpr char kCmd[] = "cat /etc/machine-id";
4241
#endif
43-
exec_cmd(cmd, uuid_str, sizeof(uuid_str));
42+
exec_cmd(kCmd, uuid_str, sizeof(uuid_str));
4443

45-
#if defined (__APPLE__)
44+
#if defined(__APPLE__)
4645
#else
47-
for (uint32_t i = 13; i > 0; i--) {
48-
uuid_str[36 - 13 + i] = uuid_str[36 - 13 + i - 4];
49-
}
46+
for (uint32_t i = 13; i > 0; i--) {
47+
uuid_str[36 - 13 + i] = uuid_str[36 - 13 + i - 4];
48+
}
5049

51-
for (uint32_t i = 5; i > 0; i--) {
52-
uuid_str[23 - 5 + i] = uuid_str[23 - 5 + i - 3];
53-
}
50+
for (uint32_t i = 5; i > 0; i--) {
51+
uuid_str[23 - 5 + i] = uuid_str[23 - 5 + i - 3];
52+
}
5453

55-
for (uint32_t i = 5; i > 0; i--) {
56-
uuid_str[18 - 5 + i] = uuid_str[18 - 5 + i - 2];
57-
}
54+
for (uint32_t i = 5; i > 0; i--) {
55+
uuid_str[18 - 5 + i] = uuid_str[18 - 5 + i - 2];
56+
}
5857

59-
for (uint32_t i = 5; i > 0; i--) {
60-
uuid_str[13 - 5 + i] = uuid_str[13 - 5 + i - 1];
61-
}
58+
for (uint32_t i = 5; i > 0; i--) {
59+
uuid_str[13 - 5 + i] = uuid_str[13 - 5 + i - 1];
60+
}
6261

63-
uuid_str[23] = '-';
64-
uuid_str[18] = '-';
65-
uuid_str[13] = '-';
66-
uuid_str[8] = '-';
62+
uuid_str[23] = '-';
63+
uuid_str[18] = '-';
64+
uuid_str[13] = '-';
65+
uuid_str[8] = '-';
6766
#endif
6867

69-
uuid_parse(uuid_str, out);
68+
uuid_parse(uuid_str, out);
7069
}
71-
} // namespace hal

0 commit comments

Comments
 (0)