Commit c6e84bce by Edward Thomson

apply: use GIT_ASSERT

parent f60ebfcb
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
* a Linking Exception. For full terms see the included COPYING file. * a Linking Exception. For full terms see the included COPYING file.
*/ */
#include "apply.h"
#include "git2/apply.h" #include "git2/apply.h"
#include "git2/patch.h" #include "git2/patch.h"
#include "git2/filter.h" #include "git2/filter.h"
...@@ -21,6 +19,7 @@ ...@@ -21,6 +19,7 @@
#include "zstream.h" #include "zstream.h"
#include "reader.h" #include "reader.h"
#include "index.h" #include "index.h"
#include "apply.h"
typedef struct { typedef struct {
/* The lines that we allocate ourself are allocated out of the pool. /* The lines that we allocate ourself are allocated out of the pool.
...@@ -399,7 +398,11 @@ int git_apply__patch( ...@@ -399,7 +398,11 @@ int git_apply__patch(
unsigned int mode = 0; unsigned int mode = 0;
int error = 0; int error = 0;
assert(contents_out && filename_out && mode_out && (source || !source_len) && patch); GIT_ASSERT_ARG(contents_out);
GIT_ASSERT_ARG(filename_out);
GIT_ASSERT_ARG(mode_out);
GIT_ASSERT_ARG(source || !source_len);
GIT_ASSERT_ARG(patch);
if (given_opts) if (given_opts)
memcpy(&ctx.opts, given_opts, sizeof(git_apply_options)); memcpy(&ctx.opts, given_opts, sizeof(git_apply_options));
...@@ -624,7 +627,10 @@ int git_apply_to_tree( ...@@ -624,7 +627,10 @@ int git_apply_to_tree(
size_t i; size_t i;
int error = 0; int error = 0;
assert(out && repo && preimage && diff); GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(repo);
GIT_ASSERT_ARG(preimage);
GIT_ASSERT_ARG(diff);
*out = NULL; *out = NULL;
...@@ -772,6 +778,8 @@ done: ...@@ -772,6 +778,8 @@ done:
int git_apply_options_init(git_apply_options *opts, unsigned int version) int git_apply_options_init(git_apply_options *opts, unsigned int version)
{ {
GIT_ASSERT_ARG(opts);
GIT_INIT_STRUCTURE_FROM_TEMPLATE( GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT); opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT);
return 0; return 0;
...@@ -805,7 +813,8 @@ int git_apply( ...@@ -805,7 +813,8 @@ int git_apply(
git_apply_options opts = GIT_APPLY_OPTIONS_INIT; git_apply_options opts = GIT_APPLY_OPTIONS_INIT;
int error = GIT_EINVALID; int error = GIT_EINVALID;
assert(repo && diff); GIT_ASSERT_ARG(repo);
GIT_ASSERT_ARG(diff);
GIT_ERROR_CHECK_VERSION( GIT_ERROR_CHECK_VERSION(
given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options"); given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options");
...@@ -829,7 +838,7 @@ int git_apply( ...@@ -829,7 +838,7 @@ int git_apply(
error = git_reader_for_workdir(&pre_reader, repo, false); error = git_reader_for_workdir(&pre_reader, repo, false);
break; break;
default: default:
assert(false); GIT_ASSERT(false);
} }
if (error < 0) if (error < 0)
...@@ -869,7 +878,7 @@ int git_apply( ...@@ -869,7 +878,7 @@ int git_apply(
error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts); error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts);
break; break;
default: default:
assert(false); GIT_ASSERT(false);
} }
if (error < 0) if (error < 0)
......
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