From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1791 invoked by alias); 28 Feb 2013 08:54:51 -0000 Received: (qmail 1748 invoked by uid 22791); 28 Feb 2013 08:54:36 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Thu, 28 Feb 2013 08:54:29 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id CD77C520243; Thu, 28 Feb 2013 09:54:26 +0100 (CET) Date: Thu, 28 Feb 2013 09:19:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [patch] gdbserver/win32-low.c: Fix printf-like formatting (was Re: [patch]: Replace stryoul call to fetch address) Message-ID: <20130228085426.GA30108@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <20130227164419.GA16975@calimero.vinschen.de> <512E404E.6070504@redhat.com> <20130227183805.GA30418@calimero.vinschen.de> <512E5B26.7050104@redhat.com> <20130227194235.GB30418@calimero.vinschen.de> <20130227195013.GC30418@calimero.vinschen.de> <83obf5wlon.fsf@gnu.org> <20130227202902.GB14591@calimero.vinschen.de> <83mwupwjr6.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <83mwupwjr6.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2013-02/txt/msg00729.txt.bz2 On Feb 27 23:05, Eli Zaretskii wrote: > > Date: Wed, 27 Feb 2013 21:29:02 +0100 > > From: Corinna Vinschen > > > > If you look closely, I didn't add the unsigned casts. > > Not in the part I cited (sorry), but elsewhere you did: > > > @@ -1317,10 +1317,10 @@ handle_exception (struct target_waitstat > > ourstatus->kind = TARGET_WAITKIND_SPURIOUS; > > return; > > } > > - OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at 0x%s", > > - current_event.u.Exception.ExceptionRecord.ExceptionCode, > > - phex_nz ((uintptr_t) current_event.u.Exception.ExceptionRecord. > > - ExceptionAddress, sizeof (uintptr_t)))); > > + OUTMSG2 (("gdbserver: unknown target exception 0x%08x at 0x%s", > > + (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionCode, > > + phex_nz ((uintptr_t) current_event.u.Exception.ExceptionRecord. > > + ExceptionAddress, sizeof (uintptr_t)))); > [...] > > @@ -1561,10 +1561,10 @@ get_child_debug_event (struct target_wai > > > > default: > > OUTMSG2 (("gdbserver: kernel event unknown " > > - "for pid=%d tid=%x code=%ld\n", > > + "for pid=%u tid=%x code=%x\n", > > (unsigned) current_event.dwProcessId, > > (unsigned) current_event.dwThreadId, > > - current_event.dwDebugEventCode)); > > + (unsigned) current_event.dwDebugEventCode)); > > break; > > } > > Are those mistakes? No. > > The unsigned casts are already widely used throughout the file. > > So why are they there? DWORD is unsigned long on 32 bit Windows, right? So it is on 64 bit Windows as well, since Windows is a LLP64 system. 64 bit Cygwin OTOH will be LP64, so in 64 bit Cygwin's case, DWORD is defined as unsigned int for hopefully obvious reasons. So, using %ld with no cast will result in a GCC warning on 64 bit Cygwin, because DWORD is not long. %d would be right for 64 bit Cygwin, but might result in a warning on 32 bit Mingw/Cygwin and 64 bit Mingw. So, whatever they did before, the casts actually do serve a purpose. They cast the variably defined DWORD-typed value to a well known int type with a well defined printf format specifier. Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat