From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25888 invoked by alias); 4 Oct 2008 21:53:06 -0000 Received: (qmail 25879 invoked by uid 22791); 4 Oct 2008 21:53:05 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 04 Oct 2008 21:52:30 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id m94LqOFg005861; Sat, 4 Oct 2008 23:52:24 +0200 (CEST) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id m94LqN1R018675; Sat, 4 Oct 2008 23:52:24 +0200 (CEST) Date: Sat, 04 Oct 2008 21:53:00 -0000 Message-Id: <200810042152.m94LqN1R018675@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: msnyder@vmware.com CC: gdb-patches@sourceware.org, teawater@gmail.com In-reply-to: <48E7B927.9050207@vmware.com> (message from Michael Snyder on Sat, 04 Oct 2008 11:42:47 -0700) Subject: Re: [RFA record/replay] cast to avoid compiler warning References: <48E7B927.9050207@vmware.com> 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/msg00115.txt.bz2 > 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. There is a C99 way to do this, but not all systems implement it properly. > 2008-10-03 Michael Snyder > > * linux-record.c (record_linux_system_call): Cast sizeof to int > in printf calls, avoid compiler warnings on 64 bit hosts. > > Index: linux-record.c > =================================================================== > RCS file: /cvs/src/src/gdb/Attic/linux-record.c,v > retrieving revision 1.1.2.4 > diff -u -p -r1.1.2.4 linux-record.c > --- linux-record.c 7 Sep 2008 01:40:43 -0000 1.1.2.4 > +++ linux-record.c 3 Oct 2008 23:04:20 -0000 > @@ -597,7 +597,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (sel)); > + paddr_nz (tmpu32), (int) sizeof (sel)); > return (-1); > } > if (record_arch_list_add_mem (sel.inp, tdep->size_fd_set)) > @@ -749,7 +749,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (record_arch_list_add_mem (a[1], tdep->size_sockaddr)) > @@ -775,7 +775,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (record_arch_list_add_mem (a[3], tdep->size_int)) > @@ -799,7 +799,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (a[2]) > @@ -809,7 +809,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (a[2]), sizeof (a[2])); > + paddr_nz (a[2]), (int) sizeof (a[2])); > return (-1); > } > if (record_arch_list_add_mem (a[1], a[2])) > @@ -831,7 +831,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (a[2]) > @@ -841,7 +841,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (a[2]), sizeof (a[2])); > + paddr_nz (a[2]), (int) sizeof (a[2])); > return (-1); > } > if (record_arch_list_add_mem (a[1], a[2])) > @@ -876,7 +876,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (a[4]) > @@ -886,7 +886,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (a[4]), sizeof (av)); > + paddr_nz (a[4]), (int) sizeof (av)); > return (-1); > } > if (record_arch_list_add_mem (a[3], av)) > @@ -930,7 +930,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (tmpu32), sizeof (a)); > + paddr_nz (tmpu32), (int) sizeof (a)); > return (-1); > } > if (record_arch_list_add_mem (a[1], tdep->size_msghdr)) > @@ -944,7 +944,7 @@ record_linux_system_call (int num, linux > { > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > - paddr_nz (a[1]), sizeof (rec)); > + paddr_nz (a[1]), (int) sizeof (rec)); > return (-1); > } > if (record_arch_list_add_mem > @@ -968,7 +968,7 @@ record_linux_system_call (int num, linux > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > paddr_nz (rec.msg_iov), > - sizeof (iov)); > + (int) sizeof (iov)); > return (-1); > } > if (record_arch_list_add_mem > @@ -1336,7 +1336,7 @@ record_linux_system_call (int num, linux > fprintf_unfiltered (gdb_stdlog, > "Record: read memory addr = 0x%s len = %d error.\n", > paddr_nz (vec), > - sizeof (struct record_iovec)); > + (int) sizeof (struct record_iovec)); > return (-1); > } > if (record_arch_list_add_mem (iov.iov_base, iov.iov_len))