tests: fix cast warnings /home/kas/git/public/libgit2/tests/t00-core.c: In function ‘test_cmp’: /home/kas/git/public/libgit2/tests/t00-core.c:78:10: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t00-core.c:78:22: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t07-hashtable.c: In function ‘hash_func’: /home/kas/git/public/libgit2/tests/t07-hashtable.c:42:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write0’: /home/kas/git/public/libgit2/tests/t08-tag.c:141:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write2’: /home/kas/git/public/libgit2/tests/t08-tag.c:192:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write3’: /home/kas/git/public/libgit2/tests/t08-tag.c:227:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t04-commit.c: In function ‘_gittest__write0’: /home/kas/git/public/libgit2/tests/t04-commit.c:650:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t04-commit.c:651:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t04-commit.c: In function ‘_gittest__root0’: /home/kas/git/public/libgit2/tests/t04-commit.c:723:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t04-commit.c:724:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/tests/t12-repo.c: In function ‘write_file’: /home/kas/git/public/libgit2/tests/t12-repo.c:360:24: 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 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
diff --git a/tests/t00-core.c b/tests/t00-core.c
index 1037ee2..6d63d1c 100644
--- a/tests/t00-core.c
+++ b/tests/t00-core.c
@@ -75,7 +75,7 @@ END_TEST
static int test_cmp(const void *a, const void *b)
{
- return *(int *)a - *(int *)b;
+ return *(const int *)a - *(const int *)b;
}
BEGIN_TEST(vector2, "remove duplicates")
diff --git a/tests/t04-commit.c b/tests/t04-commit.c
index 1c39082..53f0fae 100644
--- a/tests/t04-commit.c
+++ b/tests/t04-commit.c
@@ -615,7 +615,8 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
git_repository *repo;
git_commit *commit;
git_oid tree_id, parent_id, commit_id;
- const git_signature *author, *committer;
+ git_signature *author, *committer;
+ const git_signature *author1, *committer1;
git_commit *parent;
git_tree *tree;
@@ -647,25 +648,25 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
git_object_close((git_object *)parent);
git_object_close((git_object *)tree);
- git_signature_free((git_signature *)committer);
- git_signature_free((git_signature *)author);
+ git_signature_free(committer);
+ git_signature_free(author);
must_pass(git_commit_lookup(&commit, repo, &commit_id));
/* Check attributes were set correctly */
- author = git_commit_author(commit);
- must_be_true(author != NULL);
- must_be_true(strcmp(author->name, COMMITTER_NAME) == 0);
- must_be_true(strcmp(author->email, COMMITTER_EMAIL) == 0);
- must_be_true(author->when.time == 987654321);
- must_be_true(author->when.offset == 90);
-
- committer = git_commit_committer(commit);
- must_be_true(committer != NULL);
- must_be_true(strcmp(committer->name, COMMITTER_NAME) == 0);
- must_be_true(strcmp(committer->email, COMMITTER_EMAIL) == 0);
- must_be_true(committer->when.time == 123456789);
- must_be_true(committer->when.offset == 60);
+ author1 = git_commit_author(commit);
+ must_be_true(author1 != NULL);
+ must_be_true(strcmp(author1->name, COMMITTER_NAME) == 0);
+ must_be_true(strcmp(author1->email, COMMITTER_EMAIL) == 0);
+ must_be_true(author1->when.time == 987654321);
+ must_be_true(author1->when.offset == 90);
+
+ committer1 = git_commit_committer(commit);
+ must_be_true(committer1 != NULL);
+ must_be_true(strcmp(committer1->name, COMMITTER_NAME) == 0);
+ must_be_true(strcmp(committer1->email, COMMITTER_EMAIL) == 0);
+ must_be_true(committer1->when.time == 123456789);
+ must_be_true(committer1->when.offset == 60);
must_be_true(strcmp(git_commit_message(commit), COMMIT_MESSAGE) == 0);
@@ -683,7 +684,7 @@ BEGIN_TEST(root0, "create a root commit")
git_commit *commit;
git_oid tree_id, commit_id;
const git_oid *branch_oid;
- const git_signature *author, *committer;
+ git_signature *author, *committer;
const char *branch_name = "refs/heads/root-commit-branch";
git_reference *head, *branch;
char *head_old;
@@ -720,8 +721,8 @@ BEGIN_TEST(root0, "create a root commit")
0));
git_object_close((git_object *)tree);
- git_signature_free((git_signature *)committer);
- git_signature_free((git_signature *)author);
+ git_signature_free(committer);
+ git_signature_free(author);
/*
* The fact that creating a commit works has already been
diff --git a/tests/t07-hashtable.c b/tests/t07-hashtable.c
index 0b362ca..7313f2c 100644
--- a/tests/t07-hashtable.c
+++ b/tests/t07-hashtable.c
@@ -37,9 +37,8 @@ typedef struct _aux_object {
uint32_t hash_func(const void *key, int hash_id)
{
uint32_t r;
- git_oid *id;
+ const git_oid *id = key;
- id = (git_oid *)key;
memcpy(&r, id->id + (hash_id * sizeof(uint32_t)), sizeof(r));
return r;
}
diff --git a/tests/t08-tag.c b/tests/t08-tag.c
index 2e33055..3ac9aa7 100644
--- a/tests/t08-tag.c
+++ b/tests/t08-tag.c
@@ -115,7 +115,8 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again")
git_repository *repo;
git_tag *tag;
git_oid target_id, tag_id;
- const git_signature *tagger;
+ git_signature *tagger;
+ const git_signature *tagger1;
git_reference *ref_tag;
git_object *target;
@@ -138,18 +139,18 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again")
0));
git_object_close(target);
- git_signature_free((git_signature *)tagger);
+ git_signature_free(tagger);
must_pass(git_tag_lookup(&tag, repo, &tag_id));
must_be_true(git_oid_cmp(git_tag_target_oid(tag), &target_id) == 0);
/* Check attributes were set correctly */
- tagger = git_tag_tagger(tag);
- must_be_true(tagger != NULL);
- must_be_true(strcmp(tagger->name, TAGGER_NAME) == 0);
- must_be_true(strcmp(tagger->email, TAGGER_EMAIL) == 0);
- must_be_true(tagger->when.time == 123456789);
- must_be_true(tagger->when.offset == 60);
+ tagger1 = git_tag_tagger(tag);
+ must_be_true(tagger1 != NULL);
+ must_be_true(strcmp(tagger1->name, TAGGER_NAME) == 0);
+ must_be_true(strcmp(tagger1->email, TAGGER_EMAIL) == 0);
+ must_be_true(tagger1->when.time == 123456789);
+ must_be_true(tagger1->when.offset == 60);
must_be_true(strcmp(git_tag_message(tag), TAGGER_MESSAGE) == 0);
@@ -167,7 +168,7 @@ END_TEST
BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already existing tag")
git_repository *repo;
git_oid target_id, tag_id;
- const git_signature *tagger;
+ git_signature *tagger;
git_object *target;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
@@ -189,7 +190,7 @@ BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already
0));
git_object_close(target);
- git_signature_free((git_signature *)tagger);
+ git_signature_free(tagger);
git_repository_free(repo);
@@ -198,7 +199,7 @@ END_TEST
BEGIN_TEST(write3, "Replace an already existing tag")
git_repository *repo;
git_oid target_id, tag_id, old_tag_id;
- const git_signature *tagger;
+ git_signature *tagger;
git_reference *ref_tag;
git_object *target;
@@ -224,7 +225,7 @@ BEGIN_TEST(write3, "Replace an already existing tag")
1));
git_object_close(target);
- git_signature_free((git_signature *)tagger);
+ git_signature_free(tagger);
must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b"));
must_be_true(git_oid_cmp(git_reference_oid(ref_tag), &tag_id) == 0);
diff --git a/tests/t12-repo.c b/tests/t12-repo.c
index 5d6ad48..9e6876d 100644
--- a/tests/t12-repo.c
+++ b/tests/t12-repo.c
@@ -357,7 +357,7 @@ static int write_file(const char *path, const char *content)
if (file < GIT_SUCCESS)
return file;
- error = p_write(file, (void*)content, strlen(content) * sizeof(char));
+ error = p_write(file, content, strlen(content) * sizeof(char));
p_close(file);