Commit bc54898f by Edward Thomson

filter: use GIT_ASSERT

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