qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] hw/ide/ahci.c: Fix shift left into sign bit
Date: Fri, 16 Oct 2015 16:43:24 -0400	[thread overview]
Message-ID: <5621616C.8080706@redhat.com> (raw)
In-Reply-To: <1445017739-14876-1-git-send-email-peter.maydell@linaro.org>



On 10/16/2015 01:48 PM, Peter Maydell wrote:
> Avoid undefined behaviour from shifting left into the sign bit:
> 
> hw/ide/ahci.c:551:36: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
> 
> (Unfortunately C's promotion rules mean that in the expression
> "some_uint8_t_variable << 24" the LHS gets promoted to signed
> int before shifting.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> clang's undefined sanitizer produces a lot of copies of this warning during
> 'make check'...
> 
>  hw/ide/ahci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index 796be15..21f76ed 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -548,7 +548,7 @@ static void ahci_init_d2h(AHCIDevice *ad)
>          ad->init_d2h_sent = true;
>          /* We're emulating receiving the first Reg H2D Fis from the device;
>           * Update the SIG register, but otherwise proceed as normal. */
> -        pr->sig = (ide_state->hcyl << 24) |
> +        pr->sig = ((uint32_t)ide_state->hcyl << 24) |
>              (ide_state->lcyl << 16) |
>              (ide_state->sector << 8) |
>              (ide_state->nsector & 0xFF);
> 

Reviewed-by: John Snow <jsnow@redhat.com>

Since the "patches" tool seems to still be hiccuping, do you want to
just apply this directly?

--js

  reply	other threads:[~2015-10-16 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16 17:48 [Qemu-devel] [PATCH] hw/ide/ahci.c: Fix shift left into sign bit Peter Maydell
2015-10-16 20:43 ` John Snow [this message]
2015-10-18 14:17   ` Peter Maydell

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=5621616C.8080706@redhat.com \
    --to=jsnow@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).