Skip to content

Commit 85b5586

Browse files
committed
tree-wide: port everything over to new sd-id128 compund literal bliss
1 parent c970388 commit 85b5586

File tree

28 files changed

+101
-162
lines changed

28 files changed

+101
-162
lines changed

src/boot/bootctl.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ static int remove_subdirs(const char *root, const char *const *subdirs) {
918918

919919
static int remove_machine_id_directory(const char *root) {
920920
sd_id128_t machine_id;
921-
char buf[SD_ID128_STRING_MAX];
922921
int r;
923922

924923
assert(root);
@@ -931,7 +930,7 @@ static int remove_machine_id_directory(const char *root) {
931930
if (r < 0)
932931
return log_error_errno(r, "Failed to get machine id: %m");
933932

934-
return rmdir_one(root, sd_id128_to_string(machine_id, buf));
933+
return rmdir_one(root, SD_ID128_TO_STRING(machine_id));
935934
}
936935

937936
static int remove_binaries(const char *esp_path) {
@@ -1020,8 +1019,6 @@ static int install_loader_config(const char *esp_path) {
10201019
_cleanup_(unlink_and_freep) char *t = NULL;
10211020
_cleanup_fclose_ FILE *f = NULL;
10221021
_cleanup_close_ int fd = -1;
1023-
sd_id128_t machine_id;
1024-
char machine_string[SD_ID128_STRING_MAX];
10251022
const char *p;
10261023
int r;
10271024

@@ -1041,12 +1038,15 @@ static int install_loader_config(const char *esp_path) {
10411038

10421039
fprintf(f, "#timeout 3\n"
10431040
"#console-mode keep\n");
1041+
10441042
if (arg_make_machine_id_directory) {
1043+
sd_id128_t machine_id;
1044+
10451045
r = sd_id128_get_machine(&machine_id);
10461046
if (r < 0)
10471047
return log_error_errno(r, "Failed to get machine id: %m");
10481048

1049-
fprintf(f, "default %s-*\n", sd_id128_to_string(machine_id, machine_string));
1049+
fprintf(f, "default %s-*\n", SD_ID128_TO_STRING(machine_id));
10501050
}
10511051

10521052
r = fflush_sync_and_check(f);
@@ -1065,7 +1065,6 @@ static int install_loader_config(const char *esp_path) {
10651065

10661066
static int install_machine_id_directory(const char *root) {
10671067
sd_id128_t machine_id;
1068-
char buf[SD_ID128_STRING_MAX];
10691068
int r;
10701069

10711070
assert(root);
@@ -1078,7 +1077,7 @@ static int install_machine_id_directory(const char *root) {
10781077
if (r < 0)
10791078
return log_error_errno(r, "Failed to get machine id: %m");
10801079

1081-
return mkdir_one(root, sd_id128_to_string(machine_id, buf));
1080+
return mkdir_one(root, SD_ID128_TO_STRING(machine_id));
10821081
}
10831082

10841083
static int help(int argc, char *argv[], void *userdata) {

src/busctl/busctl.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
339339
if (r < 0)
340340
log_debug_errno(r, "Failed to acquire credentials of service %s, ignoring: %m", k);
341341
else {
342-
char m[SD_ID128_STRING_MAX];
343-
344-
r = table_add_cell(table, NULL, TABLE_STRING, sd_id128_to_string(mid, m));
342+
r = table_add_cell(table, NULL, TABLE_ID128, &mid);
345343
if (r < 0)
346344
return table_log_add_error(r);
347345

src/core/cgroup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ void cgroup_oomd_xattr_apply(Unit *u, const char *cgroup_path) {
738738
}
739739

740740
static void cgroup_xattr_apply(Unit *u) {
741-
char ids[SD_ID128_STRING_MAX];
742741
int r;
743742

744743
assert(u);
@@ -749,7 +748,7 @@ static void cgroup_xattr_apply(Unit *u) {
749748
if (!sd_id128_is_null(u->invocation_id)) {
750749
r = cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path,
751750
"trusted.invocation_id",
752-
sd_id128_to_string(u->invocation_id, ids), 32,
751+
SD_ID128_TO_STRING(u->invocation_id), 32,
753752
0);
754753
if (r < 0)
755754
log_unit_debug_errno(u, r, "Failed to set invocation ID on control group %s, ignoring: %m", empty_to_root(u->cgroup_path));

src/core/namespace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,6 @@ static int make_tmp_prefix(const char *prefix) {
24972497
static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, char **tmp_path) {
24982498
_cleanup_free_ char *x = NULL;
24992499
_cleanup_free_ char *y = NULL;
2500-
char bid[SD_ID128_STRING_MAX];
25012500
sd_id128_t boot_id;
25022501
bool rw = true;
25032502
int r;
@@ -2513,7 +2512,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, ch
25132512
if (r < 0)
25142513
return r;
25152514

2516-
x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX");
2515+
x = strjoin(prefix, "/systemd-private-", SD_ID128_TO_STRING(boot_id), "-", id, "-XXXXXX");
25172516
if (!x)
25182517
return -ENOMEM;
25192518

src/firstboot/firstboot.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ static int process_hostname(void) {
566566

567567
static int process_machine_id(void) {
568568
const char *etc_machine_id;
569-
char id[SD_ID128_STRING_MAX];
570569
int r;
571570

572571
etc_machine_id = prefix_roota(arg_root, "/etc/machine-id");
@@ -576,7 +575,7 @@ static int process_machine_id(void) {
576575
if (sd_id128_is_null(arg_machine_id))
577576
return 0;
578577

579-
r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id),
578+
r = write_string_file(etc_machine_id, SD_ID128_TO_STRING(arg_machine_id),
580579
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755 |
581580
(arg_force ? WRITE_STRING_FILE_ATOMIC : 0));
582581
if (r < 0)

src/home/homectl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,14 +817,13 @@ static int apply_identity_changes(JsonVariant **_v) {
817817

818818
if (arg_identity_extra_this_machine || !strv_isempty(arg_identity_filter)) {
819819
_cleanup_(json_variant_unrefp) JsonVariant *per_machine = NULL, *mmid = NULL;
820-
char mids[SD_ID128_STRING_MAX];
821820
sd_id128_t mid;
822821

823822
r = sd_id128_get_machine(&mid);
824823
if (r < 0)
825824
return log_error_errno(r, "Failed to acquire machine ID: %m");
826825

827-
r = json_variant_new_string(&mmid, sd_id128_to_string(mid, mids));
826+
r = json_variant_new_string(&mmid, SD_ID128_TO_STRING(mid));
828827
if (r < 0)
829828
return log_error_errno(r, "Failed to allocate matchMachineId object: %m");
830829

src/home/homed-home.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,6 @@ int home_augment_status(
21632163
uint64_t disk_size = UINT64_MAX, disk_usage = UINT64_MAX, disk_free = UINT64_MAX, disk_ceiling = UINT64_MAX, disk_floor = UINT64_MAX;
21642164
_cleanup_(json_variant_unrefp) JsonVariant *j = NULL, *v = NULL, *m = NULL, *status = NULL;
21652165
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;
2166-
char ids[SD_ID128_STRING_MAX];
21672166
HomeState state;
21682167
sd_id128_t id;
21692168
int r;
@@ -2227,7 +2226,7 @@ int home_augment_status(
22272226

22282227
j = json_variant_ref(h->record->json);
22292228
v = json_variant_ref(json_variant_by_key(j, "status"));
2230-
m = json_variant_ref(json_variant_by_key(v, sd_id128_to_string(id, ids)));
2229+
m = json_variant_ref(json_variant_by_key(v, SD_ID128_TO_STRING(id)));
22312230

22322231
r = json_variant_filter(&m, STRV_MAKE("diskSize", "diskUsage", "diskFree", "diskCeiling", "diskFloor", "signedLocally"));
22332232
if (r < 0)
@@ -2237,7 +2236,7 @@ int home_augment_status(
22372236
if (r < 0)
22382237
return r;
22392238

2240-
r = json_variant_set_field(&v, ids, m);
2239+
r = json_variant_set_field(&v, SD_ID128_TO_STRING(id), m);
22412240
if (r < 0)
22422241
return r;
22432242

src/home/homework-luks.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,10 +1487,10 @@ static int luks_format(
14871487
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
14881488
_cleanup_(erase_and_freep) void *volume_key = NULL;
14891489
struct crypt_pbkdf_type good_pbkdf, minimal_pbkdf;
1490-
char suuid[ID128_UUID_STRING_MAX], **pp;
14911490
_cleanup_free_ char *text = NULL;
14921491
size_t volume_key_size;
14931492
int slot = 0, r;
1493+
char **pp;
14941494

14951495
assert(node);
14961496
assert(dm_name);
@@ -1526,19 +1526,20 @@ static int luks_format(
15261526
build_good_pbkdf(&good_pbkdf, hr);
15271527
build_minimal_pbkdf(&minimal_pbkdf, hr);
15281528

1529-
r = sym_crypt_format(cd,
1530-
CRYPT_LUKS2,
1531-
user_record_luks_cipher(hr),
1532-
user_record_luks_cipher_mode(hr),
1533-
id128_to_uuid_string(uuid, suuid),
1534-
volume_key,
1535-
volume_key_size,
1536-
&(struct crypt_params_luks2) {
1537-
.label = label,
1538-
.subsystem = "systemd-home",
1539-
.sector_size = 512U,
1540-
.pbkdf = &good_pbkdf,
1541-
});
1529+
r = sym_crypt_format(
1530+
cd,
1531+
CRYPT_LUKS2,
1532+
user_record_luks_cipher(hr),
1533+
user_record_luks_cipher_mode(hr),
1534+
ID128_TO_UUID_STRING(uuid),
1535+
volume_key,
1536+
volume_key_size,
1537+
&(struct crypt_params_luks2) {
1538+
.label = label,
1539+
.subsystem = "systemd-home",
1540+
.sector_size = 512U,
1541+
.pbkdf = &good_pbkdf,
1542+
});
15421543
if (r < 0)
15431544
return log_error_errno(r, "Failed to format LUKS image: %m");
15441545

@@ -1621,7 +1622,6 @@ static int make_partition_table(
16211622
_cleanup_free_ char *path = NULL, *disk_uuid_as_string = NULL;
16221623
uint64_t offset, size;
16231624
sd_id128_t disk_uuid;
1624-
char uuids[ID128_UUID_STRING_MAX];
16251625
int r;
16261626

16271627
assert(fd >= 0);
@@ -1676,7 +1676,7 @@ static int make_partition_table(
16761676
if (r < 0)
16771677
return log_error_errno(r, "Failed to set partition name: %m");
16781678

1679-
r = fdisk_partition_set_uuid(p, id128_to_uuid_string(uuid, uuids));
1679+
r = fdisk_partition_set_uuid(p, ID128_TO_UUID_STRING(uuid));
16801680
if (r < 0)
16811681
return log_error_errno(r, "Failed to set partition UUID: %m");
16821682

0 commit comments

Comments
 (0)