All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Jim Meyering" <jim@meyering.net>,
	"Fredrik Gustafsson" <iveqy@iveqy.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/3] diff/apply: cast variable in call to free()
Date: Sun,  6 Nov 2011 13:06:23 +0100	[thread overview]
Message-ID: <1320581184-4557-3-git-send-email-avarab@gmail.com> (raw)
In-Reply-To: <1320581184-4557-1-git-send-email-avarab@gmail.com>

Both of these free() calls are freeing a "const unsigned char (*)[20]"
type while free() expects a "void *". This results in the following
warning under clang 2.9:

    builtin/diff.c:185:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers
            free(parent);
                 ^~~~~~

    submodule.c:394:7: warning: passing 'const unsigned char (*)[20]' to parameter of type 'void *' discards qualifiers
            free(parents);
                 ^~~~~~~

This free()-ing without a cast was added by Jim Meyering to
builtin/diff.c in v1.7.6-rc3~4 and later by Fredrik Gustafsson in
submodule.c in v1.7.7-rc1~25^2.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/diff.c |    2 +-
 submodule.c    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/diff.c b/builtin/diff.c
index 1118689..0fe638f 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -182,7 +182,7 @@ static int builtin_diff_combined(struct rev_info *revs,
 		hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
 	diff_tree_combined(parent[0], parent + 1, ents - 1,
 			   revs->dense_combined_merges, revs);
-	free(parent);
+	free((void *)parent);
 	return 0;
 }
 
diff --git a/submodule.c b/submodule.c
index 0fd10a0..52cdcc6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -391,7 +391,7 @@ static void commit_need_pushing(struct commit *commit, struct commit_list *paren
 	rev.diffopt.format_callback_data = needs_pushing;
 	diff_tree_combined(commit->object.sha1, parents, n, 1, &rev);
 
-	free(parents);
+	free((void *)parents);
 }
 
 int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remotes_name)
-- 
1.7.6.3

  parent reply	other threads:[~2011-11-06 12:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 12:06 [PATCH 0/3] Fix code issues spotted by clang Ævar Arnfjörð Bjarmason
2011-11-06 12:06 ` [PATCH 1/3] apply: get rid of useless x < 0 comparison on a size_t type Ævar Arnfjörð Bjarmason
2011-11-06 18:35   ` Junio C Hamano
2011-11-07 19:09     ` Giuseppe Bilotta
2011-11-06 12:06 ` Ævar Arnfjörð Bjarmason [this message]
2011-11-06 12:06 ` [PATCH 3/3] grep: get rid of useless x < 0 comparison on an enum member Ævar Arnfjörð Bjarmason
2011-11-06 15:03   ` Andreas Schwab
2011-11-07 12:42     ` Ævar Arnfjörð Bjarmason
2011-11-07 13:12       ` Andreas Schwab
2011-11-07 16:38         ` Jeff King
2011-11-07 18:24           ` Andreas Schwab
2011-11-07 18:34             ` Jeff King
2011-11-07 18:55               ` Jeff King
2011-11-07 19:06                 ` Ævar Arnfjörð Bjarmason
2011-11-07 20:13                 ` Andreas Schwab
2011-11-07 19:49   ` Jonathan Nieder
2011-11-07 21:18     ` Junio C Hamano
2011-11-07 21:32       ` Jonathan Nieder
2011-11-07 21:48         ` Junio C Hamano
2011-11-07 22:21           ` Jonathan Nieder
2011-11-06 12:33 ` [PATCH 0/3] Fix code issues spotted by clang Ævar Arnfjörð Bjarmason
2011-11-08 16:05   ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320581184-4557-3-git-send-email-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=iveqy@iveqy.com \
    --cc=jim@meyering.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.