diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/src/config.c b/src/config.c index 42f46e6cf..a6a8cb246 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; @@ -886,7 +889,8 @@ int git_config_get_string_buf( int ret; const char *str; - git_buf_sanitize(out); + if ((ret = git_buf_sanitize(out)) < 0) + return ret; ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS); str = !ret ? (entry->value ? entry->value : "") : NULL; @@ -1084,19 +1088,31 @@ void git_config_iterator_free(git_config_iterator *iter) int git_config_find_global(git_buf *path) { - git_buf_sanitize(path); + int error; + + if ((error = git_buf_sanitize(path)) < 0) + return error; + return git_sysdir_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL); } int git_config_find_xdg(git_buf *path) { - git_buf_sanitize(path); + int error; + + if ((error = git_buf_sanitize(path)) < 0) + return error; + return git_sysdir_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG); } int git_config_find_system(git_buf *path) { - git_buf_sanitize(path); + int error; + + if ((error = git_buf_sanitize(path)) < 0) + return error; + return git_sysdir_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM); } @@ -1104,7 +1120,9 @@ int git_config_find_programdata(git_buf *path) { int ret; - git_buf_sanitize(path); + if ((ret = git_buf_sanitize(path)) < 0) + return ret; + ret = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA); if (ret != GIT_OK) @@ -1182,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) { @@ -1202,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) { @@ -1360,9 +1378,13 @@ fail_parse: int git_config_parse_path(git_buf *out, const char *value) { - assert(out && value); + int error; - git_buf_sanitize(out); + GIT_ASSERT_ARG(out); + GIT_ASSERT_ARG(value); + + if ((error = git_buf_sanitize(out)) < 0) + return error; if (value[0] == '~') { if (value[1] != '\0' && value[1] != '/') { @@ -1405,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); |