From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5590 invoked by alias); 8 Feb 2002 23:17:09 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5497 invoked from network); 8 Feb 2002 23:17:05 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 8 Feb 2002 23:17:05 -0000 Received: from there (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with SMTP id PAA21913; Fri, 8 Feb 2002 15:16:57 -0800 (PST) Message-Id: <200202082316.PAA21913@cygnus.com> Content-Type: text/plain; charset="iso-8859-1" From: "Martin M. Hunt" Organization: Red Hat Inc To: Christopher Faylor , gdb-patches@sources.redhat.com Subject: Re: [RFA] win32-nat printf and sprintf removal Date: Fri, 08 Feb 2002 15:17:00 -0000 X-Mailer: KMail [version 1.3.2] References: <4.2.0.58.20020208182442.00ad05e0@ics.u-strasbg.fr> <20020208230440.GA8444@redhat.com> In-Reply-To: <20020208230440.GA8444@redhat.com> Cc: muller@cerbere.u-strasbg.fr MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SW-Source: 2002-02/txt/msg00256.txt.bz2 Also, you must call free() after calls to xvasprintf(). -- Martin Hunt GDB Engineer Red Hat, Inc. On Friday 08 February 2002 03:04 pm, Christopher Faylor wrote: > On Fri, Feb 08, 2002 at 06:29:11PM +0100, Pierre Muller wrote: > >I replaced printf by printf_unfiltered (or printf_filtered > >when there where other printf_filtered in the same function) > >and sprintf by xasprintf in win32-nat.c source. > > Since I wasn't aware of xasprintf, I checked it out. It takes > a different first argument than sprintf. xasprintf takes a char **. > sprintf takes a char *. > > Didn't you notice an increased number of warnings with this patch? > I don't think you changed these calls correctly. > > cgf > > >Does this enter in the obvious fix rules or not? > > > >2002-02-08 Pierre Muller > > > > * win32-nat.c : Remove use of printf and sprintf functions. > > > > > >Index: win32-nat.c > >=================================================================== > >RCS file: /cvs/src/src/gdb/win32-nat.c,v > >retrieving revision 1.47 > >diff -u -p -r1.47 win32-nat.c > >--- win32-nat.c 2002/02/06 09:27:29 1.47 > >+++ win32-nat.c 2002/02/08 17:24:56 > >@@ -86,10 +86,10 @@ static int debug_registers_used = 0; > > #define CYGWIN_SIGNAL_STRING "cygwin: signal" > > > > #define CHECK(x) check (x, __FILE__,__LINE__) > >-#define DEBUG_EXEC(x) if (debug_exec) printf x > >-#define DEBUG_EVENTS(x) if (debug_events) printf x > >-#define DEBUG_MEM(x) if (debug_memory) printf x > >-#define DEBUG_EXCEPT(x) if (debug_exceptions) printf x > >+#define DEBUG_EXEC(x) if (debug_exec) printf_unfiltered x > >+#define DEBUG_EVENTS(x) if (debug_events) printf_unfiltered x > >+#define DEBUG_MEM(x) if (debug_memory) printf_unfiltered x > >+#define DEBUG_EXCEPT(x) if (debug_exceptions) printf_unfiltered x > > > > /* Forward declaration */ > > extern struct target_ops child_ops; > >@@ -785,7 +785,7 @@ info_dll_command (char *ignore, int from > > if (!so->next) > > return; > > > >- printf ("%*s Load Address\n", -max_dll_name_len, "DLL Name"); > >+ printf_filtered ("%*s Load Address\n", -max_dll_name_len, "DLL Name"); > > while ((so = so->next) != NULL) > > printf_filtered ("%*s %08lx\n", -max_dll_name_len, so->name, > > so->load_addr); > > > >@@ -826,7 +826,7 @@ handle_output_debug_string (struct targe > > } > > > > #define DEBUG_EXCEPTION_SIMPLE(x) if (debug_exceptions) \ > >- printf ("gdb: Target exception %s at 0x%08lx\n", x, \ > >+ printf_unfiltered ("gdb: Target exception %s at 0x%08lx\n", x, \ > > (DWORD) current_event.u.Exception.ExceptionRecord.ExceptionAddress) > > > > static int > >@@ -1763,9 +1763,9 @@ cygwin_pid_to_str (ptid_t ptid) > > int pid = PIDGET (ptid); > > > > if ((DWORD) pid == current_event.dwProcessId) > >- sprintf (buf, "process %d", pid); > >+ xaprintf (buf, "process %d", pid); > > else > >- sprintf (buf, "thread %ld.0x%x", current_event.dwProcessId, pid); > >+ xasprintf (buf, "thread %ld.0x%x", current_event.dwProcessId, pid); > > return buf; > > } > > > >@@ -2009,7 +2009,7 @@ _initialize_check_for_gdb_ini (void) > > { > > int len = strlen (oldini); > > char *newini = alloca (len + 1); > >- sprintf (newini, "%.*s.gdbinit", > >+ xasprintf (newini, "%.*s.gdbinit", > > (int) (len - (sizeof ("gdb.ini") - 1)), oldini); > > warning ("obsolete '%s' found. Rename to '%s'.", oldini, newini); > > } > > > > > > > >Pierre Muller > >Institut Charles Sadron > >6,rue Boussingault > >F 67083 STRASBOURG CEDEX (France) > >mailto:muller@ics.u-strasbg.fr > >Phone : (33)-3-88-41-40-07 Fax : (33)-3-88-41-40-99