mirror of
https://github.com/systemd/systemd
synced 2024-09-06 08:46:19 +00:00
udev: add some asserts
Mostly for documentation purposes.
This commit is contained in:
parent
7283a80d10
commit
3b64e4d4f4
|
@ -240,6 +240,10 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device,
|
||||||
link_config **ret) {
|
link_config **ret) {
|
||||||
link_config *link;
|
link_config *link;
|
||||||
|
|
||||||
|
assert(ctx);
|
||||||
|
assert(device);
|
||||||
|
assert(ret);
|
||||||
|
|
||||||
LIST_FOREACH(links, link, ctx->links) {
|
LIST_FOREACH(links, link, ctx->links) {
|
||||||
const char* attr_value;
|
const char* attr_value;
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
|
||||||
bool last = false;
|
bool last = false;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
for (d = srcdev; d && !last; d = udev_device_get_parent(d)) {
|
for (d = srcdev; d && !last; d = udev_device_get_parent(d)) {
|
||||||
const char *dsubsys;
|
const char *dsubsys;
|
||||||
const char *modalias = NULL;
|
const char *modalias = NULL;
|
||||||
|
|
|
@ -268,6 +268,8 @@ static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], boo
|
||||||
bool is_pointer;
|
bool is_pointer;
|
||||||
bool is_key;
|
bool is_key;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
/* walk up the parental chain until we find the real input device; the
|
/* walk up the parental chain until we find the real input device; the
|
||||||
* argument is very likely a subdevice of this, like eventN */
|
* argument is very likely a subdevice of this, like eventN */
|
||||||
pdev = dev;
|
pdev = dev;
|
||||||
|
|
|
@ -37,6 +37,9 @@ static int install_force_release(struct udev_device *dev, const unsigned *releas
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(release);
|
||||||
|
|
||||||
atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
|
atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
|
||||||
if (!atkbd)
|
if (!atkbd)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -152,6 +155,9 @@ static void set_trackpoint_sensitivity(struct udev_device *dev, const char *valu
|
||||||
char val_s[DECIMAL_STR_MAX(int)];
|
char val_s[DECIMAL_STR_MAX(int)];
|
||||||
int r, val_i;
|
int r, val_i;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(value);
|
||||||
|
|
||||||
/* The sensitivity sysfs attr belongs to the serio parent device */
|
/* The sensitivity sysfs attr belongs to the serio parent device */
|
||||||
pdev = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
|
pdev = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
|
||||||
if (!pdev) {
|
if (!pdev) {
|
||||||
|
|
|
@ -276,6 +276,9 @@ out:
|
||||||
static int names_pci(struct udev_device *dev, struct netnames *names) {
|
static int names_pci(struct udev_device *dev, struct netnames *names) {
|
||||||
struct udev_device *parent;
|
struct udev_device *parent;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(names);
|
||||||
|
|
||||||
parent = udev_device_get_parent(dev);
|
parent = udev_device_get_parent(dev);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -302,6 +305,9 @@ static int names_usb(struct udev_device *dev, struct netnames *names) {
|
||||||
size_t l;
|
size_t l;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(names);
|
||||||
|
|
||||||
usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface");
|
usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface");
|
||||||
if (!usbdev)
|
if (!usbdev)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -350,6 +356,9 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) {
|
||||||
struct udev_device *bcmadev;
|
struct udev_device *bcmadev;
|
||||||
unsigned int core;
|
unsigned int core;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(names);
|
||||||
|
|
||||||
bcmadev = udev_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL);
|
bcmadev = udev_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL);
|
||||||
if (!bcmadev)
|
if (!bcmadev)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -371,6 +380,9 @@ static int names_ccw(struct udev_device *dev, struct netnames *names) {
|
||||||
size_t bus_id_len;
|
size_t bus_id_len;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(names);
|
||||||
|
|
||||||
/* Retrieve the associated CCW device */
|
/* Retrieve the associated CCW device */
|
||||||
cdev = udev_device_get_parent(dev);
|
cdev = udev_device_get_parent(dev);
|
||||||
if (!cdev)
|
if (!cdev)
|
||||||
|
|
|
@ -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) {
|
static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys) {
|
||||||
struct udev_device *parent = dev;
|
struct udev_device *parent = dev;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(subsys);
|
||||||
|
|
||||||
while (parent != NULL) {
|
while (parent != NULL) {
|
||||||
const char *subsystem;
|
const char *subsystem;
|
||||||
|
|
||||||
|
@ -96,6 +99,9 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
|
||||||
const char *port;
|
const char *port;
|
||||||
char *lun = NULL;
|
char *lun = NULL;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
||||||
if (targetdev == NULL)
|
if (targetdev == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -126,6 +132,9 @@ static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent,
|
||||||
const char *sas_address;
|
const char *sas_address;
|
||||||
char *lun = NULL;
|
char *lun = NULL;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
||||||
if (targetdev == NULL)
|
if (targetdev == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -169,6 +178,9 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
|
||||||
const char *phy_count;
|
const char *phy_count;
|
||||||
char *lun = NULL;
|
char *lun = NULL;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
|
||||||
if (targetdev == NULL)
|
if (targetdev == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -259,6 +271,9 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **
|
||||||
const char *port;
|
const char *port;
|
||||||
char *lun = NULL;
|
char *lun = NULL;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
/* find iscsi session */
|
/* find iscsi session */
|
||||||
transportdev = parent;
|
transportdev = parent;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -316,6 +331,9 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
int basenum;
|
int basenum;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
|
hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
|
||||||
if (hostdev == NULL)
|
if (hostdev == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -398,6 +416,9 @@ static struct udev_device *handle_scsi_hyperv(struct udev_device *parent, char *
|
||||||
char guid[38];
|
char guid[38];
|
||||||
size_t i, k;
|
size_t i, k;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
|
hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
|
||||||
if (!hostdev)
|
if (!hostdev)
|
||||||
return NULL;
|
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) {
|
static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path) {
|
||||||
struct udev_device *scsi_dev;
|
struct udev_device *scsi_dev;
|
||||||
|
|
||||||
|
assert(parent);
|
||||||
|
assert(dev);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
scsi_dev = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device");
|
scsi_dev = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device");
|
||||||
if (scsi_dev != NULL) {
|
if (scsi_dev != NULL) {
|
||||||
const char *wwpn;
|
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_transport = false;
|
||||||
bool supported_parent = false;
|
bool supported_parent = false;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
/* S390 ccw bus */
|
/* S390 ccw bus */
|
||||||
parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL);
|
parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL);
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
|
|
|
@ -252,6 +252,8 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
size_t l;
|
size_t l;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
/* shortcut, if we are called directly for a "usb_device" type */
|
/* shortcut, if we are called directly for a "usb_device" type */
|
||||||
if (udev_device_get_devtype(dev) != NULL && streq(udev_device_get_devtype(dev), "usb_device")) {
|
if (udev_device_get_devtype(dev) != NULL && streq(udev_device_get_devtype(dev), "usb_device")) {
|
||||||
dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str));
|
dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str));
|
||||||
|
|
|
@ -119,6 +119,8 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
|
||||||
char *s;
|
char *s;
|
||||||
size_t l;
|
size_t l;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
from = src;
|
from = src;
|
||||||
s = dest;
|
s = dest;
|
||||||
l = size;
|
l = size;
|
||||||
|
|
|
@ -664,6 +664,9 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi
|
||||||
struct udev_device *dev_parent;
|
struct udev_device *dev_parent;
|
||||||
struct udev_list_entry *list_entry;
|
struct udev_list_entry *list_entry;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(filter);
|
||||||
|
|
||||||
dev_parent = udev_device_get_parent(dev);
|
dev_parent = udev_device_get_parent(dev);
|
||||||
if (dev_parent == NULL)
|
if (dev_parent == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -401,6 +401,8 @@ static void worker_spawn(Manager *manager, struct event *event) {
|
||||||
struct udev_event *udev_event;
|
struct udev_event *udev_event;
|
||||||
int fd_lock = -1;
|
int fd_lock = -1;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
|
||||||
log_debug("seq %llu running", udev_device_get_seqnum(dev));
|
log_debug("seq %llu running", udev_device_get_seqnum(dev));
|
||||||
udev_event = udev_event_new(dev);
|
udev_event = udev_event_new(dev);
|
||||||
if (udev_event == NULL) {
|
if (udev_event == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue