Pārlūkot izejas kodu

faux: list: style

Serj Kalichev 4 gadi atpakaļ
vecāks
revīzija
0f3ba7f71f
1 mainītis faili ar 5 papildinājumiem un 4 dzēšanām
  1. 5 4
      faux/list/list.c

+ 5 - 4
faux/list/list.c

@@ -468,14 +468,14 @@ faux_list_node_t *faux_list_match_node(const faux_list_t *list,
 	if (!iter)
 		iter = list->head;
 	while (iter) {
-		int res;
+		int res = 0;
 		faux_list_node_t *node = iter;
 
 		iter = faux_list_next_node(iter);
 		if (saveptr)
 			*saveptr = iter;
 		res = matchFn(userkey, faux_list_data(node));
-		if (!res)
+		if (0 == res)
 			return node;
 		if (res < 0) // No chances to find match
 			return NULL;
@@ -494,10 +494,11 @@ faux_list_node_t *faux_list_match_node(const faux_list_t *list,
 void *faux_list_match(const faux_list_t *list, faux_list_match_fn matchFn,
 	const void *userkey, faux_list_node_t **saveptr) {
 
-	faux_list_node_t *res =
-		faux_list_match_node(list, matchFn, userkey, saveptr);
+	faux_list_node_t *res = faux_list_match_node(list, matchFn,
+		userkey, saveptr);
 	if (!res)
 		return NULL;
+
 	return faux_list_data(res);
 }