This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Returning false when function return type is unsigned?

Tags: None
(comma "," separated)
vishalrao
Registered Member
Posts
157
Karma
0
OS
Hello,

I happened to notice this while browsing the 4.5.4 release announcement pages and looking at kdelibs/kdecore/util/kshareddatacache.cpp

Code: Select all
unsigned KSharedDataCache::totalSize() const


has added:

Code: Select all
if (lock.failed()) {
  return false;
}


Returning bool false for return type unsigned - is this a potential problem or does the code check for MAX_UINT or whatever?

See http://websvn.kde.org/branches/KDE/4.5/ ... ev=1193778

Regards,
Vishal


"Thou shalt not follow the null pointer for at its end madness and chaos lie."
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I suggest contacting the developer of the code in question or the KDE Core Development mailing list (kde-core-devel@kde.org) regarding this.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
vishalrao
Registered Member
Posts
157
Karma
0
OS
Yup, sent this in an email to the list, apparently its still in moderation queue - will post back if there's a response :) thanks


"Thou shalt not follow the null pointer for at its end madness and chaos lie."
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
This is definitely wrong, but unfortunately not triggering any build error or warning due to bool being interpretable as integer and vice versa.

In thise it is pure luck that no error happens because false is usually 0 and total size of 0 will usually not lead to any further lookup access of the cache.

Good catch!

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient