Commit dfcd923c9f7e96f99d34a1a5e8d23c7bff6098b6

Patrick Steinhardt 2018-02-09T11:15:32

config_file: remove unused list iteration macros We currently provide a lot of macros for the `cvar_t` structure which are never being used. In fact, the only macro we need is to access the `next` pointer of `cvar_t`, which really does not require a macro at all. Remove all these macros and replace usage of `CVAR_LIST_NEXT(cvar)` with `cvar->next`.

diff --git a/src/config_file.c b/src/config_file.c
index aa9e83b..6890af6 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -38,44 +38,6 @@ typedef struct git_config_file_iter {
 /* Max depth for [include] directives */
 #define MAX_INCLUDE_DEPTH 10
 
-#define CVAR_LIST_HEAD(list) ((list)->head)
-
-#define CVAR_LIST_TAIL(list) ((list)->tail)
-
-#define CVAR_LIST_NEXT(var) ((var)->next)
-
-#define CVAR_LIST_EMPTY(list) ((list)->head == NULL)
-
-#define CVAR_LIST_APPEND(list, var) do {\
-	if (CVAR_LIST_EMPTY(list)) {\
-		CVAR_LIST_HEAD(list) = CVAR_LIST_TAIL(list) = var;\
-	} else {\
-		CVAR_LIST_NEXT(CVAR_LIST_TAIL(list)) = var;\
-		CVAR_LIST_TAIL(list) = var;\
-	}\
-} while(0)
-
-#define CVAR_LIST_REMOVE_HEAD(list) do {\
-	CVAR_LIST_HEAD(list) = CVAR_LIST_NEXT(CVAR_LIST_HEAD(list));\
-} while(0)
-
-#define CVAR_LIST_REMOVE_AFTER(var) do {\
-	CVAR_LIST_NEXT(var) = CVAR_LIST_NEXT(CVAR_LIST_NEXT(var));\
-} while(0)
-
-#define CVAR_LIST_FOREACH(list, iter)\
-	for ((iter) = CVAR_LIST_HEAD(list);\
-		 (iter) != NULL;\
-		 (iter) = CVAR_LIST_NEXT(iter))
-
-/*
- * Inspired by the FreeBSD functions
- */
-#define CVAR_LIST_FOREACH_SAFE(start, iter, tmp)\
-	for ((iter) = CVAR_LIST_HEAD(vars);\
-		 (iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\
-		 (iter) = (tmp))
-
 typedef struct {
 	git_atomic refcount;
 	git_strmap *values;
@@ -188,7 +150,7 @@ static void free_vars(git_strmap *values)
 
 	git_strmap_foreach_value(values, var,
 		while (var != NULL) {
-			cvar_t *next = CVAR_LIST_NEXT(var);
+			cvar_t *next = var->next;
 			cvar_free(var);
 			var = next;
 		});
@@ -407,7 +369,7 @@ static int config_iterator_next(
 	}
 
 	*entry = var->entry;
-	it->next_var = CVAR_LIST_NEXT(var);
+	it->next_var = var->next;
 
 	return 0;
 }