Explorar el Código

libdpkg: Simplify and trim-down dlist.h macros

Remove unused macros and simplify remaining ones given the current usage
in the code base.
Guillem Jover hace 9 años
padre
commit
bb4ae26e35
Se han modificado 3 ficheros con 20 adiciones y 27 borrados
  1. 16 23
      lib/dpkg/dlist.h
  2. 3 3
      lib/dpkg/triglib.c
  3. 1 1
      lib/dpkg/trignote.c

+ 16 - 23
lib/dpkg/dlist.h

@@ -17,36 +17,29 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
 
 
-#ifndef ADNS_DLIST_H_INCLUDED
-#define ADNS_DLIST_H_INCLUDED
+#ifndef DPKG_DLIST_H
+#define DPKG_DLIST_H
 
 
-#define LIST_INIT(list) ((list).head = (list).tail = NULL)
-#define LINK_INIT(link) ((link).next = (link).prev = NULL)
-
-#define LIST_UNLINK_PART(list, node, part)				\
-  do {									\
-    if ((node)->part prev) \
-      (node)->part prev->part next = (node)->part next; \
-    else \
-      (list).head = (node)->part next; \
-    if ((node)->part next) \
-      (node)->part next->part prev = (node)->part prev; \
-    else \
-      (list).tail = (node)->part prev; \
+#define LIST_UNLINK_PART(list, node, part)		\
+  do {							\
+    if ((node)->part.prev)				\
+      (node)->part.prev->part.next = (node)->part.next;	\
+    else						\
+      (list).head = (node)->part.next;			\
+    if ((node)->part.next)				\
+      (node)->part.next->part.prev = (node)->part.prev;	\
+    else						\
+      (list).tail = (node)->part.prev;			\
   } while (0)
   } while (0)
 
 
 #define LIST_LINK_TAIL_PART(list, node, part)		\
 #define LIST_LINK_TAIL_PART(list, node, part)		\
   do {							\
   do {							\
-    (node)->part next = NULL;				\
-    (node)->part prev = (list).tail;			\
-    if ((list).tail) \
-      (list).tail->part next = (node);	\
+    (node)->part.next = NULL;				\
+    (node)->part.prev = (list).tail;			\
+    if ((list).tail)					\
+      (list).tail->part.next = (node);			\
     else (list).head = (node);				\
     else (list).head = (node);				\
       (list).tail = (node);				\
       (list).tail = (node);				\
   } while (0)
   } while (0)
 
 
-
-#define LIST_UNLINK(list, node) LIST_UNLINK_PART(list, node,)
-#define LIST_LINK_TAIL(list, node) LIST_LINK_TAIL_PART(list, node,)
-
 #endif
 #endif

+ 3 - 3
lib/dpkg/triglib.c

@@ -112,7 +112,7 @@ trig_clear_awaiters(struct pkginfo *notpend)
 		aw = ta->aw;
 		aw = ta->aw;
 		if (!aw)
 		if (!aw)
 			continue;
 			continue;
-		LIST_UNLINK_PART(aw->trigaw, ta, sameaw.);
+		LIST_UNLINK_PART(aw->trigaw, ta, sameaw);
 		if (!aw->trigaw.head && aw->status == PKG_STAT_TRIGGERSAWAITED) {
 		if (!aw->trigaw.head && aw->status == PKG_STAT_TRIGGERSAWAITED) {
 			if (aw->trigpend_head)
 			if (aw->trigpend_head)
 				pkg_set_status(aw, PKG_STAT_TRIGGERSPENDING);
 				pkg_set_status(aw, PKG_STAT_TRIGGERSPENDING);
@@ -422,7 +422,7 @@ trk_file_interest_change(const char *trig, struct pkginfo *pkg,
 	tfi->samefile_next = *trigh.namenode_interested(fnn);
 	tfi->samefile_next = *trigh.namenode_interested(fnn);
 	*trigh.namenode_interested(fnn) = tfi;
 	*trigh.namenode_interested(fnn) = tfi;
 
 
-	LIST_LINK_TAIL_PART(filetriggers, tfi, inoverall.);
+	LIST_LINK_TAIL_PART(filetriggers, tfi, inoverall);
 	goto edited;
 	goto edited;
 
 
 found:
 found:
@@ -436,7 +436,7 @@ found:
 
 
 	/* Remove it: */
 	/* Remove it: */
 	*search = tfi->samefile_next;
 	*search = tfi->samefile_next;
-	LIST_UNLINK_PART(filetriggers, tfi, inoverall.);
+	LIST_UNLINK_PART(filetriggers, tfi, inoverall);
 edited:
 edited:
 	filetriggers_edited = 1;
 	filetriggers_edited = 1;
 }
 }

+ 1 - 1
lib/dpkg/trignote.c

@@ -96,7 +96,7 @@ trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 	ta->pend = pend;
 	ta->pend = pend;
 	ta->samepend_next = pend->othertrigaw_head;
 	ta->samepend_next = pend->othertrigaw_head;
 	pend->othertrigaw_head = ta;
 	pend->othertrigaw_head = ta;
-	LIST_LINK_TAIL_PART(aw->trigaw, ta, sameaw.);
+	LIST_LINK_TAIL_PART(aw->trigaw, ta, sameaw);
 
 
 	return true;
 	return true;
 }
 }