dissect: add some assert()s
authorLennart Poettering <lennart@poettering.net>
Wed, 19 Dec 2018 17:16:41 +0000 (18:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 19 Dec 2018 22:27:47 +0000 (23:27 +0100)
src/shared/dissect-image.c

index 551a67b..3a46faf 100644 (file)
@@ -102,6 +102,8 @@ not_found:
 static bool device_is_mmc_special_partition(sd_device *d) {
         const char *sysname;
 
+        assert(d);
+
         if (sd_device_get_sysname(d, &sysname) < 0)
                 return false;
 
@@ -112,6 +114,8 @@ static bool device_is_mmc_special_partition(sd_device *d) {
 static bool device_is_block(sd_device *d) {
         const char *ss;
 
+        assert(d);
+
         if (sd_device_get_subsystem(d, &ss) < 0)
                 return false;
 
@@ -122,6 +126,9 @@ static int enumerator_for_parent(sd_device *d, sd_device_enumerator **ret) {
         _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
         int r;
 
+        assert(d);
+        assert(ret);
+
         r = sd_device_enumerator_new(&e);
         if (r < 0)
                 return r;
@@ -153,6 +160,10 @@ static int wait_for_partitions_to_appear(
         unsigned n;
         int r;
 
+        assert(fd >= 0);
+        assert(d);
+        assert(ret_enumerator);
+
         r = enumerator_for_parent(d, &e);
         if (r < 0)
                 return r;
@@ -231,6 +242,10 @@ static int loop_wait_for_partitions_to_appear(
         _cleanup_(sd_device_unrefp) sd_device *device = NULL;
         int r;
 
+        assert(fd >= 0);
+        assert(d);
+        assert(ret_enumerator);
+
         log_debug("Waiting for device (parent + %d partitions) to appear...", num_partitions);
 
         if (!FLAGS_SET(flags, DISSECT_IMAGE_NO_UDEV)) {