platform_system_core/libutils/include/utils
Hans Boehm 6e75ad6e13 Revert "Revert "Fix wp and sp comparison bugs""
Fix wp and sp comparison bugs

Make clear() actually clear wp m_refs, so that nulls compare equal.

Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.

Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.

Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.

Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.

Add comparison tests.

This reverts commit a2a2ad8057.

The original code, and my original CL, both failed to initialize m_refs
in various wp<> constructors. This now became more important, since
comparisons now rely more on m_refs. However I believe it was always
a bug, since some comparisons always relied on m_refs.

Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
This reverts commit a2a2ad8057.

Reason for revert: Reapply after constructor fixes.

Change-Id: I2c8917416a2306e36d2b6bb7b397f653020e5688
2019-03-13 13:26:35 -07:00
..
AndroidThreads.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
Atomic.h Usage suggestions. 2017-12-19 01:16:00 +00:00
BitSet.h Usage suggestions. 2017-12-19 01:16:00 +00:00
ByteOrder.h
CallStack.h CallStack: include prefix/tag when unlinked 2019-01-03 10:17:07 -08:00
Compat.h libziparchive: fix mac os breakage 2017-03-23 12:02:09 -07:00
Condition.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
Debug.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
Endian.h
Errors.h "utils/Errors.h": include <stdint.h> for int32_t. 2018-10-16 13:17:15 -07:00
FastStrcmp.h logd: ASAN cleansing 2017-03-27 13:32:57 -07:00
FileMap.h Add noexcept to move constructors and assignment operators. 2018-10-05 16:43:47 +00:00
Flattenable.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
Functor.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
JenkinsHash.h
KeyedVector.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
LightRefBase.h Remove extra semicolon at end of namespace 2018-04-10 22:10:54 +00:00
List.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
Log.h Remove ALOGD_IF_SLOW 2017-07-14 19:51:57 +00:00
Looper.h libutils: switch Looper's fds to unique_fd. 2018-07-18 18:12:12 -07:00
LruCache.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
misc.h Remove extra semicolon at end of namespace 2018-04-10 22:10:54 +00:00
Mutex.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
NativeHandle.h clean-up libutils includes 2017-03-03 14:47:47 -08:00
Printer.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
ProcessCallStack.h [libutils] Modernize codebase by replacing NULL with nullptr 2018-07-16 18:11:34 -07:00
PropertyMap.h
RefBase.h Revert "Revert "Fix wp and sp comparison bugs"" 2019-03-13 13:26:35 -07:00
RWLock.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
Singleton.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
SortedVector.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
StopWatch.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
String8.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00
String16.h Remove extra semicolon at end of namespace 2018-04-10 22:10:54 +00:00
StrongPointer.h Revert "Revert "Fix wp and sp comparison bugs"" 2019-03-13 13:26:35 -07:00
SystemClock.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
Thread.h Suppress lint warnings on google-default-arguments 2018-10-29 23:06:23 +09:00
ThreadDefs.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
threads.h
Timers.h
Tokenizer.h Move system/core/ off NO_ERROR. 2018-10-08 11:15:52 -07:00
Trace.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
TypeHelpers.h Remove extra semicolon at end of namespace 2018-04-10 22:10:54 +00:00
Unicode.h Remove dead code. 2019-01-24 13:07:18 -08:00
Vector.h Remove more semicolons at the end of namespaces 2018-04-11 23:14:13 -07:00
VectorImpl.h Modernize codebase by replacing NULL with nullptr 2018-07-13 15:28:59 -07:00