From: Antoine Pelisse <apelisse@gmail.com>
To: John Keeping <john@keeping.me.uk>, Max Horn <max@quendi.de>,
Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>, Johannes Sixt <j6t@kdbg.org>,
Antoine Pelisse <apelisse@gmail.com>
Subject: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
Date: Wed, 16 Jan 2013 23:47:22 +0100 [thread overview]
Message-ID: <1358376443-7404-1-git-send-email-apelisse@gmail.com> (raw)
In-Reply-To: <20130116182449.GA4881@sigill.intra.peff.net>
clang incorrectly reports a constant conversion warning (implicit
truncation to bit field) when using the "flag &= ~FLAG" form, because
~FLAG needs to be truncated.
Convert this form to "flag = flag & ~FLAG" fixes the issue as
the right operand now fits into the bit field.
Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
---
I'm sorry about this fix, it really seems bad, yet it's one step closer
to warning-free clang compilation.
It seems quite clear to me that it's a bug in clang.
bisect.c | 2 +-
builtin/checkout.c | 2 +-
builtin/reflog.c | 4 ++--
commit.c | 4 ++--
revision.c | 8 ++++----
upload-pack.c | 4 ++--
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bisect.c b/bisect.c
index bd1b7b5..34ac01d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -63,7 +63,7 @@ static void clear_distance(struct commit_list *list)
{
while (list) {
struct commit *commit = list->item;
- commit->object.flags &= ~COUNTED;
+ commit->object.flags = commit->object.flags & ~COUNTED;
list = list->next;
}
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a9c1b5a..2c83234 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -717,7 +717,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
init_revisions(&revs, NULL);
setup_revisions(0, NULL, &revs, NULL);
- object->flags &= ~UNINTERESTING;
+ object->flags = object->flags & ~UNINTERESTING;
add_pending_object(&revs, object, sha1_to_hex(object->sha1));
for_each_ref(add_pending_uninteresting_ref, &revs);
diff --git a/builtin/reflog.c b/builtin/reflog.c
index b3c9e27..3079c81 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -170,7 +170,7 @@ static int commit_is_complete(struct commit *commit)
}
/* clear flags from the objects we traversed */
for (i = 0; i < found.nr; i++)
- found.objects[i].item->flags &= ~STUDYING;
+ found.objects[i].item->flags = found.objects[i].item->flags& ~STUDYING;
if (is_incomplete)
commit->object.flags |= INCOMPLETE;
else {
@@ -229,7 +229,7 @@ static void mark_reachable(struct expire_reflog_cb *cb)
struct commit_list *leftover = NULL;
for (pending = cb->mark_list; pending; pending = pending->next)
- pending->item->object.flags &= ~REACHABLE;
+ pending->item->object.flags = pending->item->object.flags & ~REACHABLE;
pending = cb->mark_list;
while (pending) {
diff --git a/commit.c b/commit.c
index e8eb0ae..800779d 100644
--- a/commit.c
+++ b/commit.c
@@ -883,7 +883,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
/* Uniquify */
for (p = heads; p; p = p->next)
- p->item->object.flags &= ~STALE;
+ p->item->object.flags = p->item->object.flags & ~STALE;
for (p = heads, num_head = 0; p; p = p->next) {
if (p->item->object.flags & STALE)
continue;
@@ -894,7 +894,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
for (p = heads, i = 0; p; p = p->next) {
if (p->item->object.flags & STALE) {
array[i++] = p->item;
- p->item->object.flags &= ~STALE;
+ p->item->object.flags = p->item->object.flags & ~STALE;
}
}
num_head = remove_redundant(array, num_head);
diff --git a/revision.c b/revision.c
index d7562ee..ed1c16d 100644
--- a/revision.c
+++ b/revision.c
@@ -787,9 +787,9 @@ static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *li
/* We are done with the TMP_MARK */
for (p = list; p; p = p->next)
- p->item->object.flags &= ~TMP_MARK;
+ p->item->object.flags = p->item->object.flags & ~TMP_MARK;
for (p = bottom; p; p = p->next)
- p->item->object.flags &= ~TMP_MARK;
+ p->item->object.flags = p->item->object.flags & ~TMP_MARK;
free_commit_list(rlist);
}
@@ -1948,7 +1948,7 @@ static int remove_duplicate_parents(struct commit *commit)
/* count them while clearing the temporary mark */
surviving_parents = 0;
for (p = commit->parents; p; p = p->next) {
- p->item->object.flags &= ~TMP_MARK;
+ p->item->object.flags = p->item->object.flags & ~TMP_MARK;
surviving_parents++;
}
return surviving_parents;
@@ -2378,7 +2378,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
if (revs->reflog_info) {
fake_reflog_parent(revs->reflog_info, commit);
- commit->object.flags &= ~(ADDED | SEEN | SHOWN);
+ commit->object.flags = commit->object.flags & ~(ADDED | SEEN | SHOWN);
}
/*
diff --git a/upload-pack.c b/upload-pack.c
index 7c05b15..74d8f0e 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -113,7 +113,7 @@ static int do_rev_list(int in, int out, void *user_data)
for (i = 0; i < want_obj.nr; i++) {
struct object *o = want_obj.objects[i].item;
/* why??? */
- o->flags &= ~UNINTERESTING;
+ o->flags = o->flags & ~UNINTERESTING;
add_pending_object(&revs, o, NULL);
}
for (i = 0; i < have_obj.nr; i++) {
@@ -700,7 +700,7 @@ static void receive_needs(void)
struct commit_list *parents;
packet_write(1, "unshallow %s",
sha1_to_hex(object->sha1));
- object->flags &= ~CLIENT_SHALLOW;
+ object->flags = object->flags & ~CLIENT_SHALLOW;
/* make sure the real parents are parsed */
unregister_shallow(object->sha1);
object->parsed = 0;
--
1.8.1.1.435.g20d29be.dirty
next prev parent reply other threads:[~2013-01-16 22:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 14:53 [PATCH] fix some clang warnings Max Horn
2013-01-16 16:04 ` Jeff King
2013-01-16 16:53 ` Junio C Hamano
2013-01-16 17:12 ` Antoine Pelisse
2013-01-16 17:18 ` John Keeping
2013-01-16 17:26 ` Max Horn
2013-01-16 17:50 ` Jeff King
2013-01-16 18:00 ` Jeff King
2013-01-16 18:09 ` Jeff King
2013-01-16 18:12 ` John Keeping
2013-01-16 18:15 ` Jeff King
2013-01-16 18:21 ` Antoine Pelisse
2013-01-16 18:22 ` John Keeping
2013-01-16 18:24 ` Jeff King
2013-01-16 19:01 ` John Keeping
2013-01-17 10:24 ` John Keeping
2013-01-16 22:47 ` Antoine Pelisse [this message]
2013-01-16 22:47 ` [PATCH 2/2] fix clang -Wtautological-compare with unsigned enum Antoine Pelisse
2013-01-16 23:10 ` Antoine Pelisse
2013-01-17 10:32 ` Antoine Pelisse
2013-01-17 11:00 ` John Keeping
2013-01-17 11:23 ` [PATCH] combine-diff: suppress a clang warning John Keeping
2013-01-17 16:44 ` [PATCH 2/2] fix clang -Wtautological-compare with unsigned enum Linus Torvalds
2013-01-17 16:56 ` Antoine Pelisse
2013-01-17 17:02 ` John Keeping
2013-01-18 17:15 ` Phil Hord
2013-01-18 18:52 ` Linus Torvalds
2013-01-16 23:08 ` [PATCH 1/2] fix clang -Wconstant-conversion with bit fields John Keeping
2013-01-16 23:09 ` Antoine Pelisse
2013-01-16 23:15 ` Antoine Pelisse
2013-01-16 23:43 ` Junio C Hamano
2013-01-16 23:46 ` Junio C Hamano
2013-01-16 18:03 ` [PATCH] fix some clang warnings Tomas Carnecky
2013-01-16 18:12 ` Matthieu Moy
2013-02-01 5:37 ` Miles Bader
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=1358376443-7404-1-git-send-email-apelisse@gmail.com \
--to=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=john@keeping.me.uk \
--cc=max@quendi.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).