From: Linus Torvalds <torvalds@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-sparse@vger.kernel.org,
Josh Triplett <josh@freedesktop.org>
Subject: [PATCH 1/2] Fix cast instruction generation
Date: Thu, 24 Apr 2008 14:52:12 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.1.10.0804241443460.2779@woody.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.10.0804241248290.2779@woody.linux-foundation.org>
From: Linus Torvalds <torvalds@woody.linux-foundation.org>
Date: Thu, 24 Apr 2008 14:45:43 -0700
Whether it's a sign-extending cast or not depends on the source
of the cast, not destination. The final size of the cast depends
on the destination, of course.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
In thread "[PATCH] RxRPC: Fix a regression in the RXKAD security module"
On Thu, 24 Apr 2008, Linus Torvalds wrote:
>
> Ok, that looks stupid, and should even have had a warning (shifting a u16
> right by 16 should warn about it being pointless, but doesn't, because the
> compiler quietly expands it to "int" in the meantime).
>
> Hmm. I could do something to sparse that warns about that too.
Something along the lines of this?
Almost totally untested. This first patch is just preparatory to get the
next patch working.
linearize.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/linearize.c b/linearize.c
index 45bb168..ec48dac 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1097,10 +1097,10 @@ static pseudo_t linearize_postop(struct entrypoint *ep, struct expression *expr)
* case, since you can't access through it anyway without another
* cast.
*/
-static struct instruction *alloc_cast_instruction(struct symbol *ctype)
+static struct instruction *alloc_cast_instruction(struct symbol *src, struct symbol *ctype)
{
int opcode = OP_CAST;
- struct symbol *base = ctype;
+ struct symbol *base = src;
if (base->ctype.modifiers & MOD_SIGNED)
opcode = OP_SCAST;
@@ -1127,7 +1127,7 @@ static pseudo_t cast_pseudo(struct entrypoint *ep, pseudo_t src, struct symbol *
return VOID;
if (from->bit_size < 0 || to->bit_size < 0)
return VOID;
- insn = alloc_cast_instruction(to);
+ insn = alloc_cast_instruction(from, to);
result = alloc_pseudo(insn);
insn->target = result;
insn->orig_type = from;
--
1.5.5.1.92.ga5bdc
next parent reply other threads:[~2008-04-24 21:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080424193856.14737.16718.stgit@warthog.procyon.org.uk>
[not found] ` <alpine.LFD.1.10.0804241248290.2779@woody.linux-foundation.org>
2008-04-24 21:52 ` Linus Torvalds [this message]
2008-04-24 21:54 ` [PATCH 2/2] Simplify (and warn about) right shifts that result in zero Linus Torvalds
2008-04-24 23:52 ` Pavel Roskin
2008-04-25 0:03 ` Linus Torvalds
2008-04-25 0:34 ` Pavel Roskin
2008-04-25 2:32 ` Josh Triplett
2008-04-25 2:29 ` Josh Triplett
2008-04-25 2:24 ` [PATCH 1/2] Fix cast instruction generation Josh Triplett
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=alpine.LFD.1.10.0804241443460.2779@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=josh@freedesktop.org \
--cc=linux-sparse@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).