From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27341 invoked by alias); 12 May 2005 15:08:12 -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 27305 invoked from network); 12 May 2005 15:08:05 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 12 May 2005 15:08:05 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50) id 1DWFIC-0000V4-OK; Thu, 12 May 2005 11:08:04 -0400 Date: Thu, 12 May 2005 15:33:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: gcc-patches@gcc.gnu.org, gdb-patches@sources.redhat.com Subject: Re: [RFA] Eliminate warnings about snprintf declaration Message-ID: <20050512150804.GA1808@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , gcc-patches@gcc.gnu.org, gdb-patches@sources.redhat.com References: <01c4c990$Blat.v2.2.2$887ec720@zahav.net.il> <41994B9D.9080809@gnu.org> <01c55702$Blat.v2.4$d4764900@zahav.net.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c55702$Blat.v2.4$d4764900@zahav.net.il> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-05/txt/msg00286.txt.bz2 On Thu, May 12, 2005 at 05:55:49PM +0300, Eli Zaretskii wrote: > Okay, here're the patches to add snprintf and vsnprintf to the list of > functions whose declarations are checked at configure time. Comments? I recommend copying the libiberty maintainers directly to get their attention. Also, this isn't useful: > @@ -282,7 +282,7 @@ > sysconf times sbrk gettimeofday ffs snprintf vsnprintf \ > pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl wait3 wait4 \ > realpath canonicalize_file_name __fsetlocking) > - AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf]) > + AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf]) > AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.]) > AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.]) > AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.]) > @@ -518,7 +518,7 @@ > [AC_MSG_RESULT([no])]) > > AC_CHECK_FUNCS($checkfuncs) > - AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf]) > + AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf]) > libiberty_NEED_DECLARATION(canonicalize_file_name) > fi That will only affect libiberty.h when building libiberty; it won't affect the users of libiberty. > +#if !HAVE_DECL_SNPRINTF > +# ifdef HAVE_DECL_SNPRINTF > + extern int snprintf (); > +# else > +/* Like sprintf but prints at most N characters. */ > + extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3; > +# endif > +#endif > + > +#if !HAVE_DECL_VSNPRINTF > +# ifdef HAVE_DECL_VSNPRINTF > + extern int vsnprintf (); > +# else > +/* Like vsprintf but prints at most N characters. */ > + extern int vsnprintf (char *, size_t, const char *, va_list); > +# endif > +#endif > + I believe you've got this logic reversed. You also don't want or need the non-prototype - it's only needed for basename because basename returns a pointer. How about this, based on the later examples in the file: #if defined (HAVE_DECL_SPRINTF) && !HAVE_DECL_SNPRINTF /* Like sprintf but prints at most N characters. */ extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3; #endif #if defined (HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF /* Like vsprintf but prints at most N characters. */ extern int vsnprintf (char *, size_t, const char *, va_list); #endif -- Daniel Jacobowitz CodeSourcery, LLC