mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 04:28:26 +00:00
Merge pull request #4086 from libgit2/ethomson/fixes
WIP: some coverity & compiler warning fixes
This commit is contained in:
commit
8df1cfc9d7
@ -121,20 +121,22 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
|
||||
{
|
||||
int error = 0;
|
||||
git_attr_file_entry *entry;
|
||||
git_attr_file *old = NULL;
|
||||
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
if ((error = attr_cache_lock(cache)) < 0)
|
||||
return error;
|
||||
|
||||
if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL)
|
||||
file = git__compare_and_swap(&entry->file[file->source], file, NULL);
|
||||
old = git__compare_and_swap(&entry->file[file->source], file, NULL);
|
||||
|
||||
attr_cache_unlock(cache);
|
||||
|
||||
if (file) {
|
||||
GIT_REFCOUNT_OWN(file, NULL);
|
||||
git_attr_file__free(file);
|
||||
if (old) {
|
||||
GIT_REFCOUNT_OWN(old, NULL);
|
||||
git_attr_file__free(old);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
@ -55,16 +55,16 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t
|
||||
}
|
||||
|
||||
/* Use clang/gcc compiler intrinsics whenever possible */
|
||||
#if (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
|
||||
# define git__add_sizet_overflow(out, one, two) \
|
||||
__builtin_uadd_overflow(one, two, out)
|
||||
# define git__multiply_sizet_overflow(out, one, two) \
|
||||
__builtin_umul_overflow(one, two, out)
|
||||
#elif (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
|
||||
#if (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
|
||||
# define git__add_sizet_overflow(out, one, two) \
|
||||
__builtin_uaddl_overflow(one, two, out)
|
||||
# define git__multiply_sizet_overflow(out, one, two) \
|
||||
__builtin_umull_overflow(one, two, out)
|
||||
#elif (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
|
||||
# define git__add_sizet_overflow(out, one, two) \
|
||||
__builtin_uadd_overflow(one, two, out)
|
||||
# define git__multiply_sizet_overflow(out, one, two) \
|
||||
__builtin_umul_overflow(one, two, out)
|
||||
#else
|
||||
|
||||
/**
|
||||
|
@ -188,8 +188,7 @@ static int load_submodule_names(git_strmap *out, git_config *cfg)
|
||||
git_buf_put(&buf, fdot + 1, ldot - fdot - 1);
|
||||
git_strmap_insert(out, entry->value, git_buf_detach(&buf), rval);
|
||||
if (rval < 0) {
|
||||
giterr_set(GITERR_NOMEMORY, "Error inserting submodule into hash table");
|
||||
free_submodule_names(out);
|
||||
giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -513,12 +512,12 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
|
||||
goto cleanup;
|
||||
}
|
||||
/* add back submodule information from index */
|
||||
if (idx) {
|
||||
if (mods && idx) {
|
||||
if ((error = submodules_from_index(map, idx, mods)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
/* add submodule information from HEAD */
|
||||
if (head) {
|
||||
if (mods && head) {
|
||||
if ((error = submodules_from_head(map, head, mods)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -441,6 +441,7 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
|
||||
cl_assert(git_path_exists("testrepo/link_to_new.txt"));
|
||||
cl_assert(git_path_exists("testrepo/new.txt"));
|
||||
|
||||
git_object_free(g_object);
|
||||
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
|
||||
|
||||
g_opts.checkout_strategy =
|
||||
@ -454,10 +455,6 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
|
||||
cl_assert(!git_path_exists("testrepo/branch_file.txt"));
|
||||
cl_assert(!git_path_exists("testrepo/link_to_new.txt"));
|
||||
cl_assert(git_path_exists("testrepo/new.txt"));
|
||||
|
||||
git_object_free(g_object);
|
||||
g_object = NULL;
|
||||
|
||||
}
|
||||
|
||||
void test_checkout_tree__can_disable_pattern_match(void)
|
||||
|
Loading…
Reference in New Issue
Block a user