transaction: 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
diff --git a/src/transaction.c b/src/transaction.c
index 81af8d8..98fa1ba 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -57,7 +57,9 @@ struct git_transaction {
int git_transaction_config_new(git_transaction **out, git_config *cfg)
{
git_transaction *tx;
- assert(out && cfg);
+
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(cfg);
tx = git__calloc(1, sizeof(git_transaction));
GIT_ERROR_CHECK_ALLOC(tx);
@@ -74,7 +76,8 @@ int git_transaction_new(git_transaction **out, git_repository *repo)
git_pool pool;
git_transaction *tx = NULL;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
if ((error = git_pool_init(&pool, 1)) < 0)
goto on_error;
@@ -109,7 +112,8 @@ int git_transaction_lock_ref(git_transaction *tx, const char *refname)
int error;
transaction_node *node;
- assert(tx && refname);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
node = git_pool_mallocz(&tx->pool, sizeof(transaction_node));
GIT_ERROR_CHECK_ALLOC(node);
@@ -176,7 +180,9 @@ int git_transaction_set_target(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -195,7 +201,9 @@ int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname
int error;
transaction_node *node;
- assert(tx && refname && target);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(target);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -272,7 +280,9 @@ int git_transaction_set_reflog(git_transaction *tx, const char *refname, const g
int error;
transaction_node *node;
- assert(tx && refname && reflog);
+ GIT_ASSERT_ARG(tx);
+ GIT_ASSERT_ARG(refname);
+ GIT_ASSERT_ARG(reflog);
if ((error = find_locked(&node, tx, refname)) < 0)
return error;
@@ -320,7 +330,7 @@ int git_transaction_commit(git_transaction *tx)
transaction_node *node;
int error = 0;
- assert(tx);
+ GIT_ASSERT_ARG(tx);
if (tx->type == TRANSACTION_CONFIG) {
error = git_config_unlock(tx->cfg, true);
@@ -355,7 +365,8 @@ void git_transaction_free(git_transaction *tx)
transaction_node *node;
git_pool pool;
- assert(tx);
+ if (!tx)
+ return;
if (tx->type == TRANSACTION_CONFIG) {
if (tx->cfg) {