From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23042 invoked by alias); 5 Oct 2008 11:02:45 -0000 Received: (qmail 23033 invoked by uid 22791); 5 Oct 2008 11:02:45 -0000 X-Spam-Check-By: sourceware.org Received: from ns.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 05 Oct 2008 11:02:05 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 69915417D0; Sun, 5 Oct 2008 13:02:02 +0200 (CEST) From: Andreas Schwab To: Mark Kettenis Cc: msnyder@vmware.com, gdb-patches@sourceware.org, teawater@gmail.com Subject: Re: [RFA record/replay] cast to avoid compiler warning References: <48E7B927.9050207@vmware.com> <200810042152.m94LqN1R018675@brahms.sibelius.xs4all.nl> <200810050954.m959s7GA011717@brahms.sibelius.xs4all.nl> X-Yow: Is a tattoo real, like a curb or a battleship? Or are we suffering in Safeway? Date: Sun, 05 Oct 2008 11:02:00 -0000 In-Reply-To: <200810050954.m959s7GA011717@brahms.sibelius.xs4all.nl> (Mark Kettenis's message of "Sun, 5 Oct 2008 11:54:07 +0200 (CEST)") Message-ID: User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00126.txt.bz2 Mark Kettenis writes: >> From: Andreas Schwab >> Date: Sun, 05 Oct 2008 09:11:27 +0200 >> >> Mark Kettenis writes: >> >> >> Date: Sat, 04 Oct 2008 11:42:47 -0700 >> >> From: Michael Snyder >> >> >> >> 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."