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

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to