summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-04-05 17:34:12 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-11-25 11:42:05 +0000
commitba5a789a1dd22a06af460e8335ee2f82825d27cd (patch)
tree871eee566a7762ebf798e84e34d39d0b30dcac3b
parentc227795b1e8a9a366f6b008d7cf60794bfd0ff83 (diff)
downloadlibgit2-ba5a789a1dd22a06af460e8335ee2f82825d27cd.tar.gz
odb_pack: use GIT_ASSERT
-rw-r--r--src/odb_pack.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 86c858df1..e4ad0f4b7 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -358,7 +358,10 @@ static int pack_backend__read_header(
struct git_pack_entry e;
int error;
- assert(len_p && type_p && backend && oid);
+ GIT_ASSERT_ARG(len_p);
+ GIT_ASSERT_ARG(type_p);
+ GIT_ASSERT_ARG(backend);
+ GIT_ASSERT_ARG(oid);
if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0)
return error;
@@ -469,7 +472,9 @@ static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb c
struct pack_backend *backend;
unsigned int i;
- assert(_backend && cb);
+ GIT_ASSERT_ARG(_backend);
+ GIT_ASSERT_ARG(cb);
+
backend = (struct pack_backend *)_backend;
/* Make sure we know about the packfiles */
@@ -488,7 +493,7 @@ static int pack_backend__writepack_append(struct git_odb_writepack *_writepack,
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
- assert(writepack);
+ GIT_ASSERT_ARG(writepack);
return git_indexer_append(writepack->indexer, data, size, stats);
}
@@ -497,16 +502,19 @@ static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack,
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
- assert(writepack);
+ GIT_ASSERT_ARG(writepack);
return git_indexer_commit(writepack->indexer, stats);
}
static void pack_backend__writepack_free(struct git_odb_writepack *_writepack)
{
- struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
+ struct pack_writepack *writepack;
+
+ if (!_writepack)
+ return;
- assert(writepack);
+ writepack = (struct pack_writepack *)_writepack;
git_indexer_free(writepack->indexer);
git__free(writepack);
@@ -522,7 +530,8 @@ static int pack_backend__writepack(struct git_odb_writepack **out,
struct pack_backend *backend;
struct pack_writepack *writepack;
- assert(out && _backend);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(_backend);
*out = NULL;
@@ -555,7 +564,8 @@ static void pack_backend__free(git_odb_backend *_backend)
struct pack_backend *backend;
size_t i;
- assert(_backend);
+ if (!_backend)
+ return;
backend = (struct pack_backend *)_backend;