From 3b64e4d4f40baac56148c7d333d6a0053358ec7a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 2 Jun 2015 16:52:07 +0200 Subject: udev: add some asserts Mostly for documentation purposes. --- src/udev/udev-builtin-path_id.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/udev/udev-builtin-path_id.c') diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index b6749aab76..0fa11f6230 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -77,6 +77,9 @@ static int format_lun_number(struct udev_device *dev, char **path) { static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys) { struct udev_device *parent = dev; + assert(dev); + assert(subsys); + while (parent != NULL) { const char *subsystem; @@ -96,6 +99,9 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, const char *port; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -126,6 +132,9 @@ static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent, const char *sas_address; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -169,6 +178,9 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa const char *phy_count; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -259,6 +271,9 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char ** const char *port; char *lun = NULL; + assert(parent); + assert(path); + /* find iscsi session */ transportdev = parent; for (;;) { @@ -316,6 +331,9 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char struct dirent *dent; int basenum; + assert(parent); + assert(path); + hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host"); if (hostdev == NULL) return NULL; @@ -398,6 +416,9 @@ static struct udev_device *handle_scsi_hyperv(struct udev_device *parent, char * char guid[38]; size_t i, k; + assert(parent); + assert(path); + hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host"); if (!hostdev) return NULL; @@ -555,6 +576,10 @@ static struct udev_device *handle_bcma(struct udev_device *parent, char **path) static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path) { struct udev_device *scsi_dev; + assert(parent); + assert(dev); + assert(path); + scsi_dev = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device"); if (scsi_dev != NULL) { const char *wwpn; @@ -582,6 +607,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool bool supported_transport = false; bool supported_parent = false; + assert(dev); + /* S390 ccw bus */ parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL); if (parent != NULL) { -- cgit v1.2.3-54-g00ecf