Commit efab78cdabcec2c8c72d498ef75e1367d0074601

Edward Thomson 2020-04-05T10:09:11

blame: use GIT_ASSERT

diff --git a/src/blame.c b/src/blame.c
index 1046dab..651b7a0 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -171,20 +171,21 @@ void git_blame_free(git_blame *blame)
 
 uint32_t git_blame_get_hunk_count(git_blame *blame)
 {
-	assert(blame);
+	GIT_ASSERT_ARG(blame);
 	return (uint32_t)blame->hunks.length;
 }
 
 const git_blame_hunk *git_blame_get_hunk_byindex(git_blame *blame, uint32_t index)
 {
-	assert(blame);
+	GIT_ASSERT_ARG_WITH_RETVAL(blame, NULL);
 	return (git_blame_hunk*)git_vector_get(&blame->hunks, index);
 }
 
 const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
 {
 	size_t i, new_lineno = lineno;
-	assert(blame);
+
+	GIT_ASSERT_ARG_WITH_RETVAL(blame, NULL);
 
 	if (!git_vector_bsearch2(&i, &blame->hunks, hunk_byfinalline_search_cmp, &new_lineno)) {
 		return git_blame_get_hunk_byindex(blame, (uint32_t)i);
@@ -388,7 +389,10 @@ int git_blame_file(
 	git_blame_options normOptions = GIT_BLAME_OPTIONS_INIT;
 	git_blame *blame = NULL;
 
-	assert(out && repo && path);
+	GIT_ASSERT_ARG(out);
+	GIT_ASSERT_ARG(repo);
+	GIT_ASSERT_ARG(path);
+
 	if ((error = normalize_options(&normOptions, options, repo)) < 0)
 		goto on_error;
 
@@ -509,7 +513,9 @@ int git_blame_buffer(
 
 	diffopts.context_lines = 0;
 
-	assert(out && reference && buffer && buffer_len);
+	GIT_ASSERT_ARG(out);
+	GIT_ASSERT_ARG(reference);
+	GIT_ASSERT_ARG(buffer && buffer_len);
 
 	blame = git_blame__alloc(reference->repository, reference->options, reference->path);
 	GIT_ERROR_CHECK_ALLOC(blame);