am cd3f60f3: Merge "AArch64: Make frameworks/base code more portable"

* commit 'cd3f60f30366a34b4499aab5a47b622069ba9cd6':
  AArch64: Make frameworks/base code more portable
This commit is contained in:
Narayan Kamath
2014-03-27 12:36:10 +00:00
committed by Android Git Automerger
21 changed files with 105 additions and 95 deletions

View File

@ -69,7 +69,7 @@ void TextLayoutCache::operator()(TextLayoutCacheKey& text, sp<TextLayoutValue>&
size_t totalSizeToDelete = text.getSize() + desc->getSize(); size_t totalSizeToDelete = text.getSize() + desc->getSize();
mSize -= totalSizeToDelete; mSize -= totalSizeToDelete;
if (mDebugEnabled) { if (mDebugEnabled) {
ALOGD("Cache value %p deleted, size = %d", desc.get(), totalSizeToDelete); ALOGD("Cache value %p deleted, size = %zu", desc.get(), totalSizeToDelete);
} }
} }
@ -129,7 +129,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
bool removedOne = mCache.removeOldest(); bool removedOne = mCache.removeOldest();
LOG_ALWAYS_FATAL_IF(!removedOne, "The cache is non-empty but we " LOG_ALWAYS_FATAL_IF(!removedOne, "The cache is non-empty but we "
"failed to remove the oldest entry. " "failed to remove the oldest entry. "
"mSize = %u, size = %u, mMaxSize = %u, mCache.size() = %u", "mSize = %u, size = %zu, mMaxSize = %u, mCache.size() = %zu",
mSize, size, mMaxSize, mCache.size()); mSize, size, mMaxSize, mCache.size());
} }
} }
@ -148,7 +148,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
nsecs_t totalTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime; nsecs_t totalTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime;
ALOGD("CACHE MISS: Added entry %p " ALOGD("CACHE MISS: Added entry %p "
"with start = %d, count = %d, contextCount = %d, " "with start = %d, count = %d, contextCount = %d, "
"entry size %d bytes, remaining space %d bytes" "entry size %zu bytes, remaining space %d bytes"
" - Compute time %0.6f ms - Put time %0.6f ms - Text = '%s'", " - Compute time %0.6f ms - Put time %0.6f ms - Text = '%s'",
value.get(), start, count, contextCount, size, mMaxSize - mSize, value.get(), start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f, value->getElapsedTime() * 0.000001f,
@ -159,7 +159,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
if (mDebugEnabled) { if (mDebugEnabled) {
ALOGD("CACHE MISS: Calculated but not storing entry because it is too big " ALOGD("CACHE MISS: Calculated but not storing entry because it is too big "
"with start = %d, count = %d, contextCount = %d, " "with start = %d, count = %d, contextCount = %d, "
"entry size %d bytes, remaining space %d bytes" "entry size %zu bytes, remaining space %d bytes"
" - Compute time %0.6f ms - Text = '%s'", " - Compute time %0.6f ms - Text = '%s'",
start, count, contextCount, size, mMaxSize - mSize, start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f, value->getElapsedTime() * 0.000001f,
@ -204,7 +204,7 @@ void TextLayoutCache::dumpCacheStats() {
ALOGD("------------------------------------------------"); ALOGD("------------------------------------------------");
ALOGD("pid : %d", getpid()); ALOGD("pid : %d", getpid());
ALOGD("running : %.0f seconds", timeRunningInSec); ALOGD("running : %.0f seconds", timeRunningInSec);
ALOGD("entries : %d", cacheSize); ALOGD("entries : %zu", cacheSize);
ALOGD("max size : %d bytes", mMaxSize); ALOGD("max size : %d bytes", mMaxSize);
ALOGD("used : %d bytes according to mSize", mSize); ALOGD("used : %d bytes according to mSize", mSize);
ALOGD("remaining : %d bytes or %2.2f percent", mMaxSize - mSize, remainingPercent); ALOGD("remaining : %d bytes or %2.2f percent", mMaxSize - mSize, remainingPercent);

View File

@ -111,7 +111,7 @@ socket_bind_local (JNIEnv *env, jobject object, jobject fileDescriptor,
/* private native void listen_native(int fd, int backlog) throws IOException; */ /* private native void listen_native(int fd, int backlog) throws IOException; */
static void static void
socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, int backlog) socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog)
{ {
int ret; int ret;
int fd; int fd;
@ -231,7 +231,7 @@ java_opt_to_real(int optID, int* opt, int* level)
} }
static jint static jint
socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, int optID) socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID)
{ {
int ret, value; int ret, value;
int opt, level; int opt, level;
@ -279,7 +279,7 @@ socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, int optID)
} }
static void socket_setOption( static void socket_setOption(
JNIEnv *env, jobject object, jobject fileDescriptor, int optID, JNIEnv *env, jobject object, jobject fileDescriptor, jint optID,
jint boolValue, jint intValue) { jint boolValue, jint intValue) {
int ret; int ret;
int optname; int optname;

View File

@ -37,7 +37,7 @@ void* android::nio_getPointer(JNIEnv *_env, jobject buffer, jarray *array) {
gNioJNI.getBasePointerID, buffer); gNioJNI.getBasePointerID, buffer);
if (pointer != 0L) { if (pointer != 0L) {
*array = NULL; *array = NULL;
return (void *) (jint) pointer; return reinterpret_cast<void *>(pointer);
} }
*array = (jarray) _env->CallStaticObjectMethod(gNioJNI.nioAccessClass, *array = (jarray) _env->CallStaticObjectMethod(gNioJNI.nioAccessClass,

View File

@ -800,7 +800,7 @@ static void dumpNativeHeap(FILE* fp)
fprintf(fp, "Total memory: %zu\n", totalMemory); fprintf(fp, "Total memory: %zu\n", totalMemory);
fprintf(fp, "Allocation records: %zd\n", recordCount); fprintf(fp, "Allocation records: %zd\n", recordCount);
if (backtraceSize != BACKTRACE_SIZE) { if (backtraceSize != BACKTRACE_SIZE) {
fprintf(fp, "WARNING: mismatched backtrace sizes (%d vs. %d)\n", fprintf(fp, "WARNING: mismatched backtrace sizes (%zu vs. %d)\n",
backtraceSize, BACKTRACE_SIZE); backtraceSize, BACKTRACE_SIZE);
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
@ -823,7 +823,11 @@ static void dumpNativeHeap(FILE* fp)
if (backtrace[bt] == 0) { if (backtrace[bt] == 0) {
break; break;
} else { } else {
#ifdef __LP64__
fprintf(fp, " %016x", backtrace[bt]);
#else
fprintf(fp, " %08x", backtrace[bt]); fprintf(fp, " %08x", backtrace[bt]);
#endif
} }
} }
fprintf(fp, "\n"); fprintf(fp, "\n");

View File

@ -47,8 +47,8 @@ static jint QTagUid_tagSocketFd(JNIEnv* env, jclass,
return (jint)res; return (jint)res;
} }
static int QTagUid_untagSocketFd(JNIEnv* env, jclass, static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
jobject fileDescriptor) { jobject fileDescriptor) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor); int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (env->ExceptionOccurred() != NULL) { if (env->ExceptionOccurred() != NULL) {

View File

@ -26,7 +26,7 @@
namespace android { namespace android {
static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray, static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
jbyteArray infoArray, int n, jboolean haveInfo) jbyteArray infoArray, jint n, jboolean haveInfo)
{ {
// Parameters are checked on java side // Parameters are checked on java side
// Failures from GetXXXArrayElements indicate a serious out-of-memory condition // Failures from GetXXXArrayElements indicate a serious out-of-memory condition

View File

@ -51,7 +51,8 @@ static int directionality_map[U_CHAR_DIRECTION_COUNT] = {
namespace android { namespace android {
static void getDirectionalities(JNIEnv* env, jobject obj, jcharArray srcArray, jbyteArray destArray, int count) static void getDirectionalities(JNIEnv* env, jobject obj, jcharArray srcArray,
jbyteArray destArray, jint count)
{ {
ScopedCharArrayRO src(env, srcArray); ScopedCharArrayRO src(env, srcArray);
if (src.get() == NULL) { if (src.get() == NULL) {
@ -102,7 +103,7 @@ static jint getEastAsianWidth(JNIEnv* env, jobject obj, jchar input)
} }
static void getEastAsianWidths(JNIEnv* env, jobject obj, jcharArray srcArray, static void getEastAsianWidths(JNIEnv* env, jobject obj, jcharArray srcArray,
int start, int count, jbyteArray destArray) jint start, jint count, jbyteArray destArray)
{ {
ScopedCharArrayRO src(env, srcArray); ScopedCharArrayRO src(env, srcArray);
if (src.get() == NULL) { if (src.get() == NULL) {
@ -144,20 +145,20 @@ static void getEastAsianWidths(JNIEnv* env, jobject obj, jcharArray srcArray,
} }
} }
static jboolean mirror(JNIEnv* env, jobject obj, jcharArray charArray, int start, int count) static jboolean mirror(JNIEnv* env, jobject obj, jcharArray charArray, jint start, jint count)
{ {
ScopedCharArrayRW data(env, charArray); ScopedCharArrayRW data(env, charArray);
if (data.get() == NULL) { if (data.get() == NULL) {
return false; return JNI_FALSE;
} }
if (start < 0 || start > start + count if (start < 0 || start > start + count
|| env->GetArrayLength(charArray) < start + count) { || env->GetArrayLength(charArray) < start + count) {
jniThrowException(env, "java/lang/ArrayIndexOutOfBoundsException", NULL); jniThrowException(env, "java/lang/ArrayIndexOutOfBoundsException", NULL);
return false; return JNI_FALSE;
} }
bool ret = false; jboolean ret = JNI_FALSE;
for (int i = start; i < start + count; i++) { for (int i = start; i < start + count; i++) {
// XXX this thinks it knows that surrogates are never mirrored // XXX this thinks it knows that surrogates are never mirrored
@ -166,7 +167,7 @@ static jboolean mirror(JNIEnv* env, jobject obj, jcharArray charArray, int start
if (c1 != c2) { if (c1 != c2) {
data[i] = c2; data[i] = c2;
ret = true; ret = JNI_TRUE;
} }
} }
return ret; return ret;

View File

@ -117,7 +117,7 @@ static jlong android_text_format_Time_normalize(JNIEnv* env, jobject This,
time2java(env, This, t); time2java(env, This, t);
RELEASE_TIMEZONE(This, t) RELEASE_TIMEZONE(This, t)
return result; return static_cast<jlong>(result);
} }
static void android_text_format_Time_switchTimezone(JNIEnv* env, jobject This, static void android_text_format_Time_switchTimezone(JNIEnv* env, jobject This,
@ -155,7 +155,7 @@ static jint android_text_format_Time_compare(JNIEnv* env, jobject clazz,
RELEASE_TIMEZONE(aObject, a) RELEASE_TIMEZONE(aObject, a)
RELEASE_TIMEZONE(bObject, b) RELEASE_TIMEZONE(bObject, b)
return result; return static_cast<jint>(result);
} }
static jstring android_text_format_Time_format2445(JNIEnv* env, jobject This) static jstring android_text_format_Time_format2445(JNIEnv* env, jobject This)
@ -346,7 +346,7 @@ static jlong android_text_format_Time_toMillis(JNIEnv* env, jobject This,
RELEASE_TIMEZONE(This, t) RELEASE_TIMEZONE(This, t)
return result; return static_cast<jlong>(result);
} }
static void android_text_format_Time_set(JNIEnv* env, jobject This, jlong millis) static void android_text_format_Time_set(JNIEnv* env, jobject This, jlong millis)
@ -400,10 +400,10 @@ static jboolean android_text_format_Time_parse(JNIEnv* env, jobject This, jstrin
if (len < 8) { if (len < 8) {
jniThrowException(env, "android/util/TimeFormatException", jniThrowException(env, "android/util/TimeFormatException",
"String too short -- expected at least 8 characters."); "String too short -- expected at least 8 characters.");
return false; return JNI_FALSE;
} }
jboolean inUtc = false; jboolean inUtc = JNI_FALSE;
ScopedStringChars s(env, strObj); ScopedStringChars s(env, strObj);
@ -414,49 +414,49 @@ static jboolean android_text_format_Time_parse(JNIEnv* env, jobject This, jstrin
n += get_char(env, s, 1, 100, &thrown); n += get_char(env, s, 1, 100, &thrown);
n += get_char(env, s, 2, 10, &thrown); n += get_char(env, s, 2, 10, &thrown);
n += get_char(env, s, 3, 1, &thrown); n += get_char(env, s, 3, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_yearField, n); env->SetIntField(This, g_yearField, n);
// month // month
n = get_char(env, s, 4, 10, &thrown); n = get_char(env, s, 4, 10, &thrown);
n += get_char(env, s, 5, 1, &thrown); n += get_char(env, s, 5, 1, &thrown);
n--; n--;
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_monField, n); env->SetIntField(This, g_monField, n);
// day of month // day of month
n = get_char(env, s, 6, 10, &thrown); n = get_char(env, s, 6, 10, &thrown);
n += get_char(env, s, 7, 1, &thrown); n += get_char(env, s, 7, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_mdayField, n); env->SetIntField(This, g_mdayField, n);
if (len > 8) { if (len > 8) {
// T // T
if (!check_char(env, s, 8, 'T')) return false; if (!check_char(env, s, 8, 'T')) return JNI_FALSE;
env->SetBooleanField(This, g_allDayField, JNI_FALSE); env->SetBooleanField(This, g_allDayField, JNI_FALSE);
// hour // hour
n = get_char(env, s, 9, 10, &thrown); n = get_char(env, s, 9, 10, &thrown);
n += get_char(env, s, 10, 1, &thrown); n += get_char(env, s, 10, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_hourField, n); env->SetIntField(This, g_hourField, n);
// min // min
n = get_char(env, s, 11, 10, &thrown); n = get_char(env, s, 11, 10, &thrown);
n += get_char(env, s, 12, 1, &thrown); n += get_char(env, s, 12, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_minField, n); env->SetIntField(This, g_minField, n);
// sec // sec
n = get_char(env, s, 13, 10, &thrown); n = get_char(env, s, 13, 10, &thrown);
n += get_char(env, s, 14, 1, &thrown); n += get_char(env, s, 14, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_secField, n); env->SetIntField(This, g_secField, n);
if (len > 15) { if (len > 15) {
// Z // Z
if (!check_char(env, s, 15, 'Z')) return false; if (!check_char(env, s, 15, 'Z')) return JNI_FALSE;
inUtc = true; inUtc = JNI_TRUE;
} }
} else { } else {
env->SetBooleanField(This, g_allDayField, JNI_TRUE); env->SetBooleanField(This, g_allDayField, JNI_TRUE);
@ -481,10 +481,10 @@ static jboolean android_text_format_Time_parse3339(JNIEnv* env,
if (len < 10) { if (len < 10) {
jniThrowException(env, "android/util/TimeFormatException", jniThrowException(env, "android/util/TimeFormatException",
"String too short --- expected at least 10 characters."); "String too short --- expected at least 10 characters.");
return false; return JNI_FALSE;
} }
jboolean inUtc = false; jboolean inUtc = JNI_FALSE;
ScopedStringChars s(env, strObj); ScopedStringChars s(env, strObj);
@ -495,57 +495,57 @@ static jboolean android_text_format_Time_parse3339(JNIEnv* env,
n += get_char(env, s, 1, 100, &thrown); n += get_char(env, s, 1, 100, &thrown);
n += get_char(env, s, 2, 10, &thrown); n += get_char(env, s, 2, 10, &thrown);
n += get_char(env, s, 3, 1, &thrown); n += get_char(env, s, 3, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_yearField, n); env->SetIntField(This, g_yearField, n);
// - // -
if (!check_char(env, s, 4, '-')) return false; if (!check_char(env, s, 4, '-')) return JNI_FALSE;
// month // month
n = get_char(env, s, 5, 10, &thrown); n = get_char(env, s, 5, 10, &thrown);
n += get_char(env, s, 6, 1, &thrown); n += get_char(env, s, 6, 1, &thrown);
--n; --n;
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_monField, n); env->SetIntField(This, g_monField, n);
// - // -
if (!check_char(env, s, 7, '-')) return false; if (!check_char(env, s, 7, '-')) return JNI_FALSE;
// day // day
n = get_char(env, s, 8, 10, &thrown); n = get_char(env, s, 8, 10, &thrown);
n += get_char(env, s, 9, 1, &thrown); n += get_char(env, s, 9, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_mdayField, n); env->SetIntField(This, g_mdayField, n);
if (len >= 19) { if (len >= 19) {
// T // T
if (!check_char(env, s, 10, 'T')) return false; if (!check_char(env, s, 10, 'T')) return JNI_FALSE;
env->SetBooleanField(This, g_allDayField, JNI_FALSE); env->SetBooleanField(This, g_allDayField, JNI_FALSE);
// hour // hour
n = get_char(env, s, 11, 10, &thrown); n = get_char(env, s, 11, 10, &thrown);
n += get_char(env, s, 12, 1, &thrown); n += get_char(env, s, 12, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
int hour = n; int hour = n;
// env->SetIntField(This, g_hourField, n); // env->SetIntField(This, g_hourField, n);
// : // :
if (!check_char(env, s, 13, ':')) return false; if (!check_char(env, s, 13, ':')) return JNI_FALSE;
// minute // minute
n = get_char(env, s, 14, 10, &thrown); n = get_char(env, s, 14, 10, &thrown);
n += get_char(env, s, 15, 1, &thrown); n += get_char(env, s, 15, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
int minute = n; int minute = n;
// env->SetIntField(This, g_minField, n); // env->SetIntField(This, g_minField, n);
// : // :
if (!check_char(env, s, 16, ':')) return false; if (!check_char(env, s, 16, ':')) return JNI_FALSE;
// second // second
n = get_char(env, s, 17, 10, &thrown); n = get_char(env, s, 17, 10, &thrown);
n += get_char(env, s, 18, 1, &thrown); n += get_char(env, s, 18, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
env->SetIntField(This, g_secField, n); env->SetIntField(This, g_secField, n);
// skip the '.XYZ' -- we don't care about subsecond precision. // skip the '.XYZ' -- we don't care about subsecond precision.
@ -579,32 +579,32 @@ static jboolean android_text_format_Time_parse3339(JNIEnv* env,
jniThrowExceptionFmt(env, "android/util/TimeFormatException", jniThrowExceptionFmt(env, "android/util/TimeFormatException",
"Unexpected character 0x%02x at position %d. Expected + or -", "Unexpected character 0x%02x at position %d. Expected + or -",
c, tz_index); c, tz_index);
return false; return JNI_FALSE;
} }
inUtc = true; inUtc = JNI_TRUE;
if (offset != 0) { if (offset != 0) {
if (len < tz_index + 6) { if (len < tz_index + 6) {
jniThrowExceptionFmt(env, "android/util/TimeFormatException", jniThrowExceptionFmt(env, "android/util/TimeFormatException",
"Unexpected length; should be %d characters", "Unexpected length; should be %d characters",
tz_index + 6); tz_index + 6);
return false; return JNI_FALSE;
} }
// hour // hour
n = get_char(env, s, tz_index + 1, 10, &thrown); n = get_char(env, s, tz_index + 1, 10, &thrown);
n += get_char(env, s, tz_index + 2, 1, &thrown); n += get_char(env, s, tz_index + 2, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
n *= offset; n *= offset;
hour += n; hour += n;
// : // :
if (!check_char(env, s, tz_index + 3, ':')) return false; if (!check_char(env, s, tz_index + 3, ':')) return JNI_FALSE;
// minute // minute
n = get_char(env, s, tz_index + 4, 10, &thrown); n = get_char(env, s, tz_index + 4, 10, &thrown);
n += get_char(env, s, tz_index + 5, 1, &thrown); n += get_char(env, s, tz_index + 5, 1, &thrown);
if (thrown) return false; if (thrown) return JNI_FALSE;
n *= offset; n *= offset;
minute += n; minute += n;
} }

View File

@ -85,7 +85,7 @@ static jboolean android_util_Log_isLoggable(JNIEnv* env, jobject clazz, jstring
jboolean result = false; jboolean result = false;
if ((strlen(chars)+sizeof(LOG_NAMESPACE)) > PROPERTY_KEY_MAX) { if ((strlen(chars)+sizeof(LOG_NAMESPACE)) > PROPERTY_KEY_MAX) {
char buf2[200]; char buf2[200];
snprintf(buf2, sizeof(buf2), "Log tag \"%s\" exceeds limit of %d characters\n", snprintf(buf2, sizeof(buf2), "Log tag \"%s\" exceeds limit of %zu characters\n",
chars, PROPERTY_KEY_MAX - sizeof(LOG_NAMESPACE)); chars, PROPERTY_KEY_MAX - sizeof(LOG_NAMESPACE));
jniThrowException(env, "java/lang/IllegalArgumentException", buf2); jniThrowException(env, "java/lang/IllegalArgumentException", buf2);

View File

@ -78,7 +78,7 @@ BackupDataWriter::write_padding_for(int n)
paddingSize = padding_extra(n); paddingSize = padding_extra(n);
if (paddingSize > 0) { if (paddingSize > 0) {
uint32_t padding = 0xbcbcbcbc; uint32_t padding = 0xbcbcbcbc;
if (DEBUG) ALOGI("writing %d padding bytes for %d", paddingSize, n); if (DEBUG) ALOGI("writing %zd padding bytes for %d", paddingSize, n);
amt = write(m_fd, &padding, paddingSize); amt = write(m_fd, &padding, paddingSize);
if (amt != paddingSize) { if (amt != paddingSize) {
m_status = errno; m_status = errno;
@ -112,7 +112,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
k = key; k = key;
} }
if (DEBUG) { if (DEBUG) {
ALOGD("Writing header: prefix='%s' key='%s' dataSize=%d", m_keyPrefix.string(), ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(),
key.string(), dataSize); key.string(), dataSize);
} }
@ -125,7 +125,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
header.keyLen = tolel(keyLen); header.keyLen = tolel(keyLen);
header.dataSize = tolel(dataSize); header.dataSize = tolel(dataSize);
if (DEBUG) ALOGI("writing entity header, %d bytes", sizeof(entity_header_v1)); if (DEBUG) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1));
amt = write(m_fd, &header, sizeof(entity_header_v1)); amt = write(m_fd, &header, sizeof(entity_header_v1));
if (amt != sizeof(entity_header_v1)) { if (amt != sizeof(entity_header_v1)) {
m_status = errno; m_status = errno;
@ -133,7 +133,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
} }
m_pos += amt; m_pos += amt;
if (DEBUG) ALOGI("writing entity header key, %d bytes", keyLen+1); if (DEBUG) ALOGI("writing entity header key, %zd bytes", keyLen+1);
amt = write(m_fd, k.string(), keyLen+1); amt = write(m_fd, k.string(), keyLen+1);
if (amt != keyLen+1) { if (amt != keyLen+1) {
m_status = errno; m_status = errno;

View File

@ -639,7 +639,7 @@ int write_tarfile(const String8& packageName, const String8& domain,
// size header -- calc len in digits by actually rendering the number // size header -- calc len in digits by actually rendering the number
// to a string - brute force but simple // to a string - brute force but simple
snprintf(sizeStr, sizeof(sizeStr), "%lld", s.st_size); snprintf(sizeStr, sizeof(sizeStr), "%lld", (long long)s.st_size);
p += write_pax_header_entry(p, "size", sizeStr); p += write_pax_header_entry(p, "size", sizeStr);
// fullname was generated above with the ustar paths // fullname was generated above with the ustar paths
@ -661,7 +661,7 @@ int write_tarfile(const String8& packageName, const String8& domain,
// [ 124 : 12 ] size of pax extended header data // [ 124 : 12 ] size of pax extended header data
memset(paxHeader + 124, 0, 12); memset(paxHeader + 124, 0, 12);
snprintf(paxHeader + 124, 12, "%011o", p - paxData); snprintf(paxHeader + 124, 12, "%011o", (unsigned int)(p - paxData));
// Checksum and write the pax block header // Checksum and write the pax block header
calc_tar_checksum(paxHeader); calc_tar_checksum(paxHeader);
@ -681,7 +681,10 @@ int write_tarfile(const String8& packageName, const String8& domain,
if (!isdir) { if (!isdir) {
off64_t toWrite = s.st_size; off64_t toWrite = s.st_size;
while (toWrite > 0) { while (toWrite > 0) {
size_t toRead = (toWrite < BUFSIZE) ? toWrite : BUFSIZE; size_t toRead = toWrite;
if (toRead > BUFSIZE) {
toRead = BUFSIZE;
}
ssize_t nRead = read(fd, buf, toRead); ssize_t nRead = read(fd, buf, toRead);
if (nRead < 0) { if (nRead < 0) {
err = errno; err = errno;
@ -1095,8 +1098,8 @@ backup_helper_test_four()
if (name != filenames[i] || states[i].modTime_sec != state.modTime_sec if (name != filenames[i] || states[i].modTime_sec != state.modTime_sec
|| states[i].modTime_nsec != state.modTime_nsec || states[i].mode != state.mode || states[i].modTime_nsec != state.modTime_nsec || states[i].mode != state.mode
|| states[i].size != state.size || states[i].crc32 != states[i].crc32) { || states[i].size != state.size || states[i].crc32 != states[i].crc32) {
fprintf(stderr, "state %zu expected={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n" fprintf(stderr, "state %zu expected={%d/%d, %04o, 0x%08x, 0x%08x, %3zu} '%s'\n"
" actual={%d/%d, 0x%08x, %04o, 0x%08x, %3zu} '%s'\n", i, " actual={%d/%d, %04o, 0x%08x, 0x%08x, %3d} '%s'\n", i,
states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size, states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size,
states[i].crc32, name.length(), filenames[i].string(), states[i].crc32, name.length(), filenames[i].string(),
state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32, state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32,
@ -1194,7 +1197,7 @@ int
test_read_header_and_entity(BackupDataReader& reader, const char* str) test_read_header_and_entity(BackupDataReader& reader, const char* str)
{ {
int err; int err;
int bufSize = strlen(str)+1; size_t bufSize = strlen(str)+1;
char* buf = (char*)malloc(bufSize); char* buf = (char*)malloc(bufSize);
String8 string; String8 string;
int cookie = 0x11111111; int cookie = 0x11111111;
@ -1229,9 +1232,9 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str)
err = EINVAL; err = EINVAL;
goto finished; goto finished;
} }
if ((int)actualSize != bufSize) { if (actualSize != bufSize) {
fprintf(stderr, "ReadEntityHeader expected dataSize 0x%08x got 0x%08zx\n", bufSize, fprintf(stderr, "ReadEntityHeader expected dataSize %zu got %zu\n",
actualSize); bufSize, actualSize);
err = EINVAL; err = EINVAL;
goto finished; goto finished;
} }

View File

@ -210,8 +210,8 @@ uint32_t CursorWindow::alloc(size_t size, bool aligned) {
uint32_t offset = mHeader->freeOffset + padding; uint32_t offset = mHeader->freeOffset + padding;
uint32_t nextFreeOffset = offset + size; uint32_t nextFreeOffset = offset + size;
if (nextFreeOffset > mSize) { if (nextFreeOffset > mSize) {
ALOGW("Window is full: requested allocation %d bytes, " ALOGW("Window is full: requested allocation %zu bytes, "
"free space %d bytes, window size %d bytes", "free space %zu bytes, window size %zu bytes",
size, freeSpace(), mSize); size, freeSpace(), mSize);
return 0; return 0;
} }

View File

@ -5996,12 +5996,12 @@ void ResTable::print(bool inclValues) const
uintptr_t esize = dtohs(ent->size); uintptr_t esize = dtohs(ent->size);
if ((esize&0x3) != 0) { if ((esize&0x3) != 0) {
printf("NON-INTEGER ResTable_entry SIZE: 0x%x\n", esize); printf("NON-INTEGER ResTable_entry SIZE: %p\n", (void *)esize);
continue; continue;
} }
if ((thisOffset+esize) > typeSize) { if ((thisOffset+esize) > typeSize) {
printf("ResTable_entry OUT OF BOUNDS: 0x%x+0x%x+0x%x (size is 0x%x)\n", printf("ResTable_entry OUT OF BOUNDS: 0x%x+0x%x+%p (size is 0x%x)\n",
entriesStart, thisOffset, esize, typeSize); entriesStart, thisOffset, (void *)esize, typeSize);
continue; continue;
} }

View File

@ -31,9 +31,9 @@ void ResourceCache::logCache() {
ALOGD("ResourceCache: cacheReport:"); ALOGD("ResourceCache: cacheReport:");
for (size_t i = 0; i < mCache->size(); ++i) { for (size_t i = 0; i < mCache->size(); ++i) {
ResourceReference* ref = mCache->valueAt(i); ResourceReference* ref = mCache->valueAt(i);
ALOGD(" ResourceCache: mCache(%d): resource, ref = 0x%p, 0x%p", ALOGD(" ResourceCache: mCache(%zu): resource, ref = 0x%p, 0x%p",
i, mCache->keyAt(i), mCache->valueAt(i)); i, mCache->keyAt(i), mCache->valueAt(i));
ALOGD(" ResourceCache: mCache(%d): refCount, recycled, destroyed, type = %d, %d, %d, %d", ALOGD(" ResourceCache: mCache(%zu): refCount, recycled, destroyed, type = %d, %d, %d, %d",
i, ref->refCount, ref->recycled, ref->destroyed, ref->resourceType); i, ref->refCount, ref->recycled, ref->destroyed, ref->resourceType);
} }
} }

View File

@ -32,7 +32,7 @@
struct usb_device *sDevice = NULL; struct usb_device *sDevice = NULL;
static void* read_thread(void* arg) { static void* read_thread(void* arg) {
int endpoint = (int)arg; int endpoint = (int)(uintptr_t)arg;
int ret = 0; int ret = 0;
while (sDevice && ret >= 0) { while (sDevice && ret >= 0) {
@ -52,7 +52,7 @@ static void* read_thread(void* arg) {
} }
static void* write_thread(void* arg) { static void* write_thread(void* arg) {
int endpoint = (int)arg; int endpoint = (int)(uintptr_t)arg;
int ret = 0; int ret = 0;
while (ret >= 0) { while (ret >= 0) {
@ -136,11 +136,11 @@ static int usb_device_added(const char *devname, void* client_data) {
} }
if ((ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) { if ((ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) {
pthread_create(&th, NULL, read_thread, (void *)ep1->bEndpointAddress); pthread_create(&th, NULL, read_thread, (void *)(uintptr_t)ep1->bEndpointAddress);
pthread_create(&th, NULL, write_thread, (void *)ep2->bEndpointAddress); pthread_create(&th, NULL, write_thread, (void *)(uintptr_t)ep2->bEndpointAddress);
} else { } else {
pthread_create(&th, NULL, read_thread, (void *)ep2->bEndpointAddress); pthread_create(&th, NULL, read_thread, (void *)(uintptr_t)ep2->bEndpointAddress);
pthread_create(&th, NULL, write_thread, (void *)ep1->bEndpointAddress); pthread_create(&th, NULL, write_thread, (void *)(uintptr_t)ep1->bEndpointAddress);
} }
} else { } else {
printf("Found possible android device - attempting to switch to accessory mode\n"); printf("Found possible android device - attempting to switch to accessory mode\n");

View File

@ -590,7 +590,7 @@ static void hexDumpToString(const uint8_t* src, size_t src_len,
for (i = 0; (i < src_len) && (offset < dst_len); ++i) { for (i = 0; (i < src_len) && (offset < dst_len); ++i) {
int res; int res;
if (0 == (i % 16)) { if (0 == (i % 16)) {
res = snprintf(dst + offset, dst_len - offset, "\n%04x :", i); res = snprintf(dst + offset, dst_len - offset, "\n%04zx :", i);
if (res < 0) if (res < 0)
break; break;
offset += res; offset += res;

View File

@ -56,7 +56,7 @@ LogRing::LogRing(const char* header, size_t entries)
, mHeader(header) { , mHeader(header) {
mRingBuffer = new Entry[mSize]; mRingBuffer = new Entry[mSize];
if (NULL == mRingBuffer) if (NULL == mRingBuffer)
ALOGE("Failed to allocate log ring with %u entries.", mSize); ALOGE("Failed to allocate log ring with %zu entries.", mSize);
} }
LogRing::~LogRing() { LogRing::~LogRing() {
@ -150,7 +150,7 @@ void LogRing::dumpLog(int fd) {
localtime_r(&mRingBuffer[ndx].first_ts.tv_sec, &t); localtime_r(&mRingBuffer[ndx].first_ts.tv_sec, &t);
strftime(timebuf, sizeof(timebuf), kTimeFmt, &t); strftime(timebuf, sizeof(timebuf), kTimeFmt, &t);
res = snprintf(buf, sizeof(buf), "[%2d] %s.%03ld :: %s%s\n", res = snprintf(buf, sizeof(buf), "[%2zu] %s.%03ld :: %s%s\n",
i, timebuf, i, timebuf,
mRingBuffer[ndx].first_ts.tv_usec / 1000, mRingBuffer[ndx].first_ts.tv_usec / 1000,
mRingBuffer[ndx].s.string(), mRingBuffer[ndx].s.string(),

View File

@ -759,7 +759,7 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
if (readSize == 0 || (readSize < 0 && errno == ENODEV)) { if (readSize == 0 || (readSize < 0 && errno == ENODEV)) {
// Device was removed before INotify noticed. // Device was removed before INotify noticed.
ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d " ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d "
"capacity: %d errno: %d)\n", "capacity: %zu errno: %d)\n",
device->fd, readSize, bufferSize, capacity, errno); device->fd, readSize, bufferSize, capacity, errno);
deviceChanged = true; deviceChanged = true;
closeDeviceLocked(device); closeDeviceLocked(device);

View File

@ -147,7 +147,7 @@ static bool validateMotionEvent(int32_t action, size_t pointerCount,
return false; return false;
} }
if (pointerCount < 1 || pointerCount > MAX_POINTERS) { if (pointerCount < 1 || pointerCount > MAX_POINTERS) {
ALOGE("Motion event has invalid pointer count %d; value must be between 1 and %d.", ALOGE("Motion event has invalid pointer count %zu; value must be between 1 and %d.",
pointerCount, MAX_POINTERS); pointerCount, MAX_POINTERS);
return false; return false;
} }
@ -3107,7 +3107,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
dump.append(INDENT "TouchedWindows:\n"); dump.append(INDENT "TouchedWindows:\n");
for (size_t i = 0; i < mTouchState.windows.size(); i++) { for (size_t i = 0; i < mTouchState.windows.size(); i++) {
const TouchedWindow& touchedWindow = mTouchState.windows[i]; const TouchedWindow& touchedWindow = mTouchState.windows[i];
dump.appendFormat(INDENT2 "%d: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n", dump.appendFormat(INDENT2 "%zu: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n",
i, touchedWindow.windowHandle->getName().string(), i, touchedWindow.windowHandle->getName().string(),
touchedWindow.pointerIds.value, touchedWindow.pointerIds.value,
touchedWindow.targetFlags); touchedWindow.targetFlags);
@ -3122,7 +3122,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i); const sp<InputWindowHandle>& windowHandle = mWindowHandles.itemAt(i);
const InputWindowInfo* windowInfo = windowHandle->getInfo(); const InputWindowInfo* windowInfo = windowHandle->getInfo();
dump.appendFormat(INDENT2 "%d: name='%s', displayId=%d, " dump.appendFormat(INDENT2 "%zu: name='%s', displayId=%d, "
"paused=%s, hasFocus=%s, hasWallpaper=%s, " "paused=%s, hasFocus=%s, hasWallpaper=%s, "
"visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, " "visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
"frame=[%d,%d][%d,%d], scale=%f, " "frame=[%d,%d][%d,%d], scale=%f, "
@ -3152,7 +3152,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
dump.append(INDENT "MonitoringChannels:\n"); dump.append(INDENT "MonitoringChannels:\n");
for (size_t i = 0; i < mMonitoringChannels.size(); i++) { for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
const sp<InputChannel>& channel = mMonitoringChannels[i]; const sp<InputChannel>& channel = mMonitoringChannels[i];
dump.appendFormat(INDENT2 "%d: '%s'\n", i, channel->getName().string()); dump.appendFormat(INDENT2 "%zu: '%s'\n", i, channel->getName().string());
} }
} else { } else {
dump.append(INDENT "MonitoringChannels: <none>\n"); dump.append(INDENT "MonitoringChannels: <none>\n");
@ -3201,7 +3201,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
dump.append(INDENT "Connections:\n"); dump.append(INDENT "Connections:\n");
for (size_t i = 0; i < mConnectionsByFd.size(); i++) { for (size_t i = 0; i < mConnectionsByFd.size(); i++) {
const sp<Connection>& connection = mConnectionsByFd.valueAt(i); const sp<Connection>& connection = mConnectionsByFd.valueAt(i);
dump.appendFormat(INDENT2 "%d: channelName='%s', windowName='%s', " dump.appendFormat(INDENT2 "%zu: channelName='%s', windowName='%s', "
"status=%s, monitor=%s, inputPublisherBlocked=%s\n", "status=%s, monitor=%s, inputPublisherBlocked=%s\n",
i, connection->getInputChannelName(), connection->getWindowName(), i, connection->getInputChannelName(), connection->getWindowName(),
connection->getStatusLabel(), toString(connection->monitor), connection->getStatusLabel(), toString(connection->monitor),

View File

@ -1992,7 +1992,7 @@ void KeyboardInputMapper::dump(String8& dump) {
dumpParameters(dump); dumpParameters(dump);
dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType); dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType);
dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation); dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
dump.appendFormat(INDENT3 "KeyDowns: %d keys currently down\n", mKeyDowns.size()); dump.appendFormat(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState); dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
dump.appendFormat(INDENT3 "DownTime: %lld\n", mDownTime); dump.appendFormat(INDENT3 "DownTime: %lld\n", mDownTime);
} }
@ -3372,7 +3372,7 @@ void TouchInputMapper::dumpVirtualKeys(String8& dump) {
for (size_t i = 0; i < mVirtualKeys.size(); i++) { for (size_t i = 0; i < mVirtualKeys.size(); i++) {
const VirtualKey& virtualKey = mVirtualKeys.itemAt(i); const VirtualKey& virtualKey = mVirtualKeys.itemAt(i);
dump.appendFormat(INDENT4 "%d: scanCode=%d, keyCode=%d, " dump.appendFormat(INDENT4 "%zu: scanCode=%d, keyCode=%d, "
"hitLeft=%d, hitRight=%d, hitTop=%d, hitBottom=%d\n", "hitLeft=%d, hitRight=%d, hitTop=%d, hitBottom=%d\n",
i, virtualKey.scanCode, virtualKey.keyCode, i, virtualKey.scanCode, virtualKey.keyCode,
virtualKey.hitLeft, virtualKey.hitRight, virtualKey.hitLeft, virtualKey.hitRight,
@ -6119,8 +6119,8 @@ void MultiTouchInputMapper::configureRawPointerAxes() {
&& mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) { && mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) {
size_t slotCount = mRawPointerAxes.slot.maxValue + 1; size_t slotCount = mRawPointerAxes.slot.maxValue + 1;
if (slotCount > MAX_SLOTS) { if (slotCount > MAX_SLOTS) {
ALOGW("MultiTouch Device %s reported %d slots but the framework " ALOGW("MultiTouch Device %s reported %zu slots but the framework "
"only supports a maximum of %d slots at this time.", "only supports a maximum of %zu slots at this time.",
getDeviceName().string(), slotCount, MAX_SLOTS); getDeviceName().string(), slotCount, MAX_SLOTS);
slotCount = MAX_SLOTS; slotCount = MAX_SLOTS;
} }
@ -6292,7 +6292,7 @@ void JoystickInputMapper::configure(nsecs_t when,
// If there are too many axes, start dropping them. // If there are too many axes, start dropping them.
// Prefer to keep explicitly mapped axes. // Prefer to keep explicitly mapped axes.
if (mAxes.size() > PointerCoords::MAX_AXES) { if (mAxes.size() > PointerCoords::MAX_AXES) {
ALOGI("Joystick '%s' has %d axes but the framework only supports a maximum of %d.", ALOGI("Joystick '%s' has %zu axes but the framework only supports a maximum of %d.",
getDeviceName().string(), mAxes.size(), PointerCoords::MAX_AXES); getDeviceName().string(), mAxes.size(), PointerCoords::MAX_AXES);
pruneAxes(true); pruneAxes(true);
pruneAxes(false); pruneAxes(false);

View File

@ -365,7 +365,9 @@ static void android_server_AlarmManagerService_set(JNIEnv*, jobject, jlong nativ
int result = impl->set(type, &ts); int result = impl->set(type, &ts);
if (result < 0) if (result < 0)
{ {
ALOGE("Unable to set alarm to %lld.%09lld: %s\n", seconds, nanoseconds, strerror(errno)); ALOGE("Unable to set alarm to %lld.%09lld: %s\n",
static_cast<long long>(seconds),
static_cast<long long>(nanoseconds), strerror(errno));
} }
} }