object: 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
diff --git a/src/object.c b/src/object.c
index fa97534..42e1e46 100644
--- a/src/object.c
+++ b/src/object.c
@@ -67,7 +67,7 @@ int git_object__from_raw(
size_t object_size;
int error;
- assert(object_out);
+ GIT_ASSERT_ARG(object_out);
*object_out = NULL;
/* Validate type match */
@@ -91,7 +91,7 @@ int git_object__from_raw(
/* Parse raw object data */
def = &git_objects_table[type];
- assert(def->free && def->parse_raw);
+ GIT_ASSERT(def->free && def->parse_raw);
if ((error = def->parse_raw(object, data, size)) < 0) {
def->free(object);
@@ -115,7 +115,7 @@ int git_object__from_odb_object(
git_object_def *def;
git_object *object = NULL;
- assert(object_out);
+ GIT_ASSERT_ARG(object_out);
*object_out = NULL;
/* Validate type match */
@@ -141,7 +141,7 @@ int git_object__from_odb_object(
/* Parse raw object data */
def = &git_objects_table[odb_obj->cached.type];
- assert(def->free && def->parse);
+ GIT_ASSERT(def->free && def->parse);
if ((error = def->parse(object, odb_obj)) < 0)
def->free(object);
@@ -174,7 +174,9 @@ int git_object_lookup_prefix(
git_odb_object *odb_obj = NULL;
int error = 0;
- assert(repo && object_out && id);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(object_out);
+ GIT_ASSERT_ARG(id);
if (len < GIT_OID_MINPREFIXLEN) {
git_error_set(GIT_ERROR_OBJECT, "ambiguous lookup - OID prefix is too short");
@@ -211,7 +213,7 @@ int git_object_lookup_prefix(
} else if (cached->flags == GIT_CACHE_STORE_RAW) {
odb_obj = (git_odb_object *)cached;
} else {
- assert(!"Wrong caching type in the global object cache");
+ GIT_ASSERT(!"Wrong caching type in the global object cache");
}
} else {
/* Object was not found in the cache, let's explore the backends.
@@ -263,19 +265,19 @@ void git_object_free(git_object *object)
const git_oid *git_object_id(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
return &obj->cached.oid;
}
git_object_t git_object_type(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, GIT_OBJECT_INVALID);
return obj->cached.type;
}
git_repository *git_object_owner(const git_object *obj)
{
- assert(obj);
+ GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
return obj->repo;
}
@@ -396,9 +398,10 @@ int git_object_peel(
git_object *source, *deref = NULL;
int error;
- assert(object && peeled);
+ GIT_ASSERT_ARG(object);
+ GIT_ASSERT_ARG(peeled);
- assert(target_type == GIT_OBJECT_TAG ||
+ GIT_ASSERT_ARG(target_type == GIT_OBJECT_TAG ||
target_type == GIT_OBJECT_COMMIT ||
target_type == GIT_OBJECT_TREE ||
target_type == GIT_OBJECT_BLOB ||
@@ -461,7 +464,9 @@ int git_object_lookup_bypath(
git_tree *tree = NULL;
git_tree_entry *entry = NULL;
- assert(out && treeish && path);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(treeish);
+ GIT_ASSERT_ARG(path);
if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJECT_TREE)) < 0 ||
(error = git_tree_entry_bypath(&entry, tree, path)) < 0)
@@ -493,7 +498,8 @@ int git_object_short_id(git_buf *out, const git_object *obj)
git_oid id = {{0}};
git_odb *odb;
- assert(out && obj);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(obj);
if ((error = git_buf_sanitize(out)) < 0)
return error;