Skip to content

Commit b5ea030

Browse files
committed
id128: introduce ID128_UUID_STRING_MAX for sizing UUID buffers
1 parent dd1b315 commit b5ea030

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

src/libsystemd/sd-id128/id128-util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "io-util.h"
1212
#include "stdio-util.h"
1313

14-
char *id128_to_uuid_string(sd_id128_t id, char s[37]) {
14+
char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]) {
1515
unsigned n, k = 0;
1616

1717
assert(s);

src/libsystemd/sd-id128/id128-util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "hash-funcs.h"
99
#include "macro.h"
1010

11-
char *id128_to_uuid_string(sd_id128_t id, char s[37]);
11+
#define ID128_UUID_STRING_MAX 37
12+
13+
char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]);
1214

1315
bool id128_is_valid(const char *s) _pure_;
1416

src/nspawn/nspawn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ static int inner_child(
28662866
FDSet *fds) {
28672867

28682868
_cleanup_free_ char *home = NULL;
2869-
char as_uuid[37];
2869+
char as_uuid[ID128_UUID_STRING_MAX];
28702870
size_t n_env = 1;
28712871
const char *envp[] = {
28722872
"PATH=" DEFAULT_PATH_COMPAT,

src/shared/logs-show.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "format-util.h"
1818
#include "hashmap.h"
1919
#include "hostname-util.h"
20+
#include "id128-util.h"
2021
#include "io-util.h"
2122
#include "journal-internal.h"
2223
#include "json.h"
@@ -26,8 +27,8 @@
2627
#include "namespace-util.h"
2728
#include "output-mode.h"
2829
#include "parse-util.h"
29-
#include "process-util.h"
3030
#include "pretty-print.h"
31+
#include "process-util.h"
3132
#include "sparse-endian.h"
3233
#include "stdio-util.h"
3334
#include "string-table.h"
@@ -1353,8 +1354,8 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
13531354
static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) {
13541355
_cleanup_close_pair_ int pair[2] = { -1, -1 };
13551356
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
1357+
char buf[ID128_UUID_STRING_MAX];
13561358
pid_t pid, child;
1357-
char buf[37];
13581359
ssize_t k;
13591360
int r;
13601361

src/test/test-id128.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
int main(int argc, char *argv[]) {
2323
sd_id128_t id, id2;
24-
char t[33], q[37];
24+
char t[SD_ID128_STRING_MAX], q[ID128_UUID_STRING_MAX];
2525
_cleanup_free_ char *b = NULL;
2626
_cleanup_close_ int fd = -1;
2727
int r;

src/veritysetup/veritysetup-generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
166166
static int determine_devices(void) {
167167
_cleanup_free_ void *m = NULL;
168168
sd_id128_t root_uuid, verity_uuid;
169-
char ids[37];
169+
char ids[ID128_UUID_STRING_MAX];
170170
size_t l;
171171
int r;
172172

0 commit comments

Comments
 (0)