Commit f10d7a368fa4af28b1e6f082349ffa4f62b3c00e

Russell Belfer 2013-12-06T15:53:26

Further callback error check style fixes Okay, I've decided I like the readability of this style much better so I used it everywhere.

diff --git a/src/config.c b/src/config.c
index 8b3a426..5477b04 100644
--- a/src/config.c
+++ b/src/config.c
@@ -507,9 +507,10 @@ int git_config_backend_foreach_match(
 			continue;
 
 		/* abort iterator on non-zero return value */
-		error = GITERR_CALLBACK( cb(entry, payload) );
-		if (error)
+		if ((error = cb(entry, payload)) != 0) {
+			GITERR_CALLBACK(error);
 			break;
+		}
 	}
 
 	if (regexp != NULL)
@@ -533,9 +534,12 @@ int git_config_foreach_match(
 	if ((error = git_config_iterator_glob_new(&iter, cfg, regexp)) < 0)
 		return error;
 
-	while (!(error = git_config_next(&entry, iter)) &&
-		   !(error = GITERR_CALLBACK( cb(entry, payload) )))
-		/* make callback on each config */;
+	while (!(error = git_config_next(&entry, iter))) {
+		if ((error = cb(entry, payload)) != 0) {
+			GITERR_CALLBACK(error);
+			break;
+		}
+	}
 
 	git_config_iterator_free(iter);
 
@@ -794,8 +798,10 @@ int git_config_get_multivar_foreach(
 	while ((err = iter->next(&entry, iter)) == 0) {
 		found = 1;
 
-		if ((err = GITERR_CALLBACK( cb(entry, payload) )) != 0)
+		if ((err = cb(entry, payload)) != 0) {
+			GITERR_CALLBACK(err);
 			break;
+		}
 	}
 
 	iter->free(iter);
diff --git a/src/notes.c b/src/notes.c
index e3a3fcc..e0d5ad1 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -582,10 +582,12 @@ int git_note_foreach(
 	if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0)
 		return error;
 
-	while (!(error = git_note_next(&note_id, &annotated_id, iter)) &&
-		   !(error = GITERR_CALLBACK(
-				note_cb(&note_id, &annotated_id, payload))))
-		/* callback for each note */;
+	while (!(error = git_note_next(&note_id, &annotated_id, iter))) {
+		if ((error = note_cb(&note_id, &annotated_id, payload)) != 0) {
+			GITERR_CALLBACK(error);
+			break;
+		}
+	}
 
 	if (error == GIT_ITEROVER)
 		error = 0;
diff --git a/src/refs.c b/src/refs.c
index afb0679..25037cc 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -516,9 +516,12 @@ int git_reference_foreach(
 	if ((error = git_reference_iterator_new(&iter, repo)) < 0)
 		return error;
 
-	while (!(error = git_reference_next(&ref, iter)) &&
-		   !(error = GITERR_CALLBACK( callback(ref, payload) )))
-		/* callback on each reference */;
+	while (!(error = git_reference_next(&ref, iter))) {
+		if ((error = callback(ref, payload)) != 0) {
+			GITERR_CALLBACK(error);
+			break;
+		}
+	}
 
 	if (error == GIT_ITEROVER)
 		error = 0;
@@ -539,9 +542,12 @@ int git_reference_foreach_name(
 	if ((error = git_reference_iterator_new(&iter, repo)) < 0)
 		return error;
 
-	while (!(error = git_reference_next_name(&refname, iter)) &&
-		   !(error = GITERR_CALLBACK( callback(refname, payload) )))
-		/* callback on each reference name */;
+	while (!(error = git_reference_next_name(&refname, iter))) {
+		if ((error = callback(refname, payload)) != 0) {
+			GITERR_CALLBACK(error);
+			break;
+		}
+	}
 
 	if (error == GIT_ITEROVER)
 		error = 0;
@@ -563,9 +569,12 @@ int git_reference_foreach_glob(
 	if ((error = git_reference_iterator_glob_new(&iter, repo, glob)) < 0)
 		return error;
 
-	while (!(error = git_reference_next_name(&refname, iter)) &&
-		   !(error = GITERR_CALLBACK( callback(refname, payload) )))
-		/* callback on each matching reference name */;
+	while (!(error = git_reference_next_name(&refname, iter))) {
+		if ((error = callback(refname, payload)) != 0) {
+			GITERR_CALLBACK(error);
+			break;
+		}
+	}
 
 	if (error == GIT_ITEROVER)
 		error = 0;