diff --git a/libutils/BlobCache.cpp b/libutils/BlobCache.cpp index 126995b8c..b0fdd44b5 100644 --- a/libutils/BlobCache.cpp +++ b/libutils/BlobCache.cpp @@ -17,13 +17,10 @@ #define LOG_TAG "BlobCache" //#define LOG_NDEBUG 0 -#include -#include -#include - #include -#include -#include +#include + +#include #include diff --git a/libutils/CallStack.cpp b/libutils/CallStack.cpp index 699da7469..bd6015e79 100644 --- a/libutils/CallStack.cpp +++ b/libutils/CallStack.cpp @@ -16,9 +16,10 @@ #define LOG_TAG "CallStack" +#include + #include -#include #include #include #include diff --git a/libutils/LinearTransform.cpp b/libutils/LinearTransform.cpp index 138ce8be7..d2e91a868 100644 --- a/libutils/LinearTransform.cpp +++ b/libutils/LinearTransform.cpp @@ -16,10 +16,9 @@ #define __STDC_LIMIT_MACROS -#include -#include - #include +#include + // disable sanitize as these functions may intentionally overflow (see comments below). // the ifdef can be removed when host builds use clang. diff --git a/libutils/Log.cpp b/libutils/Log.cpp index bffb56eda..2c1fb86b9 100644 --- a/libutils/Log.cpp +++ b/libutils/Log.cpp @@ -21,14 +21,14 @@ namespace android { -LogIfSlow::LogIfSlow(const char* tag, android_LogPriority priority, - int timeoutMillis, const char* message) : - mTag(tag), mPriority(priority), mTimeoutMillis(timeoutMillis), mMessage(message), - mStart(systemTime(SYSTEM_TIME_BOOTTIME)) { +LogIfSlow::LogIfSlow( + const char* tag, android_LogPriority priority, int timeoutMillis, const char* message) + : mTag(tag), mPriority(priority), mTimeoutMillis(timeoutMillis), mMessage(message), + mStart(systemTime(SYSTEM_TIME_BOOTTIME)) { } LogIfSlow::~LogIfSlow() { - int durationMillis = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_BOOTTIME) - mStart); + int durationMillis = (int)nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_BOOTTIME) - mStart); if (durationMillis > mTimeoutMillis) { LOG_PRI(mPriority, mTag, "%s: %dms", mMessage, durationMillis); } diff --git a/libutils/Looper.cpp b/libutils/Looper.cpp index 84bc028f8..6c57b2e54 100644 --- a/libutils/Looper.cpp +++ b/libutils/Looper.cpp @@ -13,17 +13,8 @@ // Debugs callback registration and invocation. #define DEBUG_CALLBACKS 0 -#include -#include -#include -#include -#include -#include -#include - -#include #include -#include +#include namespace android { diff --git a/libutils/NativeHandle.cpp b/libutils/NativeHandle.cpp index e4daca7ff..97d06b8bd 100644 --- a/libutils/NativeHandle.cpp +++ b/libutils/NativeHandle.cpp @@ -19,14 +19,14 @@ namespace android { -sp NativeHandle::create( - native_handle_t* handle, bool ownsHandle) { +sp NativeHandle::create(native_handle_t* handle, bool ownsHandle) { return handle ? new NativeHandle(handle, ownsHandle) : NULL; } NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle) -: mHandle(handle), mOwnsHandle(ownsHandle) -{} + : mHandle(handle), mOwnsHandle(ownsHandle) { + +} NativeHandle::~NativeHandle() { if (mOwnsHandle) { diff --git a/libutils/Printer.cpp b/libutils/Printer.cpp index 98cd2c66a..9573a10c4 100644 --- a/libutils/Printer.cpp +++ b/libutils/Printer.cpp @@ -21,10 +21,6 @@ #include #include -#include -#include -#include - namespace android { /* diff --git a/libutils/ProcessCallStack.cpp b/libutils/ProcessCallStack.cpp index 73ed4ebef..1d9f30dc7 100644 --- a/libutils/ProcessCallStack.cpp +++ b/libutils/ProcessCallStack.cpp @@ -17,18 +17,11 @@ #define LOG_TAG "ProcessCallStack" // #define LOG_NDEBUG 0 -#include -#include -#include -#include -#include - -#include -#include #include -#include -#include +#include + +#include namespace android { diff --git a/libutils/PropertyMap.cpp b/libutils/PropertyMap.cpp index 55207027b..4bcdd0f7f 100644 --- a/libutils/PropertyMap.cpp +++ b/libutils/PropertyMap.cpp @@ -16,11 +16,7 @@ #define LOG_TAG "PropertyMap" -#include -#include - #include -#include // Enables debug output for the parser. #define DEBUG_PARSER 0 diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp index 4252ba6b2..0d98db949 100644 --- a/libutils/RefBase.cpp +++ b/libutils/RefBase.cpp @@ -17,18 +17,9 @@ #define LOG_TAG "RefBase" // #define LOG_NDEBUG 0 -#include -#include -#include -#include -#include -#include - #include #include -#include -#include #ifndef __unused #define __unused __attribute__((__unused__)) diff --git a/libutils/SharedBuffer.cpp b/libutils/SharedBuffer.cpp index 1fa1d7a54..bad98b274 100644 --- a/libutils/SharedBuffer.cpp +++ b/libutils/SharedBuffer.cpp @@ -16,13 +16,13 @@ #define LOG_TAG "sharedbuffer" +#include "SharedBuffer.h" + #include #include #include -#include "SharedBuffer.h" - // --------------------------------------------------------------------------- namespace android { diff --git a/libutils/StopWatch.cpp b/libutils/StopWatch.cpp index 8c7b59645..219c13c67 100644 --- a/libutils/StopWatch.cpp +++ b/libutils/StopWatch.cpp @@ -16,9 +16,7 @@ #define LOG_TAG "StopWatch" -#include -#include -#include +#include /* for PRId64 */ #ifndef __STDC_FORMAT_MACROS @@ -27,8 +25,6 @@ #include #include -#include -#include /*****************************************************************************/ diff --git a/libutils/String16.cpp b/libutils/String16.cpp index 9f5cfeab4..12bb7c454 100644 --- a/libutils/String16.cpp +++ b/libutils/String16.cpp @@ -17,12 +17,6 @@ #include #include -#include -#include - -#include -#include -#include #include "SharedBuffer.h" diff --git a/libutils/String8.cpp b/libutils/String8.cpp index cacaf91b8..0ac39f919 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -21,11 +21,7 @@ #include #include -#include #include -#include - -#include #include "SharedBuffer.h" diff --git a/libutils/SystemClock.cpp b/libutils/SystemClock.cpp index 965e32c0f..28fc35145 100644 --- a/libutils/SystemClock.cpp +++ b/libutils/SystemClock.cpp @@ -19,17 +19,17 @@ * System clock functions. */ +#define LOG_TAG "SystemClock" + +#include + #include -#include -#include #include #include #include -#include -#include -#define LOG_TAG "SystemClock" +#include #include namespace android { diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp index def739f9f..6317c32d4 100644 --- a/libutils/Threads.cpp +++ b/libutils/Threads.cpp @@ -18,16 +18,10 @@ #define LOG_TAG "libutils.threads" #include -#include -#include -#include -#include -#include -#include +#include +#include #if !defined(_WIN32) -# include -# include # include #else # include @@ -40,7 +34,6 @@ #include #endif -#include #include #include diff --git a/libutils/Timers.cpp b/libutils/Timers.cpp index 201bc412c..b2df9a58f 100644 --- a/libutils/Timers.cpp +++ b/libutils/Timers.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #if defined(__ANDROID__) @@ -53,7 +52,7 @@ nsecs_t systemTime(int /*clock*/) int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime) { - int timeoutDelayMillis; + nsecs_t timeoutDelayMillis; if (timeoutTime > referenceTime) { uint64_t timeoutDelay = uint64_t(timeoutTime - referenceTime); if (timeoutDelay > uint64_t((INT_MAX - 1) * 1000000LL)) { @@ -64,5 +63,5 @@ int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime) } else { timeoutDelayMillis = 0; } - return timeoutDelayMillis; + return (int)timeoutDelayMillis; } diff --git a/libutils/Tokenizer.cpp b/libutils/Tokenizer.cpp index 2d0e83dcd..b68a2cfa3 100644 --- a/libutils/Tokenizer.cpp +++ b/libutils/Tokenizer.cpp @@ -16,14 +16,10 @@ #define LOG_TAG "Tokenizer" -#include -#include +#include #include -#include -#include #include #include -#include // Enables debug output for the tokenizer. #define DEBUG_TOKENIZER 0 diff --git a/libutils/Trace.cpp b/libutils/Trace.cpp index 36fd80214..8530fdca0 100644 --- a/libutils/Trace.cpp +++ b/libutils/Trace.cpp @@ -14,12 +14,11 @@ * limitations under the License. */ -#include #include +#include static void traceInit() __attribute__((constructor)); -static void traceInit() -{ +static void traceInit() { ::android::add_sysprop_change_callback(atrace_update_tags, 0); } diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp index f1a41b96f..5fd915524 100644 --- a/libutils/Unicode.cpp +++ b/libutils/Unicode.cpp @@ -16,11 +16,10 @@ #define LOG_TAG "unicode" +#include #include -#include #include -#include #if defined(_WIN32) # undef nhtol diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp index f7ca8f4f9..ef3277f42 100644 --- a/libutils/VectorImpl.cpp +++ b/libutils/VectorImpl.cpp @@ -16,13 +16,13 @@ #define LOG_TAG "Vector" +#include + #include #include #include #include -#include -#include #include diff --git a/libutils/include/utils/BlobCache.h b/libutils/include/utils/BlobCache.h index 65dca9fb4..27a81e3c0 100644 --- a/libutils/include/utils/BlobCache.h +++ b/libutils/include/utils/BlobCache.h @@ -19,10 +19,8 @@ #include -#include #include #include -#include namespace android { diff --git a/libutils/include/utils/NativeHandle.h b/libutils/include/utils/NativeHandle.h index b82516879..73fe804cc 100644 --- a/libutils/include/utils/NativeHandle.h +++ b/libutils/include/utils/NativeHandle.h @@ -24,7 +24,7 @@ typedef struct native_handle native_handle_t; namespace android { -class NativeHandle: public LightRefBase { +class NativeHandle : public LightRefBase { public: // Create a refcounted wrapper around a native_handle_t, and declare // whether the wrapper owns the handle (so that it should clean up the @@ -41,7 +41,7 @@ private: friend class LightRefBase; NativeHandle(native_handle_t* handle, bool ownsHandle); - virtual ~NativeHandle(); + ~NativeHandle(); native_handle_t* mHandle; bool mOwnsHandle; diff --git a/libutils/include/utils/RefBase.h b/libutils/include/utils/RefBase.h index 36016cde6..a61ea58f4 100644 --- a/libutils/include/utils/RefBase.h +++ b/libutils/include/utils/RefBase.h @@ -371,10 +371,8 @@ protected: private: friend class ReferenceMover; - inline static void renameRefs(size_t /*n*/, - const ReferenceRenamer& /*renamer*/) { } - inline static void renameRefId(T* /*ref*/, - const void* /*old_id*/ , const void* /*new_id*/) { } + inline static void renameRefs(size_t /*n*/, const ReferenceRenamer& /*renamer*/) { } + inline static void renameRefId(T* /*ref*/, const void* /*old_id*/ , const void* /*new_id*/) { } private: mutable std::atomic mCount; diff --git a/libutils/include/utils/Singleton.h b/libutils/include/utils/Singleton.h index a989a4703..bdb2332cf 100644 --- a/libutils/include/utils/Singleton.h +++ b/libutils/include/utils/Singleton.h @@ -18,9 +18,12 @@ #define ANDROID_UTILS_SINGLETON_H #include + +// some vendor code assumes they have atoi() after including this file. +#include + #include #include -#include #include namespace android { diff --git a/libutils/include/utils/StrongPointer.h b/libutils/include/utils/StrongPointer.h index 294e6b6f4..cdfdd8ac6 100644 --- a/libutils/include/utils/StrongPointer.h +++ b/libutils/include/utils/StrongPointer.h @@ -17,12 +17,6 @@ #ifndef ANDROID_STRONG_POINTER_H #define ANDROID_STRONG_POINTER_H -#include - -#include -#include -#include - // --------------------------------------------------------------------------- namespace android { diff --git a/libutils/include/utils/Trace.h b/libutils/include/utils/Trace.h index eeba40d65..5e9229c1e 100644 --- a/libutils/include/utils/Trace.h +++ b/libutils/include/utils/Trace.h @@ -19,16 +19,8 @@ #if defined(__ANDROID__) -#include #include -#include -#include -#include -#include -#include -#include -#include #include // See for more ATRACE_* macros. @@ -37,6 +29,7 @@ #define _PASTE(x, y) x ## y #define PASTE(x, y) _PASTE(x,y) #define ATRACE_NAME(name) android::ScopedTrace PASTE(___tracer, __LINE__) (ATRACE_TAG, name) + // ATRACE_CALL is an ATRACE_NAME that uses the current function name. #define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) @@ -44,14 +37,13 @@ namespace android { class ScopedTrace { public: -inline ScopedTrace(uint64_t tag, const char* name) - : mTag(tag) { - atrace_begin(mTag,name); -} + inline ScopedTrace(uint64_t tag, const char* name) : mTag(tag) { + atrace_begin(mTag, name); + } -inline ~ScopedTrace() { - atrace_end(mTag); -} + inline ~ScopedTrace() { + atrace_end(mTag); + } private: uint64_t mTag; diff --git a/libutils/misc.cpp b/libutils/misc.cpp index 216dc1430..2608a6575 100644 --- a/libutils/misc.cpp +++ b/libutils/misc.cpp @@ -22,12 +22,7 @@ #include #include -#include -#include -#include - #if !defined(_WIN32) -# include #endif #include