qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Peter Maydell" <peter.maydell@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/2] bswap.h: Fix ldl_he_p() signedness
Date: Fri, 25 May 2018 16:06:35 +0200	[thread overview]
Message-ID: <9b685c79-fefb-e73f-f0ed-ee9c0c97ca11@redhat.com> (raw)
In-Reply-To: <20180423162523.6392-2-f4bug@amsat.org>

On 23/04/2018 18:25, Philippe Mathieu-Daudé wrote:
> As per the "Load and Store APIs" documentation (docs/devel/loads-stores.rst),
> "No signed load operations are provided."
> Update lduw_he_p() to return as unsigned.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

This is ldl_he_p, not lduw_he_p.

However, this patch should not be necessary; using uint16_t is needed
for shorts because they implicitly extend to int, so a "short -0x1234"
becomes 0xffff1234 when assigned to uint32_t.  Instead, an int can be
assigned to a uint32_t (which is the type of fdt32_to_cpu's argument)
with no change in value.

Paolo

> ---
>  include/qemu/bswap.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
> index 3f28f661b1..613978f838 100644
> --- a/include/qemu/bswap.h
> +++ b/include/qemu/bswap.h
> @@ -330,9 +330,9 @@ static inline void stw_he_p(void *ptr, uint16_t v)
>      memcpy(ptr, &v, sizeof(v));
>  }
>  
> -static inline int ldl_he_p(const void *ptr)
> +static inline uint32_t ldl_he_p(const void *ptr)
>  {
> -    int32_t r;
> +    uint32_t r;
>      memcpy(&r, ptr, sizeof(r));
>      return r;
>  }
> 

  parent reply	other threads:[~2018-05-25 14:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 16:25 [Qemu-devel] [PATCH v3 0/2] loader: Fix misaligned member access Philippe Mathieu-Daudé
2018-04-23 16:25 ` [Qemu-devel] [PATCH v3 1/2] bswap.h: Fix ldl_he_p() signedness Philippe Mathieu-Daudé
2018-04-23 16:56   ` Peter Maydell
2018-04-24 22:18     ` Philippe Mathieu-Daudé
2018-04-23 17:32   ` Richard Henderson
2018-05-25 14:06   ` Paolo Bonzini [this message]
2018-04-23 16:25 ` [Qemu-devel] [PATCH v3 2/2] loader: Fix 64-bit misaligned member access Philippe Mathieu-Daudé
2018-04-23 17:34   ` Richard Henderson
2018-04-23 17:38     ` Philippe Mathieu-Daudé
2018-05-25 14:07   ` Paolo Bonzini

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=9b685c79-fefb-e73f-f0ed-ee9c0c97ca11@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=f4bug@amsat.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).