Potential issue in kshareddatacache.cpp checkin revision 1193778

Michael Pyne mpyne at kde.org
Sat Dec 4 00:18:12 GMT 2010


On Friday, December 03, 2010 00:07:06 Vishal Rao wrote:
> Hello,
> 
> Sorry if this is spam/silly.
> 
> I happened to notice this while browsing the 4.5.4 release announcement
> pages:
> 
> unsigned KSharedDataCache::totalSize() const
> 
> has added:
> 
> if (lock.failed()) {
>   return false;
> }
> 
> Returning bool false for return type unsigned - is this a potential
> problem or do you check for MAX_UINT or whatever?

Hmm, this is what I'd call an "answer by accident" at work. (unsigned)0 is the 
proper return value here as if the lock fails it's best to think of the cache 
as unavailable (i.e. zero-sized).

false does convert automatically to zero (indeed, the old code even compiled 
without a warning for that link on my system, even now when I double-checked). 
But, you're right that it's confusing, and I was not trying to rely on the 
conversion from bool to unsigned. I've fixed the code in 4.5 for posterity's 
sake (there shouldn't even be a binary change). trunk was already fixed.

Thanks for the report, and keep that keen eye open!

Regards,
 - Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20101203/fdb0b776/attachment.sig>


More information about the kde-core-devel mailing list