Merge "libutils: turn on -Werror"
This commit is contained in:
commit
60ca7a2223
13 changed files with 80 additions and 60 deletions
|
|
@ -43,7 +43,7 @@ commonSources:= \
|
||||||
VectorImpl.cpp \
|
VectorImpl.cpp \
|
||||||
misc.cpp
|
misc.cpp
|
||||||
|
|
||||||
host_commonCflags := -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
|
host_commonCflags := -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -Werror
|
||||||
|
|
||||||
ifeq ($(HOST_OS),windows)
|
ifeq ($(HOST_OS),windows)
|
||||||
ifeq ($(strip $(USE_CYGWIN),),)
|
ifeq ($(strip $(USE_CYGWIN),),)
|
||||||
|
|
@ -99,6 +99,7 @@ LOCAL_SRC_FILES:= \
|
||||||
ifeq ($(TARGET_ARCH),mips)
|
ifeq ($(TARGET_ARCH),mips)
|
||||||
LOCAL_CFLAGS += -DALIGN_DOUBLE
|
LOCAL_CFLAGS += -DALIGN_DOUBLE
|
||||||
endif
|
endif
|
||||||
|
LOCAL_CFLAGS += -Werror
|
||||||
|
|
||||||
LOCAL_C_INCLUDES += \
|
LOCAL_C_INCLUDES += \
|
||||||
bionic/libc/private \
|
bionic/libc/private \
|
||||||
|
|
@ -126,7 +127,8 @@ LOCAL_SHARED_LIBRARIES := \
|
||||||
libbacktrace \
|
libbacktrace \
|
||||||
libcutils \
|
libcutils \
|
||||||
libdl \
|
libdl \
|
||||||
liblog \
|
liblog
|
||||||
|
LOCAL_CFLAGS := -Werror
|
||||||
|
|
||||||
include external/stlport/libstlport.mk
|
include external/stlport/libstlport.mk
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
// BlobCache::Header::mMagicNumber value
|
// BlobCache::Header::mMagicNumber value
|
||||||
static const uint32_t blobCacheMagic = '_Bb$';
|
static const uint32_t blobCacheMagic = ('_' << 24) + ('B' << 16) + ('b' << 8) + '$';
|
||||||
|
|
||||||
// BlobCache::Header::mBlobCacheVersion value
|
// BlobCache::Header::mBlobCacheVersion value
|
||||||
static const uint32_t blobCacheVersion = 1;
|
static const uint32_t blobCacheVersion = 1;
|
||||||
|
|
@ -49,7 +49,7 @@ BlobCache::BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize
|
||||||
mRandState[1] = (now >> 16) & 0xFFFF;
|
mRandState[1] = (now >> 16) & 0xFFFF;
|
||||||
mRandState[2] = (now >> 32) & 0xFFFF;
|
mRandState[2] = (now >> 32) & 0xFFFF;
|
||||||
#endif
|
#endif
|
||||||
ALOGV("initializing random seed using %lld", now);
|
ALOGV("initializing random seed using %lld", (unsigned long long)now);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlobCache::set(const void* key, size_t keySize, const void* value,
|
void BlobCache::set(const void* key, size_t keySize, const void* value,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,13 @@
|
||||||
#include <utils/FileMap.h>
|
#include <utils/FileMap.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_WIN32_FILEMAP) && !defined(__USE_MINGW_ANSI_STDIO)
|
||||||
|
# define PRId32 "I32d"
|
||||||
|
# define PRIx32 "I32x"
|
||||||
|
# define PRId64 "I64d"
|
||||||
|
#else
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
@ -169,8 +175,8 @@ try_again:
|
||||||
goto try_again;
|
goto try_again;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGE("mmap(%" PRId64 ",%zu) failed: %s\n",
|
ALOGE("mmap(%lld,%zu) failed: %s\n",
|
||||||
adjOffset, adjLength, strerror(errno));
|
(long long)adjOffset, adjLength, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mBasePtr = ptr;
|
mBasePtr = ptr;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ public:
|
||||||
: mNextPage(0)
|
: mNextPage(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void* operator new(size_t size, void* buf) { return buf; }
|
void* operator new(size_t /*size*/, void* buf) { return buf; }
|
||||||
|
|
||||||
void* start() {
|
void* start() {
|
||||||
return (void*) (((size_t)this) + sizeof(Page));
|
return (void*) (((size_t)this) + sizeof(Page));
|
||||||
|
|
@ -103,7 +103,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Page(const Page& other) {}
|
Page(const Page& /*other*/) {}
|
||||||
Page* mNextPage;
|
Page* mNextPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,14 @@
|
||||||
#define LOG_TAG "RefBase"
|
#define LOG_TAG "RefBase"
|
||||||
// #define LOG_NDEBUG 0
|
// #define LOG_NDEBUG 0
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <utils/RefBase.h>
|
#include <utils/RefBase.h>
|
||||||
|
|
||||||
#include <utils/Atomic.h>
|
#include <utils/Atomic.h>
|
||||||
|
|
@ -24,13 +32,9 @@
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <utils/threads.h>
|
#include <utils/threads.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#ifndef __unused
|
||||||
#include <stdio.h>
|
#define __unused __attribute__((__unused__))
|
||||||
#include <typeinfo>
|
#endif
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
// compile with refcounting debugging enabled
|
// compile with refcounting debugging enabled
|
||||||
#define DEBUG_REFS 0
|
#define DEBUG_REFS 0
|
||||||
|
|
@ -388,7 +392,7 @@ void RefBase::weakref_type::incWeak(const void* id)
|
||||||
{
|
{
|
||||||
weakref_impl* const impl = static_cast<weakref_impl*>(this);
|
weakref_impl* const impl = static_cast<weakref_impl*>(this);
|
||||||
impl->addWeakRef(id);
|
impl->addWeakRef(id);
|
||||||
const int32_t c = android_atomic_inc(&impl->mWeak);
|
const int32_t c __unused = android_atomic_inc(&impl->mWeak);
|
||||||
ALOG_ASSERT(c >= 0, "incWeak called on %p after last weak ref", this);
|
ALOG_ASSERT(c >= 0, "incWeak called on %p after last weak ref", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -615,7 +619,7 @@ void RefBase::onLastStrongRef(const void* /*id*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RefBase::onIncStrongAttempted(uint32_t flags, const void* id)
|
bool RefBase::onIncStrongAttempted(uint32_t flags, const void* /*id*/)
|
||||||
{
|
{
|
||||||
return (flags&FIRST_INC_STRONG) ? true : false;
|
return (flags&FIRST_INC_STRONG) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
@ -626,13 +630,15 @@ void RefBase::onLastWeakRef(const void* /*id*/)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
void RefBase::renameRefs(size_t n, const ReferenceRenamer& renamer) {
|
|
||||||
#if DEBUG_REFS
|
#if DEBUG_REFS
|
||||||
|
void RefBase::renameRefs(size_t n, const ReferenceRenamer& renamer) {
|
||||||
for (size_t i=0 ; i<n ; i++) {
|
for (size_t i=0 ; i<n ; i++) {
|
||||||
renamer(i);
|
renamer(i);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void RefBase::renameRefs(size_t /*n*/, const ReferenceRenamer& /*renamer*/) { }
|
||||||
|
#endif
|
||||||
|
|
||||||
void RefBase::renameRefId(weakref_type* ref,
|
void RefBase::renameRefId(weakref_type* ref,
|
||||||
const void* old_id, const void* new_id) {
|
const void* old_id, const void* new_id) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* for PRId64 */
|
/* for PRId64 */
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
#define __STDC_FORMAT_MACROS 1
|
#define __STDC_FORMAT_MACROS 1
|
||||||
|
#endif
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,6 @@ static char16_t* allocFromUTF8(const char* u8str, size_t u8len)
|
||||||
return getEmptyString();
|
return getEmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* const u8end = u8cur + u8len;
|
|
||||||
|
|
||||||
SharedBuffer* buf = SharedBuffer::alloc(sizeof(char16_t)*(u16len+1));
|
SharedBuffer* buf = SharedBuffer::alloc(sizeof(char16_t)*(u16len+1));
|
||||||
if (buf) {
|
if (buf) {
|
||||||
u8cur = (const uint8_t*) u8str;
|
u8cur = (const uint8_t*) u8str;
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,6 @@ char* String8::find_extension(void) const
|
||||||
{
|
{
|
||||||
const char* lastSlash;
|
const char* lastSlash;
|
||||||
const char* lastDot;
|
const char* lastDot;
|
||||||
int extLen;
|
|
||||||
const char* const str = mString;
|
const char* const str = mString;
|
||||||
|
|
||||||
// only look at the filename
|
// only look at the filename
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,7 @@ int64_t elapsedRealtime()
|
||||||
*/
|
*/
|
||||||
#define DEBUG_TIMESTAMP 0
|
#define DEBUG_TIMESTAMP 0
|
||||||
|
|
||||||
static const char *gettime_method_names[] = {
|
#if DEBUG_TIMESTAMP && defined(ARCH_ARM)
|
||||||
"clock_gettime",
|
|
||||||
"ioctl",
|
|
||||||
"systemTime",
|
|
||||||
};
|
|
||||||
|
|
||||||
#if DEBUG_TIMESTAMP
|
|
||||||
static inline void checkTimeStamps(int64_t timestamp,
|
static inline void checkTimeStamps(int64_t timestamp,
|
||||||
int64_t volatile *prevTimestampPtr,
|
int64_t volatile *prevTimestampPtr,
|
||||||
int volatile *prevMethodPtr,
|
int volatile *prevMethodPtr,
|
||||||
|
|
@ -85,11 +79,16 @@ static inline void checkTimeStamps(int64_t timestamp,
|
||||||
* gettid, and int64_t is different on the ARM platform
|
* gettid, and int64_t is different on the ARM platform
|
||||||
* (ie long vs long long).
|
* (ie long vs long long).
|
||||||
*/
|
*/
|
||||||
#ifdef ARCH_ARM
|
|
||||||
int64_t prevTimestamp = *prevTimestampPtr;
|
int64_t prevTimestamp = *prevTimestampPtr;
|
||||||
int prevMethod = *prevMethodPtr;
|
int prevMethod = *prevMethodPtr;
|
||||||
|
|
||||||
if (timestamp < prevTimestamp) {
|
if (timestamp < prevTimestamp) {
|
||||||
|
static const char *gettime_method_names[] = {
|
||||||
|
"clock_gettime",
|
||||||
|
"ioctl",
|
||||||
|
"systemTime",
|
||||||
|
};
|
||||||
|
|
||||||
ALOGW("time going backwards: prev %lld(%s) vs now %lld(%s), tid=%d",
|
ALOGW("time going backwards: prev %lld(%s) vs now %lld(%s), tid=%d",
|
||||||
prevTimestamp, gettime_method_names[prevMethod],
|
prevTimestamp, gettime_method_names[prevMethod],
|
||||||
timestamp, gettime_method_names[curMethod],
|
timestamp, gettime_method_names[curMethod],
|
||||||
|
|
@ -99,7 +98,6 @@ static inline void checkTimeStamps(int64_t timestamp,
|
||||||
// write is interrupted or not observed as a whole.
|
// write is interrupted or not observed as a whole.
|
||||||
*prevTimestampPtr = timestamp;
|
*prevTimestampPtr = timestamp;
|
||||||
*prevMethodPtr = curMethod;
|
*prevMethodPtr = curMethod;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define checkTimeStamps(timestamp, prevTimestampPtr, prevMethodPtr, curMethod)
|
#define checkTimeStamps(timestamp, prevTimestampPtr, prevMethodPtr, curMethod)
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,11 @@
|
||||||
// #define LOG_NDEBUG 0
|
// #define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "libutils.threads"
|
#define LOG_TAG "libutils.threads"
|
||||||
|
|
||||||
#include <utils/threads.h>
|
#include <assert.h>
|
||||||
#include <utils/Log.h>
|
#include <errno.h>
|
||||||
|
#include <memory.h>
|
||||||
#include <cutils/sched_policy.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(HAVE_PTHREADS)
|
#if defined(HAVE_PTHREADS)
|
||||||
|
|
@ -47,6 +42,17 @@
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <utils/threads.h>
|
||||||
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#include <cutils/sched_policy.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ANDROID_OS
|
||||||
|
# define __android_unused
|
||||||
|
#else
|
||||||
|
# define __android_unused __attribute__((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
* Thread wrappers
|
* Thread wrappers
|
||||||
|
|
@ -119,7 +125,7 @@ void androidSetThreadName(const char* name) {
|
||||||
|
|
||||||
int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
|
int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
|
||||||
void *userData,
|
void *userData,
|
||||||
const char* threadName,
|
const char* threadName __android_unused,
|
||||||
int32_t threadPriority,
|
int32_t threadPriority,
|
||||||
size_t threadStackSize,
|
size_t threadStackSize,
|
||||||
android_thread_id_t *threadId)
|
android_thread_id_t *threadId)
|
||||||
|
|
@ -251,9 +257,9 @@ static bool doCreateThread(android_thread_func_t fn, void* arg, android_thread_i
|
||||||
|
|
||||||
int androidCreateRawThreadEtc(android_thread_func_t fn,
|
int androidCreateRawThreadEtc(android_thread_func_t fn,
|
||||||
void *userData,
|
void *userData,
|
||||||
const char* threadName,
|
const char* /*threadName*/,
|
||||||
int32_t threadPriority,
|
int32_t /*threadPriority*/,
|
||||||
size_t threadStackSize,
|
size_t /*threadStackSize*/,
|
||||||
android_thread_id_t *threadId)
|
android_thread_id_t *threadId)
|
||||||
{
|
{
|
||||||
return doCreateThread( fn, userData, threadId);
|
return doCreateThread( fn, userData, threadId);
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ANDROID_OS)
|
||||||
nsecs_t systemTime(int clock)
|
nsecs_t systemTime(int clock)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_ANDROID_OS)
|
|
||||||
static const clockid_t clocks[] = {
|
static const clockid_t clocks[] = {
|
||||||
CLOCK_REALTIME,
|
CLOCK_REALTIME,
|
||||||
CLOCK_MONOTONIC,
|
CLOCK_MONOTONIC,
|
||||||
|
|
@ -46,7 +46,10 @@ nsecs_t systemTime(int clock)
|
||||||
t.tv_sec = t.tv_nsec = 0;
|
t.tv_sec = t.tv_nsec = 0;
|
||||||
clock_gettime(clocks[clock], &t);
|
clock_gettime(clocks[clock], &t);
|
||||||
return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec;
|
return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
nsecs_t systemTime(int /*clock*/)
|
||||||
|
{
|
||||||
// Clock support varies widely across hosts. Mac OS doesn't support
|
// Clock support varies widely across hosts. Mac OS doesn't support
|
||||||
// posix clocks, older glibcs don't support CLOCK_BOOTTIME and Windows
|
// posix clocks, older glibcs don't support CLOCK_BOOTTIME and Windows
|
||||||
// is windows.
|
// is windows.
|
||||||
|
|
@ -54,8 +57,8 @@ nsecs_t systemTime(int clock)
|
||||||
t.tv_sec = t.tv_usec = 0;
|
t.tv_sec = t.tv_usec = 0;
|
||||||
gettimeofday(&t, NULL);
|
gettimeofday(&t, NULL);
|
||||||
return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL;
|
return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime)
|
int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -576,7 +576,7 @@ void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) {
|
||||||
char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen) {
|
char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen) {
|
||||||
const uint8_t* const u8end = src + srcLen;
|
const uint8_t* const u8end = src + srcLen;
|
||||||
const uint8_t* u8cur = src;
|
const uint8_t* u8cur = src;
|
||||||
const uint16_t* const u16end = dst + dstLen;
|
const char16_t* const u16end = dst + dstLen;
|
||||||
char16_t* u16cur = dst;
|
char16_t* u16cur = dst;
|
||||||
|
|
||||||
while (u8cur < u8end && u16cur < u16end) {
|
while (u8cur < u8end && u16cur < u16end) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, CacheSingleValueSucceeds) {
|
TEST_F(BlobCacheTest, CacheSingleValueSucceeds) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
||||||
ASSERT_EQ('e', buf[0]);
|
ASSERT_EQ('e', buf[0]);
|
||||||
|
|
@ -54,7 +54,7 @@ TEST_F(BlobCacheTest, CacheSingleValueSucceeds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, CacheTwoValuesSucceeds) {
|
TEST_F(BlobCacheTest, CacheTwoValuesSucceeds) {
|
||||||
char buf[2] = { 0xee, 0xee };
|
unsigned char buf[2] = { 0xee, 0xee };
|
||||||
mBC->set("ab", 2, "cd", 2);
|
mBC->set("ab", 2, "cd", 2);
|
||||||
mBC->set("ef", 2, "gh", 2);
|
mBC->set("ef", 2, "gh", 2);
|
||||||
ASSERT_EQ(size_t(2), mBC->get("ab", 2, buf, 2));
|
ASSERT_EQ(size_t(2), mBC->get("ab", 2, buf, 2));
|
||||||
|
|
@ -66,7 +66,7 @@ TEST_F(BlobCacheTest, CacheTwoValuesSucceeds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, GetOnlyWritesInsideBounds) {
|
TEST_F(BlobCacheTest, GetOnlyWritesInsideBounds) {
|
||||||
char buf[6] = { 0xee, 0xee, 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[6] = { 0xee, 0xee, 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf+1, 4));
|
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf+1, 4));
|
||||||
ASSERT_EQ(0xee, buf[0]);
|
ASSERT_EQ(0xee, buf[0]);
|
||||||
|
|
@ -78,7 +78,7 @@ TEST_F(BlobCacheTest, GetOnlyWritesInsideBounds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, GetOnlyWritesIfBufferIsLargeEnough) {
|
TEST_F(BlobCacheTest, GetOnlyWritesIfBufferIsLargeEnough) {
|
||||||
char buf[3] = { 0xee, 0xee, 0xee };
|
unsigned char buf[3] = { 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 3));
|
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 3));
|
||||||
ASSERT_EQ(0xee, buf[0]);
|
ASSERT_EQ(0xee, buf[0]);
|
||||||
|
|
@ -92,7 +92,7 @@ TEST_F(BlobCacheTest, GetDoesntAccessNullBuffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, MultipleSetsCacheLatestValue) {
|
TEST_F(BlobCacheTest, MultipleSetsCacheLatestValue) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
mBC->set("abcd", 4, "ijkl", 4);
|
mBC->set("abcd", 4, "ijkl", 4);
|
||||||
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
||||||
|
|
@ -103,7 +103,7 @@ TEST_F(BlobCacheTest, MultipleSetsCacheLatestValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, SecondSetKeepsFirstValueIfTooLarge) {
|
TEST_F(BlobCacheTest, SecondSetKeepsFirstValueIfTooLarge) {
|
||||||
char buf[MAX_VALUE_SIZE+1] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[MAX_VALUE_SIZE+1] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
mBC->set("abcd", 4, buf, MAX_VALUE_SIZE+1);
|
mBC->set("abcd", 4, buf, MAX_VALUE_SIZE+1);
|
||||||
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
ASSERT_EQ(size_t(4), mBC->get("abcd", 4, buf, 4));
|
||||||
|
|
@ -115,7 +115,7 @@ TEST_F(BlobCacheTest, SecondSetKeepsFirstValueIfTooLarge) {
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, DoesntCacheIfKeyIsTooBig) {
|
TEST_F(BlobCacheTest, DoesntCacheIfKeyIsTooBig) {
|
||||||
char key[MAX_KEY_SIZE+1];
|
char key[MAX_KEY_SIZE+1];
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
for (int i = 0; i < MAX_KEY_SIZE+1; i++) {
|
for (int i = 0; i < MAX_KEY_SIZE+1; i++) {
|
||||||
key[i] = 'a';
|
key[i] = 'a';
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +165,7 @@ TEST_F(BlobCacheTest, DoesntCacheIfKeyValuePairIsTooBig) {
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, CacheMaxKeySizeSucceeds) {
|
TEST_F(BlobCacheTest, CacheMaxKeySizeSucceeds) {
|
||||||
char key[MAX_KEY_SIZE];
|
char key[MAX_KEY_SIZE];
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
for (int i = 0; i < MAX_KEY_SIZE; i++) {
|
for (int i = 0; i < MAX_KEY_SIZE; i++) {
|
||||||
key[i] = 'a';
|
key[i] = 'a';
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ TEST_F(BlobCacheTest, CacheMaxKeyValuePairSizeSucceeds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheTest, CacheMinKeyAndValueSizeSucceeds) {
|
TEST_F(BlobCacheTest, CacheMinKeyAndValueSizeSucceeds) {
|
||||||
char buf[1] = { 0xee };
|
unsigned char buf[1] = { 0xee };
|
||||||
mBC->set("x", 1, "y", 1);
|
mBC->set("x", 1, "y", 1);
|
||||||
ASSERT_EQ(size_t(1), mBC->get("x", 1, buf, 1));
|
ASSERT_EQ(size_t(1), mBC->get("x", 1, buf, 1));
|
||||||
ASSERT_EQ('y', buf[0]);
|
ASSERT_EQ('y', buf[0]);
|
||||||
|
|
@ -282,7 +282,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(BlobCacheFlattenTest, FlattenOneValue) {
|
TEST_F(BlobCacheFlattenTest, FlattenOneValue) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
roundTrip();
|
roundTrip();
|
||||||
ASSERT_EQ(size_t(4), mBC2->get("abcd", 4, buf, 4));
|
ASSERT_EQ(size_t(4), mBC2->get("abcd", 4, buf, 4));
|
||||||
|
|
@ -348,7 +348,7 @@ TEST_F(BlobCacheFlattenTest, FlattenCatchesBufferTooSmall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadMagic) {
|
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadMagic) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
|
|
||||||
size_t size = mBC->getFlattenedSize();
|
size_t size = mBC->getFlattenedSize();
|
||||||
|
|
@ -365,7 +365,7 @@ TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadMagic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheVersion) {
|
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheVersion) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
|
|
||||||
size_t size = mBC->getFlattenedSize();
|
size_t size = mBC->getFlattenedSize();
|
||||||
|
|
@ -384,7 +384,7 @@ TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheDeviceVersion) {
|
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheDeviceVersion) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
|
|
||||||
size_t size = mBC->getFlattenedSize();
|
size_t size = mBC->getFlattenedSize();
|
||||||
|
|
@ -403,7 +403,7 @@ TEST_F(BlobCacheFlattenTest, UnflattenCatchesBadBlobCacheDeviceVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBufferTooSmall) {
|
TEST_F(BlobCacheFlattenTest, UnflattenCatchesBufferTooSmall) {
|
||||||
char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
unsigned char buf[4] = { 0xee, 0xee, 0xee, 0xee };
|
||||||
mBC->set("abcd", 4, "efgh", 4);
|
mBC->set("abcd", 4, "efgh", 4);
|
||||||
|
|
||||||
size_t size = mBC->getFlattenedSize();
|
size_t size = mBC->getFlattenedSize();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue