mailmap: use GIT_ASSERT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/src/mailmap.c b/src/mailmap.c
index 409cdbd..347b433 100644
--- a/src/mailmap.c
+++ b/src/mailmap.c
@@ -43,7 +43,8 @@ static int mailmap_entry_cmp(const void *a_raw, const void *b_raw)
const git_mailmap_entry *b = (const git_mailmap_entry *)b_raw;
int cmp;
- assert(a && b && a->replace_email && b->replace_email);
+ GIT_ASSERT_ARG(a && a->replace_email);
+ GIT_ASSERT_ARG(b && b->replace_email);
cmp = git__strcmp(a->replace_email, b->replace_email);
if (cmp)
@@ -185,7 +186,8 @@ static int mailmap_add_entry_unterminated(
git_mailmap_entry *entry = git__calloc(1, sizeof(git_mailmap_entry));
GIT_ERROR_CHECK_ALLOC(entry);
- assert(mm && replace_email && *replace_email);
+ GIT_ASSERT_ARG(mm);
+ GIT_ASSERT_ARG(replace_email && *replace_email);
if (real_name_size > 0) {
entry->real_name = git__substrdup(real_name, real_name_size);
@@ -290,7 +292,8 @@ static int mailmap_add_blob(
git_buf content = GIT_BUF_INIT;
int error;
- assert(mm && repo);
+ GIT_ASSERT_ARG(mm);
+ GIT_ASSERT_ARG(repo);
error = git_revparse_single(&object, repo, rev);
if (error < 0)
@@ -350,8 +353,6 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
const char *rev = NULL;
const char *path = NULL;
- assert(mm && repo);
-
/* If we're in a bare repo, default blob to 'HEAD:.mailmap' */
if (repo->is_bare)
rev = MM_BLOB_DEFAULT;
@@ -389,9 +390,14 @@ static void mailmap_add_from_repository(git_mailmap *mm, git_repository *repo)
int git_mailmap_from_repository(git_mailmap **out, git_repository *repo)
{
- int error = git_mailmap_new(out);
- if (error < 0)
+ int error;
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+
+ if ((error = git_mailmap_new(out)) < 0)
return error;
+
mailmap_add_from_repository(*out, repo);
return 0;
}
@@ -408,7 +414,7 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
git_mailmap_entry needle = { NULL };
needle.replace_email = (char *)email;
- assert(email);
+ GIT_ASSERT_ARG_WITH_RETVAL(email, NULL);
if (!mm)
return NULL;
@@ -431,7 +437,8 @@ const git_mailmap_entry *git_mailmap_entry_lookup(
if (git__strcmp(entry->replace_email, email))
break; /* it's a different email, so we're done looking */
- assert(entry->replace_name); /* should be specific */
+ /* should be specific */
+ GIT_ASSERT_WITH_RETVAL(entry->replace_name, NULL);
if (!name || !git__strcmp(entry->replace_name, name))
return entry;
}
@@ -447,7 +454,9 @@ int git_mailmap_resolve(
const char *name, const char *email)
{
const git_mailmap_entry *entry = NULL;
- assert(name && email);
+
+ GIT_ASSERT(name);
+ GIT_ASSERT(email);
*real_name = name;
*real_email = email;