From f70e7f70c9c5b640ca5b097d64da26e4c5d3fac9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 19 Dec 2018 18:16:41 +0100 Subject: dissect: add some assert()s --- src/shared/dissect-image.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 551a67b6c..3a46faf76 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -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)) { -- cgit v1.2.3-65-gdbad