]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use sd_id128_is_null() instead of sd_id128_equal where appropriate
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Jul 2016 14:06:31 +0000 (16:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 10:38:08 +0000 (12:38 +0200)
It's a bit easier to read because shorter. Also, most likely a tiny bit faster.

src/boot/bootctl.c
src/firstboot/firstboot.c
src/journal/journalctl.c
src/journal/journald-server.c
src/libsystemd/sd-bus/bus-socket.c
src/machine/machine.c
src/machine/machinectl.c
src/nspawn/nspawn.c

index 7cb22597171666c6ce80ea220f9010b7ec440c2e..37fa049ecf3ea6c26a6eb30dca62c7cd97f47647 100644 (file)
@@ -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
index 3df72460ef504b993966b85663361fbb50dc934f..c9e8e54ee38f00b0d8f234eda830691526a2afd9 100644 (file)
@@ -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);
index 4cc0c2b6c2cb71a9a7b245d2b3315794be7202f8..53c61808640ed972f4b2b85a1f6e55fea883216d 100644 (file)
@@ -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);
index 886e0ec856ffa201f236be113edbb87cf2715f66..587c343b3134bc5f43bc9ff03c073f56724bd9c1 100644 (file)
@@ -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);
         }
index f1e2a06050153732f5c56b3ca5095d757b3ff87c..cfd775313905a9faa79c1f5c31dd4571f2dbf939 100644 (file)
@@ -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;
 
index c1fae570849b7f39468c48a5cdec90d3b4be228e..dd046d656381b8076a79cee8e21987803e1ab961 100644 (file)
@@ -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)
index 96e0ab4b8a9c10547953c261edd1a4a2bdacd929..ddec6cb4d6395aa38e23c2338d02074363c2f24a 100644 (file)
@@ -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');
index 6c8263d3d5492609ba939109b61974fd1c386c0e..ae0d2a8deb981fae9bfef092e2f792bb21bc2850 100644 (file)
@@ -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();