tree: fix cast warnings /home/kas/git/public/libgit2/src/tree.c: In function ‘entry_search_cmp’: /home/kas/git/public/libgit2/src/tree.c:47:36: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/tree.c: In function ‘git_treebuilder_remove’: /home/kas/git/public/libgit2/src/tree.c:443:31: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
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
diff --git a/src/tree.c b/src/tree.c
index 975d36a..8e37066 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -44,8 +44,8 @@ struct tree_key_search {
int entry_search_cmp(const void *key, const void *array_member)
{
- struct tree_key_search *ksearch = (struct tree_key_search *)key;
- const git_tree_entry *entry = (const git_tree_entry *)(array_member);
+ const struct tree_key_search *ksearch = key;
+ const git_tree_entry *entry = array_member;
int result =
git_futils_cmp_path(
@@ -415,7 +415,7 @@ int git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, con
return GIT_SUCCESS;
}
-const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *filename)
+static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename)
{
int idx;
git_tree_entry *entry;
@@ -438,9 +438,14 @@ const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *file
return entry;
}
+const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *filename)
+{
+ return treebuilder_get(bld, filename);
+}
+
int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
{
- git_tree_entry *remove_ptr = (git_tree_entry *)git_treebuilder_get(bld, filename);
+ git_tree_entry *remove_ptr = treebuilder_get(bld, filename);
if (remove_ptr == NULL || remove_ptr->removed)
return git__throw(GIT_ENOTFOUND, "Failed to remove entry. File isn't in the tree");