qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thayne Harbaugh <thayne@c2.net>
To: Paul Brook <paul@codesourcery.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target_posix_types.h
Date: Wed, 14 Nov 2007 14:19:27 -0700	[thread overview]
Message-ID: <1195075167.918.103.camel@phantasm.home.enterpriseandprosperity.com> (raw)
In-Reply-To: <200711142039.38427.paul@codesourcery.com>


On Wed, 2007-11-14 at 20:39 +0000, Paul Brook wrote:
> > This means that time_t had to be tracked down on varying architectures
> > to find the size and there was an assumption made that time_t is 32 bits
> > - which isn't true for all targets.  The next problem is that if the
> > target is 32 bits but the host is 64 bits then there's a sign extension
> > problem because (time_t)-1 is used for an error condition.  If you don't
> > correctly assign assign the 32-bit -1 to a 64-bit type then, rather than
> > -1, you get 4294967295.
> 
> Is there any guarantee that time_t is a signed type? The fact that you said 
> (time_t)-1 suggests it could be an unsigned type. If time_t is an unsigned 
> type, then casting to a wider value is still wrong. You have to special-case 
> the error condition.
> 
> In the case of time_t this only becomes relevant after 32-bit time_t wrap in 
> approx. 99 years time, but I'd expect there are cases where it matters.

time_t is only one example.  There are similar problems with the
handling of struct target_iovec.  There are still other places with
similar problems.

Yes, special casing can work.  There's the possible problem of value
truncation when moving between 32 and 64 bits.

  parent reply	other threads:[~2007-11-14 21:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-14 15:59 [Qemu-devel] [PATCH] target_posix_types.h Thayne Harbaugh
2007-11-14 16:03 ` [Qemu-devel] Re: [PATCH] tget/tput deprecation Thayne Harbaugh
2007-11-14 16:08   ` Thayne Harbaugh
2007-11-14 18:21   ` Thayne Harbaugh
2007-11-14 19:02     ` Thayne Harbaugh
2007-11-16  4:16   ` Thayne Harbaugh
2007-11-14 16:25 ` [Qemu-devel] [PATCH] target_posix_types.h Jocelyn Mayer
2007-11-14 17:36   ` Thiemo Seufer
2007-11-14 17:54     ` Jocelyn Mayer
2007-11-14 18:20   ` Thayne Harbaugh
2007-11-14 18:32 ` Fabrice Bellard
2007-11-14 18:43   ` Thayne Harbaugh
2007-11-14 19:14     ` Fabrice Bellard
2007-11-14 19:53       ` Thayne Harbaugh
2007-11-14 20:39         ` Paul Brook
2007-11-14 21:06           ` Warner Losh
2007-11-14 21:25             ` Thayne Harbaugh
2007-11-14 21:19           ` Thayne Harbaugh [this message]
2007-11-14 21:37             ` Paul Brook
2007-11-14 19:56       ` Thayne Harbaugh

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=1195075167.918.103.camel@phantasm.home.enterpriseandprosperity.com \
    --to=thayne@c2.net \
    --cc=paul@codesourcery.com \
    --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).