The patch compiles smooth with gcc when you modify it as follows: --- common\rfb\LogWriter.h (broken) +++ common\rfb\LogWriter.h (fixed) @@ -35 +35 @@ - void name(const char* fmt, any, ...) { \ + void name(any* fmt, ...) { \ @@ -63 +63 @@ - void write(int level, const char* format, any, ...) { + void write(int level, any* format, ...) {
Alternatively, you could fix the couple of existing catch blocks which pass the e.str() in place of the format string, and probably even __attribute__ LogWriter methods in such way that gcc warns about possible wrong usages that might creep back into the code base as awareness of the issue fades. Regards, Jochen ----- Original Message ----- From: "Adam Tkac" <at...@redhat.com> To: "Jochen Neubeck" <j.tu...@arcor.de> Cc: <tigervnc-devel@lists.sourceforge.net> Sent: Tuesday, May 03, 2011 1:29 PM Subject: Re: [Tigervnc-devel] [PATCH] Help avoid improper use of LogWriter output methods >I mobilized all my programming skills but I wasn't able to get rid of > warnings written below so I must reject this change. > > In long term the only way seems to use C++ I/O operators in LogWriter > class which can safely deal with your example code. > > I checked source code and it seems there aren't wrong usages of > LogWriter method, please correct me if I'm wrong. > > Regards, Adam > > On 04/29/2011 02:16 PM, Adam Tkac wrote: >> Sorry for late response, this mail got lost in my queue. >> >> You are right that current LogWriter implementation will have problems >> with your example. However your patch causes following compilation >> warnings: >> >> In file included from CConnection.cxx:28:0: >> ../../common/rfb/LogWriter.h: In member function 'void >> rfb::LogWriter::error(const char*, any, ...) [with any = int]': >> ../../common/rfb/LogWriter.h:92:5: warning: second parameter of >> 'va_start' not last named argument >> >> I'm trying to find a way how to get rid of this warning but I haven't >> been successful, yet. >> >> Regards, Adam >> >> On 02/11/2011 12:14 AM, Jochen Neubeck wrote: >>> Consider the following example: >>> >>> try { >>> static const char silly_example[] = "just a %silly% example"; >>> char expanded[100]; >>> if (!ExpandEnvironmentStrings(silly_example, expanded, sizeof >>> expanded)) >>> throw rdr::Exception("failed to expand %s", silly_example); >>> } catch (rdr::exception &e) { >>> vlog.error(e.str()); >>> } >>> >>> The %s from %silly% directs vlog.error() to substitute a non-existing >>> char * argument, which might cause odd things including crash. >>> >>> Regards, >>> Jochen >>> >> >> ------------------------------------------------------------------------------ >> WhatsUp Gold - Download Free Network Management Software >> The most intuitive, comprehensive, and cost-effective network >> management toolset available today. Delivers lowest initial >> acquisition cost and overall TCO of any competing solution. >> http://p.sf.net/sfu/whatsupgold-sd >> _______________________________________________ >> Tigervnc-devel mailing list >> Tigervnc-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/tigervnc-devel > ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay _______________________________________________ Tigervnc-devel mailing list Tigervnc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-devel