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