summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2014-09-08 18:59:09 -0700
committerDan Albert <danalbert@google.com>2014-09-16 17:52:06 -0700
commit1474f8864faafebc92ff79959bb5c698bd29b704 (patch)
tree7e60cb941b744698bb8bf40e81f50ff14c46e987
parent86aeb9ef154d7aa63c58cbe5be62e5b61d6ae5fa (diff)
downloadnative-1474f8864faafebc92ff79959bb5c698bd29b704.tar.gz
Don't check if this == NULL.
Entering a method with this == NULL is undefined behavior. Clang whines about this. Change-Id: Ibde628395ca10dfef0d2f59e81280576f104b83c
-rw-r--r--libs/binder/IInterface.cpp4
-rw-r--r--libs/gui/LayerState.cpp2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp6
3 files changed, 8 insertions, 4 deletions
diff --git a/libs/binder/IInterface.cpp b/libs/binder/IInterface.cpp
index 29acf5ddd1..99a9ffeea2 100644
--- a/libs/binder/IInterface.cpp
+++ b/libs/binder/IInterface.cpp
@@ -29,12 +29,12 @@ IInterface::~IInterface() {
sp<IBinder> IInterface::asBinder()
{
- return this ? onAsBinder() : NULL;
+ return onAsBinder();
}
sp<const IBinder> IInterface::asBinder() const
{
- return this ? const_cast<IInterface*>(this)->onAsBinder() : NULL;
+ return const_cast<IInterface*>(this)->onAsBinder();
}
// ---------------------------------------------------------------------------
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index acdbd77161..498953f2ed 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -75,7 +75,7 @@ status_t ComposerState::read(const Parcel& input) {
status_t DisplayState::write(Parcel& output) const {
output.writeStrongBinder(token);
- output.writeStrongBinder(surface->asBinder());
+ output.writeStrongBinder(surface != NULL ? surface->asBinder() : NULL);
output.writeInt32(what);
output.writeInt32(layerStack);
output.writeInt32(orientation);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 943ed02216..512ec05724 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1110,7 +1110,11 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
// this display is in both lists. see if something changed.
const DisplayDeviceState& state(curr[j]);
const wp<IBinder>& display(curr.keyAt(j));
- if (state.surface->asBinder() != draw[i].surface->asBinder()) {
+ const sp<IBinder> state_binder =
+ state.surface != NULL ? state.surface->asBinder() : NULL;
+ const sp<IBinder> draw_binder =
+ draw[i].surface != NULL ? draw[i].surface->asBinder() : NULL;
+ if (state_binder != draw_binder) {
// changing the surface is like destroying and
// recreating the DisplayDevice, so we just remove it
// from the drawing state, so that it get re-added