]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-bus-address: silence gcc warning about NULL arg to strcmp()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Jun 2022 10:13:42 +0000 (12:13 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 9 Jun 2022 05:53:06 +0000 (07:53 +0200)
The code was overly complicated… We know what value we expect, we can test it
directly.

src/libsystemd/sd-bus/test-bus-address.c

index ec9ee83fac9798fc8e7f2c8536ddab6dee87a408..347ba1a39b0554aa92f18954e6b35b7c80e9c1b6 100644 (file)
@@ -15,11 +15,9 @@ static void test_one_address(sd_bus *b,
 
         r = bus_set_address_system_remote(b, host);
         log_info("\"%s\" → %d, \"%s\"", host, r, strna(r >= 0 ? b->address : NULL));
-        if (result < 0 || expected) {
-                assert_se(r == result);
-                if (r >= 0)
-                        assert_se(streq(b->address, expected));
-        }
+        assert_se(r == result);
+        if (r >= 0)
+                assert_se(streq_ptr(b->address, expected));
 }
 
 TEST(bus_set_address_system_remote) {
@@ -38,8 +36,8 @@ TEST(bus_set_address_system_remote) {
                          0, "unixexec:path=ssh,argv1=-xT,argv2=-p,argv3=123,argv4=--,argv5=host,argv6=systemd-stdio-bridge");
         test_one_address(b, "host:123:123",
                          -EINVAL, NULL);
-                test_one_address(b, "host:",
-                                 -EINVAL, NULL);
+        test_one_address(b, "host:",
+                         -EINVAL, NULL);
         test_one_address(b, "user@host",
                          0, "unixexec:path=ssh,argv1=-xT,argv2=--,argv3=user%40host,argv4=systemd-stdio-bridge");
         test_one_address(b, "user@host@host",