Commit ef6b12b0c5748c3f323c04473ea44db180af873e

Edward Thomson 2020-04-05T21:58:40

revwalk: use GIT_ASSERT

diff --git a/src/revwalk.c b/src/revwalk.c
index 1efb938..249cb16 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -99,7 +99,8 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
 
-	assert(walk && oid);
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(oid);
 
 	return git_revwalk__push_commit(walk, oid, &opts);
 }
@@ -108,7 +109,9 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
 int git_revwalk_hide(git_revwalk *walk, const git_oid *oid)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk && oid);
+
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(oid);
 
 	opts.uninteresting = 1;
 	return git_revwalk__push_commit(walk, oid, &opts);
@@ -133,7 +136,8 @@ int git_revwalk__push_glob(git_revwalk *walk, const char *glob, const git_revwal
 	git_reference_iterator *iter;
 	size_t wildcard;
 
-	assert(walk && glob);
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(glob);
 
 	if (given_opts)
 		memcpy(&opts, given_opts, sizeof(opts));
@@ -172,7 +176,9 @@ out:
 int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk && glob);
+
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(glob);
 
 	return git_revwalk__push_glob(walk, glob, &opts);
 }
@@ -180,7 +186,9 @@ int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
 int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk && glob);
+
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(glob);
 
 	opts.uninteresting = 1;
 	return git_revwalk__push_glob(walk, glob, &opts);
@@ -189,7 +197,8 @@ int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
 int git_revwalk_push_head(git_revwalk *walk)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk);
+
+	GIT_ASSERT_ARG(walk);
 
 	return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
 }
@@ -197,7 +206,8 @@ int git_revwalk_push_head(git_revwalk *walk)
 int git_revwalk_hide_head(git_revwalk *walk)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk);
+
+	GIT_ASSERT_ARG(walk);
 
 	opts.uninteresting = 1;
 	return git_revwalk__push_ref(walk, GIT_HEAD_FILE, &opts);
@@ -206,7 +216,9 @@ int git_revwalk_hide_head(git_revwalk *walk)
 int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk && refname);
+
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(refname);
 
 	return git_revwalk__push_ref(walk, refname, &opts);
 }
@@ -249,7 +261,10 @@ out:
 int git_revwalk_hide_ref(git_revwalk *walk, const char *refname)
 {
 	git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
-	assert(walk && refname);
+
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(refname);
+
 	opts.uninteresting = 1;
 	return git_revwalk__push_ref(walk, refname, &opts);
 }
@@ -694,13 +709,14 @@ void git_revwalk_free(git_revwalk *walk)
 
 git_repository *git_revwalk_repository(git_revwalk *walk)
 {
-	assert(walk);
+	GIT_ASSERT_ARG_WITH_RETVAL(walk, NULL);
+
 	return walk->repo;
 }
 
 int git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
 {
-	assert(walk);
+	GIT_ASSERT_ARG(walk);
 
 	if (walk->walking)
 		git_revwalk_reset(walk);
@@ -732,7 +748,8 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
 	int error;
 	git_commit_list_node *next;
 
-	assert(walk && oid);
+	GIT_ASSERT_ARG(walk);
+	GIT_ASSERT_ARG(oid);
 
 	if (!walk->walking) {
 		if ((error = prepare_walk(walk)) < 0)
@@ -757,7 +774,7 @@ int git_revwalk_reset(git_revwalk *walk)
 {
 	git_commit_list_node *commit;
 
-	assert(walk);
+	GIT_ASSERT_ARG(walk);
 
 	git_oidmap_foreach_value(walk->commits, commit, {
 		commit->seen = 0;
@@ -787,7 +804,7 @@ int git_revwalk_add_hide_cb(
 	git_revwalk_hide_cb hide_cb,
 	void *payload)
 {
-	assert(walk);
+	GIT_ASSERT_ARG(walk);
 
 	if (walk->walking)
 		git_revwalk_reset(walk);