]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Remove variable only used for an assert
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Mar 2019 13:28:24 +0000 (14:28 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Mar 2019 08:03:06 +0000 (09:03 +0100)
When compiled with -DNDEBUG, we get warnings about set-but-unused variables.
In general, it's not something we care about, but since removing those
variables arguably makes the code nicer, let's just to it in this case.

src/basic/gcrypt-util.c
src/libsystemd/sd-device/device-enumerator.c
src/network/netdev/fou-tunnel.c
src/network/netdev/wireguard.c
src/shared/fstab-util.h

index f304a2bab69f9d9af22cdc81b6ca1ff652117dd0..9bab47dd8a02613d8f089e4879ecca3837fa1236 100644 (file)
@@ -7,12 +7,10 @@
 #include "hexdecoct.h"
 
 void initialize_libgcrypt(bool secmem) {
-        const char *p;
         if (gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P))
                 return;
 
-        p = gcry_check_version("1.4.5");
-        assert(p);
+        assert_se(gcry_check_version("1.4.5"));
 
         /* Turn off "secmem". Clients which wish to make use of this
          * feature should initialize the library manually */
index 4da6e652106866825d67e5bfd68c0bb831652415..4357860170a5f905fd14880e6570719485232a14 100644 (file)
@@ -428,7 +428,6 @@ static bool match_tag(sd_device_enumerator *enumerator, sd_device *device) {
 static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) {
         const char *syspath_parent, *syspath;
         Iterator i;
-        int r;
 
         assert(enumerator);
         assert(device);
@@ -436,8 +435,7 @@ static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) {
         if (set_isempty(enumerator->match_parent))
                 return true;
 
-        r = sd_device_get_syspath(device, &syspath);
-        assert(r >= 0);
+        assert_se(sd_device_get_syspath(device, &syspath) >= 0);
 
         SET_FOREACH(syspath_parent, enumerator->match_parent, i)
                 if (path_startswith(syspath, syspath_parent))
index 65dad384e2213d13a5ede5df4a99c81b7e84a295..4dbcb574df50f1db79b15e05e9837d4849d58f08 100644 (file)
@@ -64,14 +64,10 @@ static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message **r
 static int netdev_fou_tunnel_create(NetDev *netdev) {
         _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
         uint32_t serial;
-        FouTunnel *t;
         int r;
 
         assert(netdev);
-
-        t = FOU(netdev);
-
-        assert(t);
+        assert(FOU(netdev));
 
         r = netdev_fill_fou_tunnel_message(netdev, &m);
         if (r < 0)
index 73c5402972ffe5ec68d2eed609b22ab9f06aece4..03eaac1f9cba59026fa1bf3eca52558dec27d766 100644 (file)
@@ -430,11 +430,8 @@ static void resolve_endpoints(NetDev *netdev) {
 }
 
 static int netdev_wireguard_post_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
-        Wireguard *w;
-
         assert(netdev);
-        w = WIREGUARD(netdev);
-        assert(w);
+        assert(WIREGUARD(netdev));
 
         (void) wireguard_set_interface(netdev);
         resolve_endpoints(netdev);
index 9820f78ca858b228f34240cf2da8e5fcb56e65ac..08622565113b82420b06e297ab82fc22ae8e0ca2 100644 (file)
@@ -20,14 +20,12 @@ static inline bool fstab_test_option(const char *opts, const char *names) {
 int fstab_find_pri(const char *options, int *ret);
 
 static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no) {
-        int r;
         const char *opt;
 
         /* If first name given is last, return 1.
          * If second name given is last or neither is found, return 0. */
 
-        r = fstab_filter_options(opts, yes_no, &opt, NULL, NULL);
-        assert(r >= 0);
+        assert_se(fstab_filter_options(opts, yes_no, &opt, NULL, NULL) >= 0);
 
         return opt == yes_no;
 }