From f921b457a784b8f3edffcac7db79c940634c35f9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 30 Oct 2018 02:40:23 +0900 Subject: [PATCH] libudev: coding style fixes --- src/libudev/libudev-hwdb.c | 2 +- src/libudev/libudev-list.c | 14 +++++++------- src/libudev/libudev-queue.c | 2 +- src/libudev/libudev-util.c | 14 +++++++------- src/libudev/libudev.h | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 33c042c02b..2dd0a8b484 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -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; } diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index 32b4127f99..a5d52272cc 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -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; } diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index 4ccb3f8736..60a84cb03b 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -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; } diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index 8007463581..f07b29ab48 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -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++; diff --git a/src/libudev/libudev.h b/src/libudev/libudev.h index 3e3d0591dd..02c2e5e8ed 100644 --- a/src/libudev/libudev.h +++ b/src/libudev/libudev.h @@ -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)) /*