Commit e7604da8 by Edward Thomson

config: use GIT_ASSERT

parent 3b2153fe
...@@ -108,7 +108,8 @@ int git_config_add_file_ondisk( ...@@ -108,7 +108,8 @@ int git_config_add_file_ondisk(
struct stat st; struct stat st;
int res; int res;
assert(cfg && path); GIT_ASSERT_ARG(cfg);
GIT_ASSERT_ARG(path);
res = p_stat(path, &st); res = p_stat(path, &st);
if (res < 0 && errno != ENOENT && errno != ENOTDIR) { if (res < 0 && errno != ENOENT && errno != ENOTDIR) {
...@@ -316,7 +317,8 @@ int git_config_add_backend( ...@@ -316,7 +317,8 @@ int git_config_add_backend(
backend_internal *internal; backend_internal *internal;
int result; int result;
assert(cfg && backend); GIT_ASSERT_ARG(cfg);
GIT_ASSERT_ARG(backend);
GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
...@@ -514,7 +516,8 @@ int git_config_backend_foreach_match( ...@@ -514,7 +516,8 @@ int git_config_backend_foreach_match(
git_regexp regex; git_regexp regex;
int error = 0; int error = 0;
assert(backend && cb); GIT_ASSERT_ARG(backend);
GIT_ASSERT_ARG(cb);
if (regexp && git_regexp_compile(&regex, regexp, 0) < 0) if (regexp && git_regexp_compile(&regex, regexp, 0) < 0)
return -1; return -1;
...@@ -1197,7 +1200,7 @@ int git_config_lock(git_transaction **out, git_config *cfg) ...@@ -1197,7 +1200,7 @@ int git_config_lock(git_transaction **out, git_config *cfg)
git_config_backend *backend; git_config_backend *backend;
backend_internal *internal; backend_internal *internal;
assert(cfg); GIT_ASSERT_ARG(cfg);
internal = git_vector_get(&cfg->backends, 0); internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) { if (!internal || !internal->backend) {
...@@ -1217,7 +1220,7 @@ int git_config_unlock(git_config *cfg, int commit) ...@@ -1217,7 +1220,7 @@ int git_config_unlock(git_config *cfg, int commit)
git_config_backend *backend; git_config_backend *backend;
backend_internal *internal; backend_internal *internal;
assert(cfg); GIT_ASSERT_ARG(cfg);
internal = git_vector_get(&cfg->backends, 0); internal = git_vector_get(&cfg->backends, 0);
if (!internal || !internal->backend) { if (!internal || !internal->backend) {
...@@ -1377,7 +1380,8 @@ int git_config_parse_path(git_buf *out, const char *value) ...@@ -1377,7 +1380,8 @@ int git_config_parse_path(git_buf *out, const char *value)
{ {
int error; int error;
assert(out && value); GIT_ASSERT_ARG(out);
GIT_ASSERT_ARG(value);
if ((error = git_buf_sanitize(out)) < 0) if ((error = git_buf_sanitize(out)) < 0)
return error; return error;
...@@ -1423,7 +1427,8 @@ int git_config__normalize_name(const char *in, char **out) ...@@ -1423,7 +1427,8 @@ int git_config__normalize_name(const char *in, char **out)
{ {
char *name, *fdot, *ldot; char *name, *fdot, *ldot;
assert(in && out); GIT_ASSERT_ARG(in);
GIT_ASSERT_ARG(out);
name = git__strdup(in); name = git__strdup(in);
GIT_ERROR_CHECK_ALLOC(name); GIT_ERROR_CHECK_ALLOC(name);
......
...@@ -365,7 +365,7 @@ static int config_file_set_multivar( ...@@ -365,7 +365,7 @@ static int config_file_set_multivar(
int result; int result;
char *key; char *key;
assert(regexp); GIT_ASSERT_ARG(regexp);
if ((result = git_config__normalize_name(name, &key)) < 0) if ((result = git_config__normalize_name(name, &key)) < 0)
return result; return result;
...@@ -531,7 +531,7 @@ static char *escape_value(const char *ptr) ...@@ -531,7 +531,7 @@ static char *escape_value(const char *ptr)
size_t len; size_t len;
const char *esc; const char *esc;
assert(ptr); GIT_ASSERT_ARG_WITH_RETVAL(ptr, NULL);
len = strlen(ptr); len = strlen(ptr);
if (!len) if (!len)
......
...@@ -187,7 +187,7 @@ static int parse_section_header(git_config_parser *reader, char **section_out) ...@@ -187,7 +187,7 @@ static int parse_section_header(git_config_parser *reader, char **section_out)
/* Make sure we were given a section header */ /* Make sure we were given a section header */
c = line[pos++]; c = line[pos++];
assert(c == '['); GIT_ASSERT(c == '[');
c = line[pos++]; c = line[pos++];
......
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