refdb: 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
diff --git a/src/refdb.c b/src/refdb.c
index fb86d5c..ed33de9 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -24,7 +24,8 @@ int git_refdb_new(git_refdb **out, git_repository *repo)
{
git_refdb *db;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
db = git__calloc(1, sizeof(*db));
GIT_ERROR_CHECK_ALLOC(db);
@@ -41,7 +42,8 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
git_refdb *db;
git_refdb_backend *dir;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -89,7 +91,7 @@ int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
int git_refdb_compress(git_refdb *db)
{
- assert(db);
+ GIT_ASSERT_ARG(db);
if (db->backend->compress)
return db->backend->compress(db->backend);
@@ -114,7 +116,9 @@ void git_refdb_free(git_refdb *db)
int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
{
- assert(exists && refdb && refdb->backend);
+ GIT_ASSERT_ARG(exists);
+ GIT_ASSERT_ARG(refdb);
+ GIT_ASSERT_ARG(refdb->backend);
return refdb->backend->exists(exists, refdb->backend, ref_name);
}
@@ -124,7 +128,10 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
git_reference *ref;
int error;
- assert(db && db->backend && out && ref_name);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(ref_name);
error = db->backend->lookup(&ref, db->backend, ref_name);
if (error < 0)
@@ -234,7 +241,8 @@ void git_refdb_iterator_free(git_reference_iterator *iter)
int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target)
{
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
GIT_REFCOUNT_INC(db);
ref->db = db;
@@ -253,7 +261,9 @@ int git_refdb_rename(
{
int error;
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+
error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message);
if (error < 0)
return error;
@@ -268,7 +278,9 @@ int git_refdb_rename(
int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target)
{
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
+
return db->backend->del(db->backend, ref_name, old_id, old_target);
}
@@ -276,7 +288,8 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name)
{
int error;
- assert(db && db->backend);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(db->backend);
if ((error = db->backend->reflog_read(out, db->backend, name)) < 0)
return error;
@@ -368,14 +381,16 @@ out:
int git_refdb_has_log(git_refdb *db, const char *refname)
{
- assert(db && refname);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
return db->backend->has_log(db->backend, refname);
}
int git_refdb_ensure_log(git_refdb *db, const char *refname)
{
- assert(db && refname);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
return db->backend->ensure_log(db->backend, refname);
}
@@ -389,7 +404,9 @@ int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
{
- assert(payload && db && refname);
+ GIT_ASSERT_ARG(payload);
+ GIT_ASSERT_ARG(db);
+ GIT_ASSERT_ARG(refname);
if (!db->backend->lock) {
git_error_set(GIT_ERROR_REFERENCE, "backend does not support locking");
@@ -401,7 +418,7 @@ int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message)
{
- assert(db);
+ GIT_ASSERT_ARG(db);
return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message);
}