]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libudev: coding style fixes 10787/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 29 Oct 2018 17:40:23 +0000 (02:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Nov 2018 05:38:35 +0000 (14:38 +0900)
src/libudev/libudev-hwdb.c
src/libudev/libudev-list.c
src/libudev/libudev-queue.c
src/libudev/libudev-util.c
src/libudev/libudev.h

index 33c042c02b926345caa6dee75a5839181d5be30d..2dd0a8b4841c0a765fcbcaa0d9641c5dd7d1521f 100644 (file)
@@ -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;
                 }
index 32b4127f99b0902aba0b495448cfe3ba0121ffcd..a5d52272ccbbb638683ce536a9892b500699aa41 100644 (file)
@@ -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;
 }
index 4ccb3f87361e9a9620f057ee9419667d46a2834d..60a84cb03bedec8332c8d5185032da1ac48629c1 100644 (file)
@@ -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;
         }
index 800746358155f44ebd12b6a31b1b1c49dbaa0185..f07b29ab481919459d2d8577f95f978dc171beae 100644 (file)
@@ -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++;
index 3e3d0591dd825e602c0291b4e444621ee77bce00..02c2e5e8eda3b1e1ae2a7d6431d506c5836f214b 100644 (file)
@@ -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))
 
 /*