[glib/wip/chergert/insertbeforelink: 576/576] glist: code style cleanup for g_list_insert_before()



commit eeddd15d8af5323e82d4116a0fc6ebf5c4d24507
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 29 12:57:01 2019 -0700

    glist: code style cleanup for g_list_insert_before()
    
    This makes the g_list_insert_before() follow more closely the guidelines
    for GLib, which is to avoid implicit pointer boolean value and to prefer
    for over while to improve readability.

 glib/glist.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/glib/glist.c b/glib/glist.c
index ef82f0045..94fdfeb8a 100644
--- a/glib/glist.c
+++ b/glib/glist.c
@@ -441,14 +441,14 @@ g_list_insert_before (GList    *list,
                       GList    *sibling,
                       gpointer  data)
 {
-  if (!list)
+  if (list == NULL)
     {
       list = g_list_alloc ();
       list->data = data;
       g_return_val_if_fail (sibling == NULL, list);
       return list;
     }
-  else if (sibling)
+  else if (sibling != NULL)
     {
       GList *node;
 
@@ -457,7 +457,7 @@ g_list_insert_before (GList    *list,
       node->prev = sibling->prev;
       node->next = sibling;
       sibling->prev = node;
-      if (node->prev)
+      if (node->prev != NULL)
         {
           node->prev->next = node;
           return list;
@@ -472,9 +472,7 @@ g_list_insert_before (GList    *list,
     {
       GList *last;
 
-      last = list;
-      while (last->next)
-        last = last->next;
+      for (last = list; last->next != NULL; last = last->next) {}
 
       last->next = _g_list_alloc ();
       last->next->data = data;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]