From 288f7301ecafb2c53ab4671361109803af118668 Mon Sep 17 00:00:00 2001
From: Lemmy Huang <huangliming5@huawei.com>
Date: Thu, 11 Jul 2024 16:04:00 +0800
Subject: [PATCH] cleancode: refactor lwipgz_hlist.h

  Changed:
    INIT_HLIST_HEAD -> hlist_init_head
    INIT_HLIST_NODE -> hlist_init_node
    hlist_empty     -> hlist_head_empty
    hlist_unhashed  -> hlist_node_null
    hlist_del_init  -> hlist_del_node
  Not changed:
    hlist_add_head
    hlist_add_before
    hlist_add_after
  Deprecated:
    INIT_HLIST_CTRL
    hlist_ctl_del
    hlist_pop_tail
    hlist_pop_head
    hlist_ctl_add_tail
    hlist_ctl_add_head
    hlist_ctl_add_after
    hlist_ctl_add_before

Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
---
 src/ltran/ltran_stack.c    | 6 +++---
 src/ltran/ltran_tcp_conn.c | 6 +++---
 src/ltran/ltran_tcp_sock.c | 6 +++---
 src/ltran/ltran_timer.c    | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/ltran/ltran_stack.c b/src/ltran/ltran_stack.c
index 299fb7a..737d883 100644
--- a/src/ltran/ltran_stack.c
+++ b/src/ltran/ltran_stack.c
@@ -43,7 +43,7 @@ struct gazelle_stack_htable *gazelle_stack_htable_create(uint32_t max_stack_num)
     }
 
     for (i = 0; i < GAZELLE_MAX_STACK_HTABLE_SIZE; i++) {
-        INIT_HLIST_HEAD(&stack_htable->array[i].chain);
+        hlist_init_head(&stack_htable->array[i].chain);
         stack_htable->array[i].chain_size = 0;
     }
     stack_htable->cur_stack_num = 0;
@@ -68,7 +68,7 @@ void gazelle_stack_htable_destroy(void)
         while (node != NULL) {
             stack = hlist_entry(node, typeof(*stack), stack_node);
             node = node->next;
-            hlist_del_init(&stack->stack_node);
+            hlist_del_node(&stack->stack_node);
             free(stack);
         }
     }
@@ -181,7 +181,7 @@ void gazelle_stack_del_by_tid(struct gazelle_stack_htable *stack_htable, uint32_
         }
     }
 
-    hlist_del_init(&stack->stack_node);
+    hlist_del_node(&stack->stack_node);
     stack_htable->cur_stack_num--;
     stack_hbucket->chain_size--;
 
diff --git a/src/ltran/ltran_tcp_conn.c b/src/ltran/ltran_tcp_conn.c
index 026d22a..2c8f8ef 100644
--- a/src/ltran/ltran_tcp_conn.c
+++ b/src/ltran/ltran_tcp_conn.c
@@ -40,7 +40,7 @@ struct gazelle_tcp_conn_htable *gazelle_tcp_conn_htable_create(uint32_t max_conn
     }
 
     for (i = 0; i < GAZELLE_MAX_CONN_HTABLE_SIZE; i++) {
-        INIT_HLIST_HEAD(&conn_htable->array[i].chain);
+        hlist_init_head(&conn_htable->array[i].chain);
         conn_htable->array[i].chain_size = 0;
     }
     conn_htable->cur_conn_num = 0;
@@ -65,7 +65,7 @@ void gazelle_tcp_conn_htable_destroy(void)
         while (node != NULL) {
             conn = hlist_entry(node, typeof(*conn), conn_node);
             node = node->next;
-            hlist_del_init(&conn->conn_node);
+            hlist_del_node(&conn->conn_node);
             rte_free(conn);
         }
     }
@@ -175,7 +175,7 @@ void gazelle_conn_del_by_quintuple(struct gazelle_tcp_conn_htable *conn_htable,
         return;
     }
 
-    hlist_del_init(&conn->conn_node);
+    hlist_del_node(&conn->conn_node);
     rte_free(conn);
     conn_htable->cur_conn_num--;
     conn_hbucket->chain_size--;
diff --git a/src/ltran/ltran_tcp_sock.c b/src/ltran/ltran_tcp_sock.c
index eef2821..1e06bd7 100644
--- a/src/ltran/ltran_tcp_sock.c
+++ b/src/ltran/ltran_tcp_sock.c
@@ -51,7 +51,7 @@ struct gazelle_tcp_sock_htable *gazelle_tcp_sock_htable_create(uint32_t max_tcp_
     }
 
     for (i = 0; i < GAZELLE_MAX_TCP_SOCK_HTABLE_SIZE; i++) {
-        INIT_HLIST_HEAD(&tcp_sock_htable->array[i].chain);
+        hlist_init_head(&tcp_sock_htable->array[i].chain);
         tcp_sock_htable->array[i].chain_size = 0;
     }
     tcp_sock_htable->cur_tcp_sock_num = 0;
@@ -77,7 +77,7 @@ void gazelle_tcp_sock_htable_destroy(void)
         while (node != NULL) {
             tcp_sock = hlist_entry(node, typeof(*tcp_sock), tcp_sock_node);
             node = node->next;
-            hlist_del_init(&tcp_sock->tcp_sock_node);
+            hlist_del_node(&tcp_sock->tcp_sock_node);
             free(tcp_sock);
         }
     }
@@ -186,7 +186,7 @@ void gazelle_sock_del_by_ipporttid(struct gazelle_tcp_sock_htable *tcp_sock_htab
         return;
     }
 
-    hlist_del_init(&tcp_sock->tcp_sock_node);
+    hlist_del_node(&tcp_sock->tcp_sock_node);
     free(tcp_sock);
     tcp_sock_htable->cur_tcp_sock_num--;
     tcp_sock_hbucket->chain_size--;
diff --git a/src/ltran/ltran_timer.c b/src/ltran/ltran_timer.c
index 87046cb..51d6544 100644
--- a/src/ltran/ltran_timer.c
+++ b/src/ltran/ltran_timer.c
@@ -63,7 +63,7 @@ void gazelle_detect_sock_logout(struct gazelle_tcp_sock_htable *tcp_sock_htable)
             tcp_sock = hlist_entry(node, typeof(*tcp_sock), tcp_sock_node);
             node = node->next;
             if (!INSTANCE_IS_ON(tcp_sock)) {
-                hlist_del_init(&tcp_sock->tcp_sock_node);
+                hlist_del_node(&tcp_sock->tcp_sock_node);
                 tcp_sock_htable->cur_tcp_sock_num--;
                 tcp_sock_htable->array[i].chain_size--;
                 LTRAN_DEBUG("delete the tcp sock htable: tid %u ip %u port %u\n",
@@ -99,7 +99,7 @@ void gazelle_detect_conn_logout(struct gazelle_tcp_conn_htable *conn_htable)
             conn = hlist_entry(node, typeof(*conn), conn_node);
             node = node->next;
             if (!INSTANCE_IS_ON(conn)) {
-                hlist_del_init(&conn->conn_node);
+                hlist_del_node(&conn->conn_node);
                 conn_htable->cur_conn_num--;
                 conn_htable->array[i].chain_size--;
                 LTRAN_DEBUG("delete the tcp conn htable: tid %u quintuple[%u %u %u %u %u]\n",
@@ -146,7 +146,7 @@ void gazelle_delete_aging_conn(struct gazelle_tcp_conn_htable *conn_htable)
                 continue;
             }
 
-            hlist_del_init(&conn->conn_node);
+            hlist_del_node(&conn->conn_node);
             conn_htable->cur_conn_num--;
             conn_htable->array[i].chain_size--;
             if (conn->sock) {
-- 
2.33.0

