1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

tree-wide: port everything over to new sd-id128 compund literal bliss

This commit is contained in:
Lennart Poettering 2021-08-20 10:54:49 +02:00
parent c970388b22
commit 85b55869bc
28 changed files with 101 additions and 162 deletions

View File

@ -918,7 +918,6 @@ static int remove_subdirs(const char *root, const char *const *subdirs) {
static int remove_machine_id_directory(const char *root) {
sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r;
assert(root);
@ -931,7 +930,7 @@ static int remove_machine_id_directory(const char *root) {
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
return rmdir_one(root, sd_id128_to_string(machine_id, buf));
return rmdir_one(root, SD_ID128_TO_STRING(machine_id));
}
static int remove_binaries(const char *esp_path) {
@ -1020,8 +1019,6 @@ static int install_loader_config(const char *esp_path) {
_cleanup_(unlink_and_freep) char *t = NULL;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_close_ int fd = -1;
sd_id128_t machine_id;
char machine_string[SD_ID128_STRING_MAX];
const char *p;
int r;
@ -1041,12 +1038,15 @@ static int install_loader_config(const char *esp_path) {
fprintf(f, "#timeout 3\n"
"#console-mode keep\n");
if (arg_make_machine_id_directory) {
sd_id128_t machine_id;
r = sd_id128_get_machine(&machine_id);
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
fprintf(f, "default %s-*\n", sd_id128_to_string(machine_id, machine_string));
fprintf(f, "default %s-*\n", SD_ID128_TO_STRING(machine_id));
}
r = fflush_sync_and_check(f);
@ -1065,7 +1065,6 @@ static int install_loader_config(const char *esp_path) {
static int install_machine_id_directory(const char *root) {
sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r;
assert(root);
@ -1078,7 +1077,7 @@ static int install_machine_id_directory(const char *root) {
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
return mkdir_one(root, sd_id128_to_string(machine_id, buf));
return mkdir_one(root, SD_ID128_TO_STRING(machine_id));
}
static int help(int argc, char *argv[], void *userdata) {

View File

@ -339,9 +339,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
if (r < 0)
log_debug_errno(r, "Failed to acquire credentials of service %s, ignoring: %m", k);
else {
char m[SD_ID128_STRING_MAX];
r = table_add_cell(table, NULL, TABLE_STRING, sd_id128_to_string(mid, m));
r = table_add_cell(table, NULL, TABLE_ID128, &mid);
if (r < 0)
return table_log_add_error(r);

View File

@ -738,7 +738,6 @@ void cgroup_oomd_xattr_apply(Unit *u, const char *cgroup_path) {
}
static void cgroup_xattr_apply(Unit *u) {
char ids[SD_ID128_STRING_MAX];
int r;
assert(u);
@ -749,7 +748,7 @@ static void cgroup_xattr_apply(Unit *u) {
if (!sd_id128_is_null(u->invocation_id)) {
r = cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path,
"trusted.invocation_id",
sd_id128_to_string(u->invocation_id, ids), 32,
SD_ID128_TO_STRING(u->invocation_id), 32,
0);
if (r < 0)
log_unit_debug_errno(u, r, "Failed to set invocation ID on control group %s, ignoring: %m", empty_to_root(u->cgroup_path));

View File

@ -2497,7 +2497,6 @@ static int make_tmp_prefix(const char *prefix) {
static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, char **tmp_path) {
_cleanup_free_ char *x = NULL;
_cleanup_free_ char *y = NULL;
char bid[SD_ID128_STRING_MAX];
sd_id128_t boot_id;
bool rw = true;
int r;
@ -2513,7 +2512,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, ch
if (r < 0)
return r;
x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX");
x = strjoin(prefix, "/systemd-private-", SD_ID128_TO_STRING(boot_id), "-", id, "-XXXXXX");
if (!x)
return -ENOMEM;

View File

@ -566,7 +566,6 @@ static int process_hostname(void) {
static int process_machine_id(void) {
const char *etc_machine_id;
char id[SD_ID128_STRING_MAX];
int r;
etc_machine_id = prefix_roota(arg_root, "/etc/machine-id");
@ -576,7 +575,7 @@ static int process_machine_id(void) {
if (sd_id128_is_null(arg_machine_id))
return 0;
r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id),
r = write_string_file(etc_machine_id, SD_ID128_TO_STRING(arg_machine_id),
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755 |
(arg_force ? WRITE_STRING_FILE_ATOMIC : 0));
if (r < 0)

View File

@ -817,14 +817,13 @@ static int apply_identity_changes(JsonVariant **_v) {
if (arg_identity_extra_this_machine || !strv_isempty(arg_identity_filter)) {
_cleanup_(json_variant_unrefp) JsonVariant *per_machine = NULL, *mmid = NULL;
char mids[SD_ID128_STRING_MAX];
sd_id128_t mid;
r = sd_id128_get_machine(&mid);
if (r < 0)
return log_error_errno(r, "Failed to acquire machine ID: %m");
r = json_variant_new_string(&mmid, sd_id128_to_string(mid, mids));
r = json_variant_new_string(&mmid, SD_ID128_TO_STRING(mid));
if (r < 0)
return log_error_errno(r, "Failed to allocate matchMachineId object: %m");

View File

@ -2163,7 +2163,6 @@ int home_augment_status(
uint64_t disk_size = UINT64_MAX, disk_usage = UINT64_MAX, disk_free = UINT64_MAX, disk_ceiling = UINT64_MAX, disk_floor = UINT64_MAX;
_cleanup_(json_variant_unrefp) JsonVariant *j = NULL, *v = NULL, *m = NULL, *status = NULL;
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;
char ids[SD_ID128_STRING_MAX];
HomeState state;
sd_id128_t id;
int r;
@ -2227,7 +2226,7 @@ int home_augment_status(
j = json_variant_ref(h->record->json);
v = json_variant_ref(json_variant_by_key(j, "status"));
m = json_variant_ref(json_variant_by_key(v, sd_id128_to_string(id, ids)));
m = json_variant_ref(json_variant_by_key(v, SD_ID128_TO_STRING(id)));
r = json_variant_filter(&m, STRV_MAKE("diskSize", "diskUsage", "diskFree", "diskCeiling", "diskFloor", "signedLocally"));
if (r < 0)
@ -2237,7 +2236,7 @@ int home_augment_status(
if (r < 0)
return r;
r = json_variant_set_field(&v, ids, m);
r = json_variant_set_field(&v, SD_ID128_TO_STRING(id), m);
if (r < 0)
return r;

View File

@ -1487,10 +1487,10 @@ static int luks_format(
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
_cleanup_(erase_and_freep) void *volume_key = NULL;
struct crypt_pbkdf_type good_pbkdf, minimal_pbkdf;
char suuid[ID128_UUID_STRING_MAX], **pp;
_cleanup_free_ char *text = NULL;
size_t volume_key_size;
int slot = 0, r;
char **pp;
assert(node);
assert(dm_name);
@ -1526,19 +1526,20 @@ static int luks_format(
build_good_pbkdf(&good_pbkdf, hr);
build_minimal_pbkdf(&minimal_pbkdf, hr);
r = sym_crypt_format(cd,
CRYPT_LUKS2,
user_record_luks_cipher(hr),
user_record_luks_cipher_mode(hr),
id128_to_uuid_string(uuid, suuid),
volume_key,
volume_key_size,
&(struct crypt_params_luks2) {
.label = label,
.subsystem = "systemd-home",
.sector_size = 512U,
.pbkdf = &good_pbkdf,
});
r = sym_crypt_format(
cd,
CRYPT_LUKS2,
user_record_luks_cipher(hr),
user_record_luks_cipher_mode(hr),
ID128_TO_UUID_STRING(uuid),
volume_key,
volume_key_size,
&(struct crypt_params_luks2) {
.label = label,
.subsystem = "systemd-home",
.sector_size = 512U,
.pbkdf = &good_pbkdf,
});
if (r < 0)
return log_error_errno(r, "Failed to format LUKS image: %m");
@ -1621,7 +1622,6 @@ static int make_partition_table(
_cleanup_free_ char *path = NULL, *disk_uuid_as_string = NULL;
uint64_t offset, size;
sd_id128_t disk_uuid;
char uuids[ID128_UUID_STRING_MAX];
int r;
assert(fd >= 0);
@ -1676,7 +1676,7 @@ static int make_partition_table(
if (r < 0)
return log_error_errno(r, "Failed to set partition name: %m");
r = fdisk_partition_set_uuid(p, id128_to_uuid_string(uuid, uuids));
r = fdisk_partition_set_uuid(p, ID128_TO_UUID_STRING(uuid));
if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m");

View File

@ -24,7 +24,6 @@ int user_record_synthesize(
gid_t gid) {
_cleanup_free_ char *hd = NULL, *un = NULL, *ip = NULL, *rr = NULL, *user_name_and_realm = NULL;
char smid[SD_ID128_STRING_MAX];
sd_id128_t mid;
int r;
@ -86,7 +85,7 @@ int user_record_synthesize(
JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(realm)),
JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("regular")),
JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("imagePath", JSON_BUILD_STRING(image_path)),
JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING(hd)),
JSON_BUILD_PAIR("storage", JSON_BUILD_STRING(user_storage_to_string(storage))),
@ -109,7 +108,6 @@ int user_record_synthesize(
int group_record_synthesize(GroupRecord *g, UserRecord *h) {
_cleanup_free_ char *un = NULL, *rr = NULL, *group_name_and_realm = NULL, *description = NULL;
char smid[SD_ID128_STRING_MAX];
sd_id128_t mid;
int r;
@ -147,11 +145,11 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(rr)),
JSON_BUILD_PAIR("description", JSON_BUILD_STRING(description)),
JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
JSON_BUILD_PAIR("status", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Home"))))))));
if (r < 0)
return r;
@ -284,7 +282,6 @@ int user_record_add_binding(
gid_t gid) {
_cleanup_(json_variant_unrefp) JsonVariant *new_binding_entry = NULL, *binding = NULL;
char smid[SD_ID128_STRING_MAX], partition_uuids[ID128_UUID_STRING_MAX], luks_uuids[ID128_UUID_STRING_MAX], fs_uuids[ID128_UUID_STRING_MAX];
_cleanup_free_ char *ip = NULL, *hd = NULL, *ip_auto = NULL, *lc = NULL, *lcm = NULL, *fst = NULL;
sd_id128_t mid;
int r;
@ -297,7 +294,6 @@ int user_record_add_binding(
r = sd_id128_get_machine(&mid);
if (r < 0)
return r;
sd_id128_to_string(mid, smid);
if (image_path) {
ip = strdup(image_path);
@ -336,9 +332,9 @@ int user_record_add_binding(
r = json_build(&new_binding_entry,
JSON_BUILD_OBJECT(
JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", JSON_BUILD_STRING(image_path)),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", JSON_BUILD_STRING(id128_to_uuid_string(partition_uuid, partition_uuids))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", JSON_BUILD_STRING(id128_to_uuid_string(luks_uuid, luks_uuids))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", JSON_BUILD_STRING(id128_to_uuid_string(fs_uuid, fs_uuids))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(partition_uuid))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(luks_uuid))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(fs_uuid))),
JSON_BUILD_PAIR_CONDITION(!!luks_cipher, "luksCipher", JSON_BUILD_STRING(luks_cipher)),
JSON_BUILD_PAIR_CONDITION(!!luks_cipher_mode, "luksCipherMode", JSON_BUILD_STRING(luks_cipher_mode)),
JSON_BUILD_PAIR_CONDITION(luks_volume_key_size != UINT64_MAX, "luksVolumeKeySize", JSON_BUILD_UNSIGNED(luks_volume_key_size)),
@ -355,7 +351,7 @@ int user_record_add_binding(
_cleanup_(json_variant_unrefp) JsonVariant *be = NULL;
/* Merge the new entry with an old one, if that exists */
be = json_variant_ref(json_variant_by_key(binding, smid));
be = json_variant_ref(json_variant_by_key(binding, SD_ID128_TO_STRING(mid)));
if (be) {
r = json_variant_merge(&be, new_binding_entry);
if (r < 0)
@ -366,7 +362,7 @@ int user_record_add_binding(
}
}
r = json_variant_set_field(&binding, smid, new_binding_entry);
r = json_variant_set_field(&binding, SD_ID128_TO_STRING(mid), new_binding_entry);
if (r < 0)
return r;
@ -633,7 +629,6 @@ int user_record_test_recovery_key(UserRecord *h, UserRecord *secret) {
int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) {
_cleanup_(json_variant_unrefp) JsonVariant *new_per_machine = NULL, *midv = NULL, *midav = NULL, *ne = NULL;
_cleanup_free_ JsonVariant **array = NULL;
char smid[SD_ID128_STRING_MAX];
size_t idx = SIZE_MAX, n;
JsonVariant *per_machine;
sd_id128_t mid;
@ -651,9 +646,7 @@ int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) {
if (r < 0)
return r;
sd_id128_to_string(mid, smid);
r = json_variant_new_string(&midv, smid);
r = json_variant_new_string(&midv, SD_ID128_TO_STRING(mid));
if (r < 0)
return r;
@ -1208,7 +1201,6 @@ int user_record_merge_secret(UserRecord *h, UserRecord *secret) {
int user_record_good_authentication(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
uint64_t counter, usec;
sd_id128_t mid;
int r;
@ -1235,7 +1227,7 @@ int user_record_good_authentication(UserRecord *h) {
v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
r = json_variant_set_field_unsigned(&z, "goodAuthenticationCounter", counter);
if (r < 0)
@ -1245,7 +1237,7 @@ int user_record_good_authentication(UserRecord *h) {
if (r < 0)
return r;
r = json_variant_set_field(&w, buf, z);
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0)
return r;
@ -1265,7 +1257,6 @@ int user_record_good_authentication(UserRecord *h) {
int user_record_bad_authentication(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
uint64_t counter, usec;
sd_id128_t mid;
int r;
@ -1292,7 +1283,7 @@ int user_record_bad_authentication(UserRecord *h) {
v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
r = json_variant_set_field_unsigned(&z, "badAuthenticationCounter", counter);
if (r < 0)
@ -1302,7 +1293,7 @@ int user_record_bad_authentication(UserRecord *h) {
if (r < 0)
return r;
r = json_variant_set_field(&w, buf, z);
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0)
return r;
@ -1323,7 +1314,6 @@ int user_record_bad_authentication(UserRecord *h) {
int user_record_ratelimit(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
usec_t usec, new_ratelimit_begin_usec, new_ratelimit_count;
char buf[SD_ID128_STRING_MAX];
sd_id128_t mid;
int r;
@ -1355,7 +1345,7 @@ int user_record_ratelimit(UserRecord *h) {
v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
r = json_variant_set_field_unsigned(&z, "rateLimitBeginUSec", new_ratelimit_begin_usec);
if (r < 0)
@ -1365,7 +1355,7 @@ int user_record_ratelimit(UserRecord *h) {
if (r < 0)
return r;
r = json_variant_set_field(&w, buf, z);
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0)
return r;

View File

@ -103,14 +103,13 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
_fallthrough_;
case ENTRY_BOOT_ID: {
sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0)
return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos,
"_BOOT_ID=%s\n", sd_id128_to_string(boot_id, sid));
"_BOOT_ID=%s\n", SD_ID128_TO_STRING(boot_id));
assert(r >= 0);
if ((size_t) r > size - pos)
/* not enough space */

View File

@ -2873,7 +2873,6 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
r = sd_bus_message_new_method_return(m, &reply);
else if (streq_ptr(m->member, "GetMachineId")) {
sd_id128_t id;
char sid[SD_ID128_STRING_MAX];
r = sd_id128_get_machine(&id);
if (r < 0)
@ -2883,7 +2882,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
if (r < 0)
return r;
r = sd_bus_message_append(reply, "s", sd_id128_to_string(id, sid));
r = sd_bus_message_append(reply, "s", SD_ID128_TO_STRING(id));
} else {
r = sd_bus_message_new_method_errorf(
m, &reply,

View File

@ -2159,7 +2159,6 @@ _public_ int sd_device_trigger_with_uuid(
sd_device_action_t action,
sd_id128_t *ret_uuid) {
char buf[ID128_UUID_STRING_MAX];
const char *s, *j;
sd_id128_t u;
int r;
@ -2178,8 +2177,7 @@ _public_ int sd_device_trigger_with_uuid(
if (r < 0)
return r;
id128_to_uuid_string(u, buf);
j = strjoina(s, " ", buf);
j = strjoina(s, " ", ID128_TO_UUID_STRING(u));
r = sd_device_set_sysattr_value(device, "uevent", j);
if (r < 0)

View File

@ -3273,7 +3273,6 @@ fail:
#define FORMAT_TIMESTAMP_SAFE(t) (FORMAT_TIMESTAMP(t) ?: " --- ")
void journal_file_print_header(JournalFile *f) {
char a[SD_ID128_STRING_MAX], b[SD_ID128_STRING_MAX], c[SD_ID128_STRING_MAX], d[SD_ID128_STRING_MAX];
struct stat st;
assert(f);
@ -3300,10 +3299,10 @@ void journal_file_print_header(JournalFile *f) {
"Objects: %"PRIu64"\n"
"Entry objects: %"PRIu64"\n",
f->path,
sd_id128_to_string(f->header->file_id, a),
sd_id128_to_string(f->header->machine_id, b),
sd_id128_to_string(f->header->boot_id, c),
sd_id128_to_string(f->header->seqnum_id, d),
SD_ID128_TO_STRING(f->header->file_id),
SD_ID128_TO_STRING(f->header->machine_id),
SD_ID128_TO_STRING(f->header->boot_id),
SD_ID128_TO_STRING(f->header->seqnum_id),
f->header->state == STATE_OFFLINE ? "OFFLINE" :
f->header->state == STATE_ONLINE ? "ONLINE" :
f->header->state == STATE_ARCHIVED ? "ARCHIVED" : "UNKNOWN",

View File

@ -920,7 +920,6 @@ _public_ int sd_journal_previous_skip(sd_journal *j, uint64_t skip) {
_public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
Object *o;
int r;
char bid[SD_ID128_STRING_MAX], sid[SD_ID128_STRING_MAX];
assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD);
@ -933,13 +932,10 @@ _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
if (r < 0)
return r;
sd_id128_to_string(j->current_file->header->seqnum_id, sid);
sd_id128_to_string(o->entry.boot_id, bid);
if (asprintf(cursor,
"s=%s;i=%"PRIx64";b=%s;m=%"PRIx64";t=%"PRIx64";x=%"PRIx64,
sid, le64toh(o->entry.seqnum),
bid, le64toh(o->entry.monotonic),
SD_ID128_TO_STRING(j->current_file->header->seqnum_id), le64toh(o->entry.seqnum),
SD_ID128_TO_STRING(o->entry.boot_id), le64toh(o->entry.monotonic),
le64toh(o->entry.realtime),
le64toh(o->entry.xor_hash)) < 0)
return -ENOMEM;

View File

@ -127,7 +127,6 @@ static int run(int argc, char *argv[]) {
_cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
_cleanup_(decrypted_image_unrefp) DecryptedImage *decrypted_image = NULL;
_cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL;
char buf[SD_ID128_STRING_MAX];
sd_id128_t id;
int r;
@ -177,7 +176,7 @@ static int run(int argc, char *argv[]) {
}
if (arg_print)
puts(sd_id128_to_string(id, buf));
puts(SD_ID128_TO_STRING(id));
return 0;
}

View File

@ -281,7 +281,6 @@ static int lldp_send_packet(
}
static int link_send_lldp(Link *link) {
char machine_id_string[SD_ID128_STRING_MAX];
_cleanup_free_ char *hostname = NULL, *pretty_hostname = NULL;
_cleanup_free_ void *packet = NULL;
size_t packet_size = 0;
@ -313,7 +312,7 @@ static int link_send_lldp(Link *link) {
r = lldp_make_packet(link->network->lldp_emit,
&link->hw_addr.ether,
sd_id128_to_string(machine_id, machine_id_string),
SD_ID128_TO_STRING(machine_id),
link->ifname,
(uint16_t) ttl,
link->network ? link->network->description : NULL,

View File

@ -2550,7 +2550,6 @@ static int setup_hostname(void) {
static int setup_journal(const char *directory) {
_cleanup_free_ char *d = NULL;
char id[SD_ID128_STRING_MAX];
const char *dirname, *p, *q;
sd_id128_t this_id;
bool try;
@ -2571,7 +2570,7 @@ static int setup_journal(const char *directory) {
if (sd_id128_equal(arg_uuid, this_id)) {
log_full(try ? LOG_WARNING : LOG_ERR,
"Host and machine ids are equal (%s): refusing to link journals", sd_id128_to_string(arg_uuid, id));
"Host and machine ids are equal (%s): refusing to link journals", SD_ID128_TO_STRING(arg_uuid));
if (try)
return 0;
return -EEXIST;
@ -2587,9 +2586,7 @@ static int setup_journal(const char *directory) {
}
}
(void) sd_id128_to_string(arg_uuid, id);
p = strjoina("/var/log/journal/", id);
p = strjoina("/var/log/journal/", SD_ID128_TO_STRING(arg_uuid));
q = prefix_roota(directory, p);
if (path_is_mount_point(p, NULL, 0) > 0) {
@ -3183,7 +3180,6 @@ static int inner_child(
char **os_release_pairs) {
_cleanup_free_ char *home = NULL;
char as_uuid[ID128_UUID_STRING_MAX];
size_t n_env = 1;
char *envp[] = {
(char*) "PATH=" DEFAULT_PATH_COMPAT,
@ -3432,7 +3428,7 @@ static int inner_child(
assert(!sd_id128_is_null(arg_uuid));
if (asprintf(envp + n_env++, "container_uuid=%s", id128_to_uuid_string(arg_uuid, as_uuid)) < 0)
if (asprintf(envp + n_env++, "container_uuid=%s", ID128_TO_UUID_STRING(arg_uuid)) < 0)
return log_oom();
if (fdset_size(fds) > 0) {

View File

@ -2115,7 +2115,6 @@ static void context_bar_char_process_partition(
static int partition_hint(const Partition *p, const char *node, char **ret) {
_cleanup_free_ char *buf = NULL;
char ids[ID128_UUID_STRING_MAX];
const char *label;
sd_id128_t id;
@ -2144,7 +2143,7 @@ static int partition_hint(const Partition *p, const char *node, char **ret) {
else
id = p->type_uuid;
buf = strdup(id128_to_uuid_string(id, ids));
buf = strdup(ID128_TO_UUID_STRING(id));
done:
if (!buf)
@ -2544,7 +2543,6 @@ static int partition_encrypt(
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
_cleanup_(erase_and_freep) void *volume_key = NULL;
_cleanup_free_ char *dm_name = NULL, *vol = NULL;
char suuid[ID128_UUID_STRING_MAX];
size_t volume_key_size = 256 / 8;
sd_id128_t uuid;
int r;
@ -2591,7 +2589,7 @@ static int partition_encrypt(
CRYPT_LUKS2,
"aes",
"xts-plain64",
id128_to_uuid_string(uuid, suuid),
ID128_TO_UUID_STRING(uuid),
volume_key,
volume_key_size,
&(struct crypt_params_luks2) {
@ -3340,11 +3338,9 @@ static int context_mangle_partitions(Context *context) {
}
if (!sd_id128_equal(p->new_uuid, p->current_uuid)) {
char buf[ID128_UUID_STRING_MAX];
assert(!sd_id128_is_null(p->new_uuid));
r = fdisk_partition_set_uuid(p->current_partition, id128_to_uuid_string(p->new_uuid, buf));
r = fdisk_partition_set_uuid(p->current_partition, ID128_TO_UUID_STRING(p->new_uuid));
if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m");
@ -3371,7 +3367,6 @@ static int context_mangle_partitions(Context *context) {
} else {
_cleanup_(fdisk_unref_partitionp) struct fdisk_partition *q = NULL;
_cleanup_(fdisk_unref_parttypep) struct fdisk_parttype *t = NULL;
char ids[ID128_UUID_STRING_MAX];
assert(!p->new_partition);
assert(p->offset % 512 == 0);
@ -3383,7 +3378,7 @@ static int context_mangle_partitions(Context *context) {
if (!t)
return log_oom();
r = fdisk_parttype_set_typestr(t, id128_to_uuid_string(p->type_uuid, ids));
r = fdisk_parttype_set_typestr(t, ID128_TO_UUID_STRING(p->type_uuid));
if (r < 0)
return log_error_errno(r, "Failed to initialize partition type: %m");
@ -3411,7 +3406,7 @@ static int context_mangle_partitions(Context *context) {
if (r < 0)
return log_error_errno(r, "Failed to set partition number: %m");
r = fdisk_partition_set_uuid(q, id128_to_uuid_string(p->new_uuid, ids));
r = fdisk_partition_set_uuid(q, ID128_TO_UUID_STRING(p->new_uuid));
if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m");

View File

@ -2551,15 +2551,11 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
case TABLE_IN6_ADDR:
return json_variant_new_array_bytes(ret, &d->address, FAMILY_ADDRESS_SIZE(AF_INET6));
case TABLE_ID128: {
char buf[SD_ID128_STRING_MAX];
return json_variant_new_string(ret, sd_id128_to_string(d->id128, buf));
}
case TABLE_ID128:
return json_variant_new_string(ret, SD_ID128_TO_STRING(d->id128));
case TABLE_UUID: {
char buf[ID128_UUID_STRING_MAX];
return json_variant_new_string(ret, id128_to_uuid_string(d->id128, buf));
}
case TABLE_UUID:
return json_variant_new_string(ret, ID128_TO_UUID_STRING(d->id128));
case TABLE_UID:
if (!uid_is_valid(d->uid))

View File

@ -59,7 +59,6 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
{},
};
char smid[SD_ID128_STRING_MAX];
JsonVariant *m;
sd_id128_t mid;
int r;
@ -74,7 +73,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m)
return 0;
@ -146,7 +145,6 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
{},
};
char smid[SD_ID128_STRING_MAX];
JsonVariant *m;
sd_id128_t mid;
int r;
@ -161,7 +159,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m)
return 0;

View File

@ -447,9 +447,7 @@ int json_variant_new_hex(JsonVariant **ret, const void *p, size_t n) {
}
int json_variant_new_id128(JsonVariant **ret, sd_id128_t id) {
char s[SD_ID128_STRING_MAX];
return json_variant_new_string(ret, sd_id128_to_string(id, s));
return json_variant_new_string(ret, SD_ID128_TO_STRING(id));
}
static void json_variant_set(JsonVariant *a, JsonVariant *b) {

View File

@ -752,13 +752,12 @@ static int output_export(
const Set *output_fields,
const size_t highlight[2]) {
sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
int r;
usec_t realtime, monotonic;
_cleanup_free_ char *cursor = NULL;
usec_t realtime, monotonic;
sd_id128_t boot_id;
const void *data;
size_t length;
int r;
assert(j);
@ -784,7 +783,7 @@ static int output_export(
cursor,
realtime,
monotonic,
sd_id128_to_string(boot_id, sid));
SD_ID128_TO_STRING(boot_id));
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
size_t fieldlen;

View File

@ -65,31 +65,27 @@ int make_filesystem(
if (r < 0)
return r;
if (r == 0) {
char suuid[ID128_UUID_STRING_MAX];
/* Child */
id128_to_uuid_string(uuid, suuid);
if (streq(fstype, "ext4"))
(void) execlp(mkfs, mkfs,
"-L", label,
"-U", suuid,
"-I", "256",
"-O", "has_journal",
"-m", "0",
"-E", discard ? "lazy_itable_init=1,discard" : "lazy_itable_init=1,nodiscard",
node, NULL);
"-L", label,
"-U", ID128_TO_UUID_STRING(uuid),
"-I", "256",
"-O", "has_journal",
"-m", "0",
"-E", discard ? "lazy_itable_init=1,discard" : "lazy_itable_init=1,nodiscard",
node, NULL);
else if (streq(fstype, "btrfs")) {
if (discard)
(void) execlp(mkfs, mkfs, "-L", label, "-U", suuid, node, NULL);
(void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), node, NULL);
else
(void) execlp(mkfs, mkfs, "-L", label, "-U", suuid, "--nodiscard", node, NULL);
(void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), "--nodiscard", node, NULL);
} else if (streq(fstype, "xfs")) {
const char *j;
j = strjoina("uuid=", suuid);
j = strjoina("uuid=", ID128_TO_UUID_STRING(uuid));
if (discard)
(void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", node, NULL);
else
@ -118,9 +114,9 @@ int make_filesystem(
} else if (streq(fstype, "swap")) {
(void) execlp(mkfs, mkfs,
"-L", label,
"-U", suuid,
node, NULL);
"-L", label,
"-U", ID128_TO_UUID_STRING(uuid),
node, NULL);
} else
/* Generic fallback for all other file systems */

View File

@ -1127,7 +1127,6 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
{},
};
char smid[SD_ID128_STRING_MAX];
JsonVariant *m;
sd_id128_t mid;
int r;
@ -1142,7 +1141,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m)
return 0;
@ -1368,7 +1367,6 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
{},
};
char smid[SD_ID128_STRING_MAX];
JsonVariant *m;
sd_id128_t mid;
int r;
@ -1383,7 +1381,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m)
return 0;

View File

@ -237,16 +237,12 @@ static void test_condition_test_ac_power(void) {
static void test_condition_test_host(void) {
_cleanup_free_ char *hostname = NULL;
char sid[SD_ID128_STRING_MAX];
Condition *condition;
sd_id128_t id;
int r;
r = sd_id128_get_machine(&id);
assert_se(r >= 0);
assert_se(sd_id128_to_string(id, sid));
assert_se(sd_id128_get_machine(&id) >= 0);
condition = condition_new(CONDITION_HOST, sid, false, false);
condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), false, false);
assert_se(condition);
assert_se(condition_test(condition, environ) > 0);
condition_free(condition);
@ -256,7 +252,7 @@ static void test_condition_test_host(void) {
assert_se(condition_test(condition, environ) == 0);
condition_free(condition);
condition = condition_new(CONDITION_HOST, sid, false, true);
condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), false, true);
assert_se(condition);
assert_se(condition_test(condition, environ) == 0);
condition_free(condition);

View File

@ -200,9 +200,8 @@ static void test_protect_kernel_logs(void) {
}
int main(int argc, char *argv[]) {
sd_id128_t bid;
char boot_id[SD_ID128_STRING_MAX];
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL;
sd_id128_t bid;
test_setup_logging(LOG_INFO);
@ -214,16 +213,15 @@ int main(int argc, char *argv[]) {
}
assert_se(sd_id128_get_boot(&bid) >= 0);
sd_id128_to_string(bid, boot_id);
x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-");
y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-");
x = strjoin("/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-abcd.service-");
y = strjoin("/var/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-abcd.service-");
assert_se(x && y);
test_tmpdir("abcd.service", x, y);
z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
z = strjoin("/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
zz = strjoin("/var/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
assert_se(z && zz);

View File

@ -37,7 +37,6 @@ typedef struct LookupParameters {
static int add_nss_service(JsonVariant **v) {
_cleanup_(json_variant_unrefp) JsonVariant *status = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
sd_id128_t mid;
int r;
@ -54,7 +53,7 @@ static int add_nss_service(JsonVariant **v) {
return r;
status = json_variant_ref(json_variant_by_key(*v, "status"));
z = json_variant_ref(json_variant_by_key(status, sd_id128_to_string(mid, buf)));
z = json_variant_ref(json_variant_by_key(status, SD_ID128_TO_STRING(mid)));
if (json_variant_by_key(z, "service"))
return 0;
@ -63,7 +62,7 @@ static int add_nss_service(JsonVariant **v) {
if (r < 0)
return r;
r = json_variant_set_field(&status, buf, z);
r = json_variant_set_field(&status, SD_ID128_TO_STRING(mid), z);
if (r < 0)
return r;

View File

@ -194,7 +194,6 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
static int determine_devices(void) {
_cleanup_free_ void *m = NULL;
sd_id128_t root_uuid, verity_uuid;
char ids[ID128_UUID_STRING_MAX];
size_t l;
int r;
@ -217,7 +216,7 @@ static int determine_devices(void) {
if (!arg_data_what) {
memcpy(&root_uuid, m, sizeof(root_uuid));
arg_data_what = path_join("/dev/disk/by-partuuid", id128_to_uuid_string(root_uuid, ids));
arg_data_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(root_uuid));
if (!arg_data_what)
return log_oom();
}
@ -225,7 +224,7 @@ static int determine_devices(void) {
if (!arg_hash_what) {
memcpy(&verity_uuid, (uint8_t*) m + l - sizeof(verity_uuid), sizeof(verity_uuid));
arg_hash_what = path_join("/dev/disk/by-partuuid", id128_to_uuid_string(verity_uuid, ids));
arg_hash_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(verity_uuid));
if (!arg_hash_what)
return log_oom();
}