[Libreoffice-commits] -Werror=format-security
Stephan Bergmann
sbergman at redhat.com
Tue Aug 7 04:53:25 PDT 2012
On 08/07/2012 01:28 PM, Michael Meeks wrote:
> On Tue, 2012-08-07 at 09:23 +0200, Stephan Bergmann wrote:
>> Use SAL_INFO/SAL_WARN for permanent warning code (see
>> <http://wiki.documentfoundation.org/Development#Assertions_and_Logging>), and
>> use SAL_DEBUG for temporary debug output (that the LO git commit hooks
>> will prevent from accidentally becoming permanent).
>
> I always use fprintf and never these other things. I can never remember
> how to make SAL_WARN / SAL_INFO / SAL_DEBUG to actually output something
> and grok their prefix behaviour etc.; on the occasions I've tried adding
> one of those I inevitably have to do 2x compilation loops before giving
> up and using fprintf - IIRC you have to use some different compile
> flags, and/or set some also-difficult-to-remember environment variable
> to some value - right ?
No, not for SAL_DEBUG. (SAL_WARN requires an --enable-dbgutil build,
but which developer doesn't do that, anyway? SAL_INFO requires
SAL_LOG=+WARN+INFO, but that's on purpose, to keep the default amount of
output manageable.)
> fprintf (stderr,"foo\n");
>
> goes directly, atomically to your terminal pausing the app until it's
> out and it -just-works- (TM) ;-)
As does SAL_DEBUG (modulo the "pausing the app," which fprintf doesn't
do either, at least not in a multithreaded process), with the added
benefit that it is way simpler to output an OUString s with:
fprintf(stderr, "%s", OUStringToOString(s,
RTL_TEXTENCODING_UTF8).getStr());
vs. just
SAL_DEBUG(s);
Stephan
More information about the LibreOffice
mailing list