am 781bb3f7: DO NOT MERGE - fix: memory leak

* commit '781bb3f72e2706f07ee8bcc0c140201faf07c35c':
  DO NOT MERGE - fix: memory leak
diff --git a/hardware.c b/hardware.c
index 6713ea0..79d0a2f 100644
--- a/hardware.c
+++ b/hardware.c
@@ -67,9 +67,9 @@
         const char *path,
         const struct hw_module_t **pHmi)
 {
-    int status;
-    void *handle;
-    struct hw_module_t *hmi;
+    int status = -EINVAL;
+    void *handle = NULL;
+    struct hw_module_t *hmi = NULL;
 
     /*
      * load the symbols resolving undefined symbols before
@@ -145,11 +145,12 @@
 int hw_get_module_by_class(const char *class_id, const char *inst,
                            const struct hw_module_t **module)
 {
-    int i;
-    char prop[PATH_MAX];
-    char path[PATH_MAX];
-    char name[PATH_MAX];
-    char prop_name[PATH_MAX];
+    int i = 0;
+    char prop[PATH_MAX] = {0};
+    char path[PATH_MAX] = {0};
+    char name[PATH_MAX] = {0};
+    char prop_name[PATH_MAX] = {0};
+
 
     if (inst)
         snprintf(name, PATH_MAX, "%s.%s", class_id, inst);
diff --git a/modules/camera/Stream.cpp b/modules/camera/Stream.cpp
index 2db3ed2..90ad30b 100644
--- a/modules/camera/Stream.cpp
+++ b/modules/camera/Stream.cpp
@@ -227,15 +227,15 @@
 
     dprintf(fd, "Stream ID: %d (%p)\n", mId, mStream);
     dprintf(fd, "Stream Type: %s (%d)\n", typeToString(mType), mType);
-    dprintf(fd, "Width: %"PRIu32" Height: %"PRIu32"\n", mWidth, mHeight);
+    dprintf(fd, "Width: %" PRIu32 " Height: %" PRIu32 "\n", mWidth, mHeight);
     dprintf(fd, "Stream Format: %s (%d)", formatToString(mFormat), mFormat);
     // ToDo: prettyprint usage mask flags
-    dprintf(fd, "Gralloc Usage Mask: %#"PRIx32"\n", mUsage);
-    dprintf(fd, "Max Buffer Count: %"PRIu32"\n", mMaxBuffers);
+    dprintf(fd, "Gralloc Usage Mask: %#" PRIx32 "\n", mUsage);
+    dprintf(fd, "Max Buffer Count: %" PRIu32 "\n", mMaxBuffers);
     dprintf(fd, "Buffers Registered: %s\n", mRegistered ? "true" : "false");
-    dprintf(fd, "Number of Buffers: %"PRIu32"\n", mNumBuffers);
+    dprintf(fd, "Number of Buffers: %" PRIu32 "\n", mNumBuffers);
     for (uint32_t i = 0; i < mNumBuffers; i++) {
-        dprintf(fd, "Buffer %"PRIu32"/%"PRIu32": %p\n", i, mNumBuffers,
+        dprintf(fd, "Buffer %" PRIu32 "/%" PRIu32 ": %p\n", i, mNumBuffers,
                 mBuffers[i]);
     }
 }
diff --git a/modules/gralloc/mapper.cpp b/modules/gralloc/mapper.cpp
index 5a882e2..20d9841 100644
--- a/modules/gralloc/mapper.cpp
+++ b/modules/gralloc/mapper.cpp
@@ -33,14 +33,6 @@
 #include "gralloc_priv.h"
 
 
-/* desktop Linux needs a little help with gettid() */
-#if defined(ARCH_X86) && !defined(HAVE_ANDROID_OS)
-#define __KERNEL__
-# include <linux/unistd.h>
-pid_t gettid() { return syscall(__NR_gettid);}
-#undef __KERNEL__
-#endif
-
 /*****************************************************************************/
 
 static int gralloc_map(gralloc_module_t const* /*module*/,
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index 65f699b..445f69e 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -35,16 +35,10 @@
     libcutils \
     libdl \
     liblog \
-    libstlport \
     libutils \
 
-LOCAL_PRELINK_MODULE := false
 LOCAL_STRIP_MODULE := false
 
-LOCAL_C_INCLUDES := \
-    external/stlport/stlport \
-    bionic \
-
 include $(BUILD_SHARED_LIBRARY)
 
 endif # USE_SENSOR_MULTI_HAL
diff --git a/tests/camera2/Android.mk b/tests/camera2/Android.mk
index 577ba0a..1128522 100644
--- a/tests/camera2/Android.mk
+++ b/tests/camera2/Android.mk
@@ -19,7 +19,6 @@
 	liblog \
 	libutils \
 	libcutils \
-	libstlport \
 	libhardware \
 	libcamera_metadata \
 	libcameraservice \
@@ -29,21 +28,13 @@
 	libui \
 	libdl
 
-LOCAL_STATIC_LIBRARIES := \
-	libgtest
-
 LOCAL_C_INCLUDES += \
-	bionic \
-	bionic/libstdc++/include \
-	external/gtest/include \
-	external/stlport/stlport \
 	system/media/camera/include \
 	frameworks/av/include/ \
 	frameworks/av/services/camera/libcameraservice \
 	frameworks/native/include \
 
 LOCAL_CFLAGS += -Wall -Wextra
-
 LOCAL_MODULE:= camera2_test
 LOCAL_MODULE_STEM_32 := camera2_test
 LOCAL_MODULE_STEM_64 := camera2_test64
diff --git a/tests/camera2/CameraBurstTests.cpp b/tests/camera2/CameraBurstTests.cpp
index 8dcc2a2..198c0c1 100644
--- a/tests/camera2/CameraBurstTests.cpp
+++ b/tests/camera2/CameraBurstTests.cpp
@@ -49,7 +49,7 @@
 #define dout if (0) std::cout
 #endif
 
-#define WARN_UNLESS(condition) (!(condition) ? (std::cerr) : (std::ostream(NULL)) << "Warning: ")
+#define WARN_UNLESS(condition) if(!(condition)) std::cerr << "Warning: "
 #define WARN_LE(exp, act) WARN_UNLESS((exp) <= (act))
 #define WARN_LT(exp, act) WARN_UNLESS((exp) < (act))
 #define WARN_GT(exp, act) WARN_UNLESS((exp) > (act))
@@ -219,7 +219,7 @@
         CameraMetadata tmpRequest = previewRequest;
         ASSERT_EQ(OK, tmpRequest.update(ANDROID_SENSOR_EXPOSURE_TIME,
                                         &exposures[i], 1));
-        ALOGV("Submitting capture request %d with exposure %"PRId64, i,
+        ALOGV("Submitting capture request %d with exposure %" PRId64, i,
             exposures[i]);
         dout << "Capture request " << i << " exposure is "
              << (exposures[i]/1e6f) << std::endl;
@@ -231,7 +231,7 @@
     float brightnesses[CAMERA_FRAME_BURST_COUNT];
     // Get each frame (metadata) and then the buffer. Calculate brightness.
     for (int i = 0; i < CAMERA_FRAME_BURST_COUNT; ++i) {
-        ALOGV("Reading capture request %d with exposure %"PRId64, i, exposures[i]);
+        ALOGV("Reading capture request %d with exposure %" PRId64, i, exposures[i]);
         ASSERT_EQ(OK, mDevice->waitForNextFrame(CAMERA_FRAME_TIMEOUT));
         ALOGV("Reading capture request-1 %d", i);
         CaptureResult result;
@@ -618,7 +618,7 @@
                                         &durationList[i], 1));
         ASSERT_EQ(OK, tmpRequest.update(ANDROID_SENSOR_SENSITIVITY,
                                         &sensitivityList[i], 1));
-        ALOGV("Submitting capture %zu with exposure %"PRId64", frame duration %"PRId64", sensitivity %d",
+        ALOGV("Submitting capture %zu with exposure %" PRId64 ", frame duration %" PRId64 ", sensitivity %d",
                 i, expList[i], durationList[i], sensitivityList[i]);
         dout << "Capture request " << i <<
                 ": exposure is " << (expList[i]/1e6f) << " ms" <<
diff --git a/tests/camera2/CameraMultiStreamTests.cpp b/tests/camera2/CameraMultiStreamTests.cpp
index b92d8cc..df8e623 100644
--- a/tests/camera2/CameraMultiStreamTests.cpp
+++ b/tests/camera2/CameraMultiStreamTests.cpp
@@ -356,7 +356,7 @@
             ASSERT_EQ(OK, request.update(ANDROID_SENSOR_EXPOSURE_TIME, &exposures[i], 1));
             ASSERT_EQ(OK, request.update(ANDROID_SENSOR_SENSITIVITY, &sensitivities[i], 1));
             ASSERT_EQ(OK, mDevice->capture(request));
-            ALOGV("Submitting request with: id %d with exposure %"PRId64", sensitivity %d",
+            ALOGV("Submitting request with: id %d with exposure %" PRId64 ", sensitivity %d",
                     *requestIdStart, exposures[i], sensitivities[i]);
             if (CAMERA_MULTI_STREAM_DEBUGGING) {
                 request.dump(STDOUT_FILENO);
@@ -554,7 +554,7 @@
         minFrameDuration = DEFAULT_FRAME_DURATION;
     }
 
-    ALOGV("targeted minimal frame duration is: %"PRId64"ns", minFrameDuration);
+    ALOGV("targeted minimal frame duration is: %" PRId64 "ns", minFrameDuration);
 
     GetMaxSize(jpegData, jpegCount, &jpegMaxSize, &maxIdx);
     ALOGV("Found Jpeg size max idx = %d", maxIdx);
@@ -672,7 +672,7 @@
         ASSERT_EQ(OK, previewRequest.update(
                 ANDROID_SENSOR_EXPOSURE_TIME,
                 &exposures[i], 1));
-        ALOGV("Submitting preview request %zu with exposure %"PRId64,
+        ALOGV("Submitting preview request %zu with exposure %" PRId64,
                 i, exposures[i]);
 
         ASSERT_EQ(OK, mDevice->setStreamingRequest(previewRequest));
diff --git a/tests/keymaster/Android.mk b/tests/keymaster/Android.mk
index e53e67f..c420db9 100644
--- a/tests/keymaster/Android.mk
+++ b/tests/keymaster/Android.mk
@@ -6,26 +6,17 @@
 LOCAL_SRC_FILES:= \
     keymaster_test.cpp
 
-# Note that "bionic" is needed because of stlport
 LOCAL_C_INCLUDES := \
-    bionic \
-    external/gtest/include \
     external/openssl/include \
-    external/stlport/stlport
 
 LOCAL_SHARED_LIBRARIES := \
     liblog \
     libutils \
     libcrypto \
-    libstlport \
-    libhardware
-
-LOCAL_STATIC_LIBRARIES := \
-    libgtest \
-    libgtest_main
+    libhardware \
 
 LOCAL_MODULE := keymaster_test
 
 LOCAL_MODULE_TAGS := tests
 
-include $(BUILD_EXECUTABLE)
+include $(BUILD_NATIVE_TEST)