filter: 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/filter.c b/src/filter.c
index ae9220c..ccabdcd 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -266,7 +266,8 @@ int git_filter_register(
{
int error;
- assert(name && filter);
+ GIT_ASSERT_ARG(name);
+ GIT_ASSERT_ARG(filter);
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -293,7 +294,7 @@ int git_filter_unregister(const char *name)
git_filter_def *fdef;
int error = 0;
- assert(name);
+ GIT_ASSERT_ARG(name);
/* cannot unregister default filters */
if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
@@ -618,7 +619,7 @@ int git_filter_list_contains(
{
size_t i;
- assert(name);
+ GIT_ASSERT_ARG(name);
if (!fl)
return 0;
@@ -639,7 +640,8 @@ int git_filter_list_push(
git_filter_def *fdef = NULL;
git_filter_entry *fe;
- assert(fl && filter);
+ GIT_ASSERT_ARG(fl);
+ GIT_ASSERT_ARG(filter);
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -684,9 +686,8 @@ static int buf_stream_write(
git_writestream *s, const char *buffer, size_t len)
{
struct buf_stream *buf_stream = (struct buf_stream *)s;
- assert(buf_stream);
-
- assert(buf_stream->complete == 0);
+ GIT_ASSERT_ARG(buf_stream);
+ GIT_ASSERT(buf_stream->complete == 0);
return git_buf_put(buf_stream->target, buffer, len);
}
@@ -694,9 +695,9 @@ static int buf_stream_write(
static int buf_stream_close(git_writestream *s)
{
struct buf_stream *buf_stream = (struct buf_stream *)s;
- assert(buf_stream);
+ GIT_ASSERT_ARG(buf_stream);
- assert(buf_stream->complete == 0);
+ GIT_ASSERT(buf_stream->complete == 0);
buf_stream->complete = 1;
return 0;
@@ -740,7 +741,7 @@ int git_filter_list_apply_to_data(
&writer.parent)) < 0)
return error;
- assert(writer.complete);
+ GIT_ASSERT(writer.complete);
return error;
}
@@ -759,7 +760,7 @@ int git_filter_list_apply_to_file(
filters, repo, path, &writer.parent)) < 0)
return error;
- assert(writer.complete);
+ GIT_ASSERT(writer.complete);
return error;
}
@@ -790,7 +791,7 @@ int git_filter_list_apply_to_blob(
filters, blob, &writer.parent)) < 0)
return error;
- assert(writer.complete);
+ GIT_ASSERT(writer.complete);
return error;
}
@@ -809,7 +810,7 @@ static int proxy_stream_write(
git_writestream *s, const char *buffer, size_t len)
{
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
- assert(proxy_stream);
+ GIT_ASSERT_ARG(proxy_stream);
return git_buf_put(&proxy_stream->input, buffer, len);
}
@@ -821,7 +822,7 @@ static int proxy_stream_close(git_writestream *s)
git_error_state error_state = {0};
int error;
- assert(proxy_stream);
+ GIT_ASSERT_ARG(proxy_stream);
error = proxy_stream->filter->apply(
proxy_stream->filter,
@@ -856,11 +857,12 @@ static int proxy_stream_close(git_writestream *s)
static void proxy_stream_free(git_writestream *s)
{
struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
- assert(proxy_stream);
- git_buf_dispose(&proxy_stream->input);
- git_buf_dispose(&proxy_stream->temp_buf);
- git__free(proxy_stream);
+ if (proxy_stream) {
+ git_buf_dispose(&proxy_stream->input);
+ git_buf_dispose(&proxy_stream->temp_buf);
+ git__free(proxy_stream);
+ }
}
static int proxy_stream_init(
@@ -914,7 +916,7 @@ static int stream_list_init(
git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
git_writestream *filter_stream;
- assert(fe->filter->stream || fe->filter->apply);
+ GIT_ASSERT(fe->filter->stream || fe->filter->apply);
/* If necessary, create a stream that proxies the traditional
* application.