On Friday 01 of April 2011, Michael Meeks wrote:
Hi guys,
I see quite a staggering number of these things around the codebase:
$ g grep '== sal_True' | wc -l
744
and the (less dangerous IMHO) '== sal_False' construct has ~400 (what
positive people we are ;-)
if( m_pDataContainer->IsModuleInstalled( E_SWRITER ) == sal_True )
if( IsModified() == sal_True )
if( m_bOwner == sal_True )
etc. etc.
sal_True is -1
What makes you think so (besides possibly today's date, but then the rest of
your mail looks ok) ?
/ure/sal/inc/sal/types.h : # define sal_True ((sal_Bool)1)
printf("%d\n", sal_True);
1
- which is great for unsigned bit fields and all that -
Not really important, but you lost me there.
but - well, I am certain there are a whole host of creative errors
around where a supposedly boolean value is neither 0 nor -1, and of
course these create serious trouble were we to convert to using plain
'bool' more widely.
Actually, converting to bool would have probably avoided any such possible
trouble, as converting to bool converts any non-zero to true (which has the
value of 1 with gcc, although I'm not quite sure the spec mandates this). So
if in those examples above the return type and the type of the variable were
bool, this just works (unlike sal_Bool). With bool it can break only if
somebody does something prehistoric like 'int Buffer::isNonEmpty() const {
return size; }'.
--
Lubos Lunak
l.lunak@suse.cz
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.