Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: msnyder@vmware.com, gdb-patches@sourceware.org, 	teawater@gmail.com
Subject: Re: [RFA record/replay] cast to avoid compiler warning
Date: Sun, 05 Oct 2008 11:02:00 -0000	[thread overview]
Message-ID: <jeiqs7qp92.fsf@sykes.suse.de> (raw)
In-Reply-To: <200810050954.m959s7GA011717@brahms.sibelius.xs4all.nl> (Mark 	Kettenis's message of "Sun, 5 Oct 2008 11:54:07 +0200 (CEST)")

Mark Kettenis <mark.kettenis@xs4all.nl> writes:

>> From: Andreas Schwab <schwab@suse.de>
>> Date: Sun, 05 Oct 2008 09:11:27 +0200
>> 
>> Mark Kettenis <mark.kettenis@xs4all.nl> writes:
>> 
>> >> Date: Sat, 04 Oct 2008 11:42:47 -0700
>> >> From: Michael Snyder <msnyder@vmware.com>
>> >> 
>> >> Sizeof returns size_t, which is not always the same as int.
>> >> This cast will prevent compiler warnings on some architectures
>> >> (eg. x86_64)
>> >
>> > This is wrong!  Better cast to unsigned long and print as %lu.
>> 
>> The value will always be a small number.
>
> It is still a bad example.  People may copy the idiom and uses it on
> cases where the value is not a small number.

If sizeof returns a too big number you should probably rethink your data
types.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


  reply	other threads:[~2008-10-05 11:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-04 18:45 Michael Snyder
2008-10-04 21:53 ` Mark Kettenis
2008-10-05  7:12   ` Andreas Schwab
2008-10-05  9:54     ` Mark Kettenis
2008-10-05 11:02       ` Andreas Schwab [this message]
2008-10-05 12:17   ` Mark Wielaard
2008-10-05 15:47     ` Michael Snyder
2008-10-05 16:05       ` Daniel Jacobowitz
2008-10-05 18:28         ` Michael Snyder
2008-10-05 18:40           ` Mark Kettenis
2008-10-05 19:41           ` Eli Zaretskii
2008-10-05 20:35             ` Michael Snyder
2008-10-05 21:03               ` Mark Kettenis
2008-10-06  7:29               ` teawater

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=jeiqs7qp92.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=msnyder@vmware.com \
    --cc=teawater@gmail.com \
    /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