mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
tree-wide: use sd_id128_is_null() instead of sd_id128_equal where appropriate
It's a bit easier to read because shorter. Also, most likely a tiny bit faster.
This commit is contained in:
parent
bf3dd08a81
commit
3bbaff3e08
@ -311,7 +311,7 @@ static int print_efi_option(uint16_t id, bool in_order) {
|
||||
return r;
|
||||
|
||||
/* print only configured entries with partition information */
|
||||
if (!path || sd_id128_equal(partition, SD_ID128_NULL))
|
||||
if (!path || sd_id128_is_null(partition))
|
||||
return 0;
|
||||
|
||||
efi_tilt_backslashes(path);
|
||||
@ -1072,7 +1072,7 @@ static int bootctl_main(int argc, char*argv[]) {
|
||||
|
||||
printf("Loader:\n");
|
||||
printf(" Product: %s\n", strna(loader));
|
||||
if (!sd_id128_equal(loader_part_uuid, SD_ID128_NULL))
|
||||
if (!sd_id128_is_null(loader_part_uuid))
|
||||
printf(" Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
|
||||
SD_ID128_FORMAT_VAL(loader_part_uuid));
|
||||
else
|
||||
|
@ -427,7 +427,7 @@ static int process_machine_id(void) {
|
||||
if (laccess(etc_machine_id, F_OK) >= 0)
|
||||
return 0;
|
||||
|
||||
if (sd_id128_equal(arg_machine_id, SD_ID128_NULL))
|
||||
if (sd_id128_is_null(arg_machine_id))
|
||||
return 0;
|
||||
|
||||
mkdir_parents(etc_machine_id, 0755);
|
||||
|
@ -1266,7 +1266,7 @@ static int add_boot(sd_journal *j) {
|
||||
/* Take a shortcut and use the current boot_id, which we can do very quickly.
|
||||
* We can do this only when we logs are coming from the current machine,
|
||||
* so take the slow path if log location is specified. */
|
||||
if (arg_boot_offset == 0 && sd_id128_equal(arg_boot_id, SD_ID128_NULL) &&
|
||||
if (arg_boot_offset == 0 && sd_id128_is_null(arg_boot_id) &&
|
||||
!arg_directory && !arg_file)
|
||||
|
||||
return add_match_this_boot(j, arg_machine);
|
||||
|
@ -877,7 +877,7 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format,
|
||||
assert_cc(6 == LOG_INFO);
|
||||
IOVEC_SET_STRING(iovec[n++], "PRIORITY=6");
|
||||
|
||||
if (!sd_id128_equal(message_id, SD_ID128_NULL)) {
|
||||
if (!sd_id128_is_null(message_id)) {
|
||||
snprintf(mid, sizeof(mid), LOG_MESSAGE_ID(message_id));
|
||||
IOVEC_SET_STRING(iovec[n++], mid);
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
|
||||
peer.bytes[i/2] = ((uint8_t) x << 4 | (uint8_t) y);
|
||||
}
|
||||
|
||||
if (!sd_id128_equal(b->server_id, SD_ID128_NULL) &&
|
||||
if (!sd_id128_is_null(b->server_id) &&
|
||||
!sd_id128_equal(b->server_id, peer))
|
||||
return -EPERM;
|
||||
|
||||
|
@ -181,7 +181,7 @@ int machine_save(Machine *m) {
|
||||
fprintf(f, "ROOT=%s\n", escaped);
|
||||
}
|
||||
|
||||
if (!sd_id128_equal(m->id, SD_ID128_NULL))
|
||||
if (!sd_id128_is_null(m->id))
|
||||
fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id));
|
||||
|
||||
if (m->leader != 0)
|
||||
|
@ -528,7 +528,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
|
||||
|
||||
fputs(strna(i->name), stdout);
|
||||
|
||||
if (!sd_id128_equal(i->id, SD_ID128_NULL))
|
||||
if (!sd_id128_is_null(i->id))
|
||||
printf("(" SD_ID128_FORMAT_STR ")\n", SD_ID128_FORMAT_VAL(i->id));
|
||||
else
|
||||
putchar('\n');
|
||||
|
@ -1277,8 +1277,8 @@ static char* id128_format_as_uuid(sd_id128_t id, char s[37]) {
|
||||
}
|
||||
|
||||
static int setup_boot_id(const char *dest) {
|
||||
sd_id128_t rnd = SD_ID128_NULL;
|
||||
const char *from, *to;
|
||||
sd_id128_t rnd = {};
|
||||
char as_uuid[37];
|
||||
int r;
|
||||
|
||||
@ -1304,9 +1304,9 @@ static int setup_boot_id(const char *dest) {
|
||||
if (mount(from, to, NULL, MS_BIND, NULL) < 0)
|
||||
r = log_error_errno(errno, "Failed to bind mount boot id: %m");
|
||||
else if (mount(NULL, to, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_NOSUID|MS_NODEV, NULL) < 0)
|
||||
log_warning_errno(errno, "Failed to make boot id read-only: %m");
|
||||
log_warning_errno(errno, "Failed to make boot id read-only, ignoring: %m");
|
||||
|
||||
unlink(from);
|
||||
(void) unlink(from);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -2232,9 +2232,9 @@ static int mount_device(const char *what, const char *where, const char *directo
|
||||
}
|
||||
|
||||
static int setup_machine_id(const char *directory) {
|
||||
int r;
|
||||
const char *etc_machine_id, *t;
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
etc_machine_id = prefix_roota(directory, "/etc/machine-id");
|
||||
|
||||
@ -2663,7 +2663,7 @@ static int inner_child(
|
||||
(asprintf((char**)(envp + n_env++), "LOGNAME=%s", arg_user ? arg_user : "root") < 0))
|
||||
return log_oom();
|
||||
|
||||
assert(!sd_id128_equal(arg_uuid, SD_ID128_NULL));
|
||||
assert(!sd_id128_is_null(arg_uuid));
|
||||
|
||||
if (asprintf((char**)(envp + n_env++), "container_uuid=%s", id128_format_as_uuid(arg_uuid, as_uuid)) < 0)
|
||||
return log_oom();
|
||||
|
Loading…
Reference in New Issue
Block a user