libudev: coding style fixes
This commit is contained in:
parent
5ea78a39e5
commit
f921b457a7
|
@ -112,7 +112,7 @@ _public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev
|
|||
udev_list_cleanup(&hwdb->properties_list);
|
||||
|
||||
SD_HWDB_FOREACH_PROPERTY(hwdb->hwdb, modalias, key, value) {
|
||||
if (udev_list_entry_add(&hwdb->properties_list, key, value) == NULL) {
|
||||
if (!udev_list_entry_add(&hwdb->properties_list, key, value)) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *
|
|||
}
|
||||
|
||||
static void udev_list_entry_delete(struct udev_list_entry *entry) {
|
||||
if (entry->list->entries != NULL) {
|
||||
if (entry->list->entries) {
|
||||
int i;
|
||||
struct udev_list *list = entry->list;
|
||||
|
||||
|
@ -240,7 +240,7 @@ struct udev_list_entry *udev_list_get_entry(struct udev_list *list) {
|
|||
_public_ struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry) {
|
||||
struct udev_list_node *next;
|
||||
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return NULL;
|
||||
next = list_entry->node.next;
|
||||
/* empty list or no more entries */
|
||||
|
@ -261,7 +261,7 @@ _public_ struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry
|
|||
_public_ struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name) {
|
||||
int i;
|
||||
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return NULL;
|
||||
|
||||
if (!list_entry->list->unique)
|
||||
|
@ -282,7 +282,7 @@ _public_ struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_en
|
|||
* Returns: the name string of this entry.
|
||||
*/
|
||||
_public_ const char *udev_list_entry_get_name(struct udev_list_entry *list_entry) {
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return NULL;
|
||||
return list_entry->name;
|
||||
}
|
||||
|
@ -296,19 +296,19 @@ _public_ const char *udev_list_entry_get_name(struct udev_list_entry *list_entry
|
|||
* Returns: the value string of this entry.
|
||||
*/
|
||||
_public_ const char *udev_list_entry_get_value(struct udev_list_entry *list_entry) {
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return NULL;
|
||||
return list_entry->value;
|
||||
}
|
||||
|
||||
int udev_list_entry_get_num(struct udev_list_entry *list_entry) {
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return -EINVAL;
|
||||
return list_entry->num;
|
||||
}
|
||||
|
||||
void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num) {
|
||||
if (list_entry == NULL)
|
||||
if (!list_entry)
|
||||
return;
|
||||
list_entry->num = num;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ _public_ struct udev_queue *udev_queue_new(struct udev *udev) {
|
|||
struct udev_queue *udev_queue;
|
||||
|
||||
udev_queue = new(struct udev_queue, 1);
|
||||
if (udev_queue == NULL) {
|
||||
if (!udev_queue) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ int util_resolve_subsys_kernel(const char *string,
|
|||
subsys = &temp[1];
|
||||
|
||||
sysname = strchr(subsys, '/');
|
||||
if (sysname == NULL)
|
||||
if (!sysname)
|
||||
return -1;
|
||||
sysname[0] = '\0';
|
||||
sysname = &sysname[1];
|
||||
|
||||
attr = strchr(sysname, ']');
|
||||
if (attr == NULL)
|
||||
if (!attr)
|
||||
return -1;
|
||||
attr[0] = '\0';
|
||||
attr = &attr[1];
|
||||
|
@ -51,18 +51,18 @@ int util_resolve_subsys_kernel(const char *string,
|
|||
if (attr[0] == '\0')
|
||||
attr = NULL;
|
||||
|
||||
if (read_value && attr == NULL)
|
||||
if (read_value && !attr)
|
||||
return -1;
|
||||
|
||||
dev = udev_device_new_from_subsystem_sysname(NULL, subsys, sysname);
|
||||
if (dev == NULL)
|
||||
if (!dev)
|
||||
return -1;
|
||||
|
||||
if (read_value) {
|
||||
const char *val;
|
||||
|
||||
val = udev_device_get_sysattr_value(dev, attr);
|
||||
if (val != NULL)
|
||||
if (val)
|
||||
strscpy(result, maxsize, val);
|
||||
else
|
||||
result[0] = '\0';
|
||||
|
@ -73,7 +73,7 @@ int util_resolve_subsys_kernel(const char *string,
|
|||
|
||||
s = result;
|
||||
l = strpcpyl(&s, maxsize, udev_device_get_syspath(dev), NULL);
|
||||
if (attr != NULL)
|
||||
if (attr)
|
||||
strpcpyl(&s, l, "/", attr, NULL);
|
||||
log_debug("path '[%s/%s]%s' is '%s'", subsys, sysname, attr, result);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ int util_replace_chars(char *str, const char *white) {
|
|||
}
|
||||
|
||||
/* if space is allowed, replace whitespace with ordinary space */
|
||||
if (isspace(str[i]) && white != NULL && strchr(white, ' ') != NULL) {
|
||||
if (isspace(str[i]) && white && strchr(white, ' ')) {
|
||||
str[i] = ' ';
|
||||
i++;
|
||||
replaced++;
|
||||
|
|
|
@ -49,7 +49,7 @@ const char *udev_list_entry_get_value(struct udev_list_entry *list_entry);
|
|||
*/
|
||||
#define udev_list_entry_foreach(list_entry, first_entry) \
|
||||
for (list_entry = first_entry; \
|
||||
list_entry != NULL; \
|
||||
list_entry; \
|
||||
list_entry = udev_list_entry_get_next(list_entry))
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue