Move system/core/ off NO_ERROR.

It causes trouble for Windows, and OK already exists.

Bug: N/A
Test: builds
Change-Id: Ida22fd658b0ebb259c710ba39049b07c9e495d9c
This commit is contained in:
Elliott Hughes 2018-10-08 11:10:11 -07:00
parent f3186de123
commit 643268f325
19 changed files with 83 additions and 86 deletions

View file

@ -70,7 +70,7 @@ status_t BnGateKeeperService::onTransact(
} else {
reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
}
return NO_ERROR;
return OK;
}
case VERIFY: {
CHECK_INTERFACE(IGateKeeperService, data, reply);
@ -102,7 +102,7 @@ status_t BnGateKeeperService::onTransact(
} else {
reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
}
return NO_ERROR;
return OK;
}
case VERIFY_CHALLENGE: {
CHECK_INTERFACE(IGateKeeperService, data, reply);
@ -141,7 +141,7 @@ status_t BnGateKeeperService::onTransact(
} else {
reply->writeInt32(GATEKEEPER_RESPONSE_ERROR);
}
return NO_ERROR;
return OK;
}
case GET_SECURE_USER_ID: {
CHECK_INTERFACE(IGateKeeperService, data, reply);
@ -149,20 +149,20 @@ status_t BnGateKeeperService::onTransact(
uint64_t sid = getSecureUserId(uid);
reply->writeNoException();
reply->writeInt64(sid);
return NO_ERROR;
return OK;
}
case CLEAR_SECURE_USER_ID: {
CHECK_INTERFACE(IGateKeeperService, data, reply);
uint32_t uid = data.readInt32();
clearSecureUserId(uid);
reply->writeNoException();
return NO_ERROR;
return OK;
}
case REPORT_DEVICE_SETUP_COMPLETE: {
CHECK_INTERFACE(IGateKeeperService, data, reply);
reportDeviceSetupComplete();
reply->writeNoException();
return NO_ERROR;
return OK;
}
default:
return BBinder::onTransact(code, data, reply, flags);

View file

@ -386,7 +386,7 @@ public:
write(fd, result, strlen(result) + 1);
}
return NO_ERROR;
return OK;
}
private:

View file

@ -357,7 +357,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryChargeCounterPath);
ret = NO_ERROR;
ret = OK;
} else {
ret = NAME_NOT_FOUND;
}
@ -367,7 +367,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCurrentNowPath);
ret = NO_ERROR;
ret = OK;
} else {
ret = NAME_NOT_FOUND;
}
@ -377,7 +377,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCurrentAvgPath);
ret = NO_ERROR;
ret = OK;
} else {
ret = NAME_NOT_FOUND;
}
@ -387,7 +387,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
if (!mHealthdConfig->batteryCapacityPath.isEmpty()) {
val->valueInt64 =
getIntField(mHealthdConfig->batteryCapacityPath);
ret = NO_ERROR;
ret = OK;
} else {
ret = NAME_NOT_FOUND;
}
@ -403,7 +403,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
case BATTERY_PROP_BATTERY_STATUS:
val->valueInt64 = getChargeStatus();
ret = NO_ERROR;
ret = OK;
break;
default:

View file

@ -171,7 +171,7 @@ int ARMAssembler::generate(const char* name)
}
mAssembly->resize( int(pc()-base())*4 );
// the instruction cache is flushed by CodeCache
const int64_t duration = ggl_system_time() - mDuration;
const char * const format = "generated %s (%d ins) at [%p:%p] in %lld ns\n";
@ -183,8 +183,8 @@ int ARMAssembler::generate(const char* name)
printf(format, name, int(pc()-base()), base(), pc(), duration);
disassemble(name);
}
return NO_ERROR;
return OK;
}
uint32_t* ARMAssembler::pcForLabel(const char* label)
@ -213,14 +213,14 @@ void ARMAssembler::dataProcessing(int opcode, int cc,
// multiply...
void ARMAssembler::MLA(int cc, int s,
int Rd, int Rm, int Rs, int Rn) {
if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
LOG_FATAL_IF(Rd==Rm, "MLA(r%u,r%u,r%u,r%u)", Rd,Rm,Rs,Rn);
*mPC++ = (cc<<28) | (1<<21) | (s<<20) |
(Rd<<16) | (Rn<<12) | (Rs<<8) | 0x90 | Rm;
}
void ARMAssembler::MUL(int cc, int s,
int Rd, int Rm, int Rs) {
if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
if (Rd == Rm) { int t = Rm; Rm=Rs; Rs=t; }
LOG_FATAL_IF(Rd==Rm, "MUL(r%u,r%u,r%u)", Rd,Rm,Rs);
*mPC++ = (cc<<28) | (s<<20) | (Rd<<16) | (Rs<<8) | 0x90 | Rm;
}
@ -577,4 +577,3 @@ uint32_t ARMAssembler::reg_post(int Rm)
}
}; // namespace android

View file

@ -325,7 +325,7 @@ int ArmToArm64Assembler::generate(const char* name)
printf(format, name, int(pc()-base()), base(), pc(), duration);
disassemble(name);
}
return NO_ERROR;
return OK;
}
uint32_t* ArmToArm64Assembler::pcForLabel(const char* label)
@ -1238,4 +1238,3 @@ uint32_t ArmToArm64Assembler::A64_EXTR_W(uint32_t Rd, uint32_t Rn,
}
}; // namespace android

View file

@ -1421,7 +1421,7 @@ int MIPSAssembler::generate(const char* name)
disassemble(name);
}
return NO_ERROR;
return OK;
}
uint32_t* MIPSAssembler::pcForLabel(const char* label)
@ -1953,5 +1953,3 @@ void MIPSAssembler::UNIMPL(void)
}; // namespace android:

View file

@ -158,8 +158,8 @@ enum {
*
* When any camera method returns error, the client can use ping command
* to see if the camera has been taken away by other clients. If the result
* is NO_ERROR, it means the camera hardware is not released. If the result
* is not NO_ERROR, the camera has been released and the existing client
* is OK, it means the camera hardware is not released. If the result
* is not OK, the camera has been released and the existing client
* can silently finish itself or show a dialog.
*/
CAMERA_CMD_PING = 9,

View file

@ -208,7 +208,7 @@ status_t PropertyMap::Parser::parse() {
mTokenizer->nextLine();
}
return NO_ERROR;
return OK;
}
} // namespace android

View file

@ -157,12 +157,12 @@ status_t String16::setTo(const String16& other, size_t len, size_t begin)
if (begin >= N) {
SharedBuffer::bufferFromData(mString)->release();
mString = getEmptyString();
return NO_ERROR;
return OK;
}
if ((begin+len) > N) len = N-begin;
if (begin == 0 && len == N) {
setTo(other);
return NO_ERROR;
return OK;
}
if (&other == this) {
@ -191,7 +191,7 @@ status_t String16::setTo(const char16_t* other, size_t len)
memmove(str, other, len*sizeof(char16_t));
str[len] = 0;
mString = str;
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}
@ -202,9 +202,9 @@ status_t String16::append(const String16& other)
const size_t otherLen = other.size();
if (myLen == 0) {
setTo(other);
return NO_ERROR;
return OK;
} else if (otherLen == 0) {
return NO_ERROR;
return OK;
}
if (myLen >= SIZE_MAX / sizeof(char16_t) - otherLen) {
@ -218,7 +218,7 @@ status_t String16::append(const String16& other)
char16_t* str = (char16_t*)buf->data();
memcpy(str+myLen, other, (otherLen+1)*sizeof(char16_t));
mString = str;
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}
@ -228,9 +228,9 @@ status_t String16::append(const char16_t* chrs, size_t otherLen)
const size_t myLen = size();
if (myLen == 0) {
setTo(chrs, otherLen);
return NO_ERROR;
return OK;
} else if (otherLen == 0) {
return NO_ERROR;
return OK;
}
if (myLen >= SIZE_MAX / sizeof(char16_t) - otherLen) {
@ -245,7 +245,7 @@ status_t String16::append(const char16_t* chrs, size_t otherLen)
memcpy(str+myLen, chrs, otherLen*sizeof(char16_t));
str[myLen+otherLen] = 0;
mString = str;
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}
@ -260,9 +260,9 @@ status_t String16::insert(size_t pos, const char16_t* chrs, size_t len)
const size_t myLen = size();
if (myLen == 0) {
return setTo(chrs, len);
return NO_ERROR;
return OK;
} else if (len == 0) {
return NO_ERROR;
return OK;
}
if (pos > myLen) pos = myLen;
@ -286,7 +286,7 @@ status_t String16::insert(size_t pos, const char16_t* chrs, size_t len)
#if 0
printf("Result (%d chrs): %s\n", size(), String8(*this).string());
#endif
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}
@ -357,7 +357,7 @@ status_t String16::makeLower()
edit[i] = tolower((char)v);
}
}
return NO_ERROR;
return OK;
}
status_t String16::replaceAll(char16_t replaceThis, char16_t withThis)
@ -378,7 +378,7 @@ status_t String16::replaceAll(char16_t replaceThis, char16_t withThis)
edit[i] = withThis;
}
}
return NO_ERROR;
return OK;
}
status_t String16::remove(size_t len, size_t begin)
@ -387,11 +387,11 @@ status_t String16::remove(size_t len, size_t begin)
if (begin >= N) {
SharedBuffer::bufferFromData(mString)->release();
mString = getEmptyString();
return NO_ERROR;
return OK;
}
if ((begin+len) > N) len = N-begin;
if (begin == 0 && len == N) {
return NO_ERROR;
return OK;
}
if (begin > 0) {
@ -410,7 +410,7 @@ status_t String16::remove(size_t len, size_t begin)
char16_t* str = (char16_t*)buf->data();
str[len] = 0;
mString = str;
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}

View file

@ -230,7 +230,7 @@ status_t String8::setTo(const char* other)
const char *newString = allocFromUTF8(other, strlen(other));
SharedBuffer::bufferFromData(mString)->release();
mString = newString;
if (mString) return NO_ERROR;
if (mString) return OK;
mString = getEmptyString();
return NO_MEMORY;
@ -241,7 +241,7 @@ status_t String8::setTo(const char* other, size_t len)
const char *newString = allocFromUTF8(other, len);
SharedBuffer::bufferFromData(mString)->release();
mString = newString;
if (mString) return NO_ERROR;
if (mString) return OK;
mString = getEmptyString();
return NO_MEMORY;
@ -252,7 +252,7 @@ status_t String8::setTo(const char16_t* other, size_t len)
const char *newString = allocFromUTF16(other, len);
SharedBuffer::bufferFromData(mString)->release();
mString = newString;
if (mString) return NO_ERROR;
if (mString) return OK;
mString = getEmptyString();
return NO_MEMORY;
@ -263,7 +263,7 @@ status_t String8::setTo(const char32_t* other, size_t len)
const char *newString = allocFromUTF32(other, len);
SharedBuffer::bufferFromData(mString)->release();
mString = newString;
if (mString) return NO_ERROR;
if (mString) return OK;
mString = getEmptyString();
return NO_MEMORY;
@ -274,9 +274,9 @@ status_t String8::append(const String8& other)
const size_t otherLen = other.bytes();
if (bytes() == 0) {
setTo(other);
return NO_ERROR;
return OK;
} else if (otherLen == 0) {
return NO_ERROR;
return OK;
}
return real_append(other.string(), otherLen);
@ -292,7 +292,7 @@ status_t String8::append(const char* other, size_t otherLen)
if (bytes() == 0) {
return setTo(other, otherLen);
} else if (otherLen == 0) {
return NO_ERROR;
return OK;
}
return real_append(other, otherLen);
@ -311,7 +311,7 @@ status_t String8::appendFormat(const char* fmt, ...)
status_t String8::appendFormatV(const char* fmt, va_list args)
{
int n, result = NO_ERROR;
int n, result = OK;
va_list tmp_args;
/* args is undefined after vsnprintf.
@ -346,7 +346,7 @@ status_t String8::real_append(const char* other, size_t otherLen)
str += myLen;
memcpy(str, other, otherLen);
str[otherLen] = '\0';
return NO_ERROR;
return OK;
}
return NO_MEMORY;
}
@ -382,7 +382,7 @@ status_t String8::unlockBuffer(size_t size)
mString = str;
}
return NO_ERROR;
return OK;
}
ssize_t String8::find(const char* other, size_t start) const

View file

@ -379,7 +379,7 @@ status_t Mutex::lock()
{
DWORD dwWaitResult;
dwWaitResult = WaitForSingleObject((HANDLE) mState, INFINITE);
return dwWaitResult != WAIT_OBJECT_0 ? -1 : NO_ERROR;
return dwWaitResult != WAIT_OBJECT_0 ? -1 : OK;
}
void Mutex::unlock()
@ -506,7 +506,7 @@ typedef struct WinCondition {
ReleaseMutex(condState->internalMutex);
WaitForSingleObject(hMutex, INFINITE);
return res == WAIT_OBJECT_0 ? NO_ERROR : -1;
return res == WAIT_OBJECT_0 ? OK : -1;
}
} WinCondition;
@ -639,13 +639,15 @@ void Condition::broadcast()
*/
Thread::Thread(bool canCallJava)
: mCanCallJava(canCallJava),
mThread(thread_id_t(-1)),
mLock("Thread::mLock"),
mStatus(NO_ERROR),
mExitPending(false), mRunning(false)
: mCanCallJava(canCallJava),
mThread(thread_id_t(-1)),
mLock("Thread::mLock"),
mStatus(OK),
mExitPending(false),
mRunning(false)
#if defined(__ANDROID__)
, mTid(-1)
,
mTid(-1)
#endif
{
}
@ -656,7 +658,7 @@ Thread::~Thread()
status_t Thread::readyToRun()
{
return NO_ERROR;
return OK;
}
status_t Thread::run(const char* name, int32_t priority, size_t stack)
@ -672,7 +674,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
// reset status and exitPending to their default value, so we can
// try again after an error happened (either below, or in readyToRun())
mStatus = NO_ERROR;
mStatus = OK;
mExitPending = false;
mThread = thread_id_t(-1);
@ -700,10 +702,10 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
}
// Do not refer to mStatus here: The thread is already running (may, in fact
// already have exited with a valid mStatus result). The NO_ERROR indication
// already have exited with a valid mStatus result). The OK indication
// here merely indicates successfully starting the thread and does not
// imply successful termination/execution.
return NO_ERROR;
return OK;
// Exiting scope of mLock is a memory barrier and allows new thread to run
}
@ -728,7 +730,7 @@ int Thread::_threadLoop(void* user)
if (first) {
first = false;
self->mStatus = self->readyToRun();
result = (self->mStatus == NO_ERROR);
result = (self->mStatus == OK);
if (result && !self->exitPending()) {
// Binder threads (and maybe others) rely on threadLoop

View file

@ -48,7 +48,7 @@ Tokenizer::~Tokenizer() {
status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
*outTokenizer = nullptr;
int result = NO_ERROR;
int result = OK;
int fd = ::open(filename.string(), O_RDONLY);
if (fd < 0) {
result = -errno;

View file

@ -61,7 +61,7 @@ VectorImpl::~VectorImpl()
"[%p] subclasses of VectorImpl must call finish_vector()"
" in their destructor. Leaking %d bytes.",
this, (int)(mCount*mItemSize));
// We can't call _do_destroy() here because the vtable is already gone.
// We can't call _do_destroy() here because the vtable is already gone.
}
VectorImpl& VectorImpl::operator = (const VectorImpl& rhs)
@ -197,7 +197,7 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state)
_do_copy(temp, item, 1);
ssize_t j = i-1;
void* next = reinterpret_cast<char*>(array) + mItemSize*(i);
void* next = reinterpret_cast<char*>(array) + mItemSize*(i);
do {
_do_destroy(next, 1);
_do_copy(next, curr, 1);
@ -214,13 +214,13 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state)
}
i++;
}
if (temp) {
_do_destroy(temp, 1);
free(temp);
}
}
return NO_ERROR;
return OK;
}
void VectorImpl::pop()
@ -354,7 +354,7 @@ ssize_t VectorImpl::setCapacity(size_t new_capacity)
}
ssize_t VectorImpl::resize(size_t size) {
ssize_t result = NO_ERROR;
ssize_t result = OK;
if (size > mCount) {
result = insertAt(mCount, size - mCount);
} else if (size < mCount) {
@ -370,7 +370,7 @@ void VectorImpl::release_storage()
if (sb->release(SharedBuffer::eKeepStorage) == 1) {
_do_destroy(mStorage, mCount);
SharedBuffer::dealloc(sb);
}
}
}
}
@ -644,13 +644,13 @@ ssize_t SortedVectorImpl::merge(const VectorImpl& vector)
}
}
}
return NO_ERROR;
return OK;
}
ssize_t SortedVectorImpl::merge(const SortedVectorImpl& vector)
{
// we've merging a sorted vector... nice!
ssize_t err = NO_ERROR;
ssize_t err = OK;
if (!vector.isEmpty()) {
// first take care of the case where the vectors are sorted together
if (do_compare(vector.itemLocation(vector.size()-1), arrayImpl()) <= 0) {
@ -677,4 +677,3 @@ ssize_t SortedVectorImpl::remove(const void* item)
/*****************************************************************************/
}; // namespace android

View file

@ -43,8 +43,8 @@ typedef int32_t status_t;
#endif
enum {
OK = 0, // Everything's swell.
NO_ERROR = 0, // No errors.
OK = 0, // Preferred constant for checking success.
NO_ERROR = OK, // Deprecated synonym for `OK`. Prefer `OK` because it doesn't conflict with Windows.
UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value

View file

@ -190,11 +190,11 @@ public:
inline status_t flatten(void* buffer, size_t size) const {
if (size < sizeof(T)) return NO_MEMORY;
memcpy(buffer, static_cast<T const*>(this), sizeof(T));
return NO_ERROR;
return OK;
}
inline status_t unflatten(void const* buffer, size_t) {
memcpy(static_cast<T*>(this), buffer, sizeof(T));
return NO_ERROR;
return OK;
}
};

View file

@ -29,7 +29,7 @@ class Functor {
public:
Functor() {}
virtual ~Functor() {}
virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; }
virtual status_t operator()(int /*what*/, void* /*data*/) { return OK; }
};
} // namespace android

View file

@ -37,7 +37,7 @@ public:
/**
* Opens a file and maps it into memory.
*
* Returns NO_ERROR and a tokenizer for the file, if successful.
* Returns OK and a tokenizer for the file, if successful.
* Otherwise returns an error and sets outTokenizer to NULL.
*/
static status_t open(const String8& filename, Tokenizer** outTokenizer);
@ -45,7 +45,7 @@ public:
/**
* Prepares to tokenize the contents of a string.
*
* Returns NO_ERROR and a tokenizer for the string, if successful.
* Returns OK and a tokenizer for the string, if successful.
* Otherwise returns an error and sets outTokenizer to NULL.
*/
static status_t fromContents(const String8& filename,

View file

@ -161,7 +161,7 @@ status_t StoragedService::dump(int fd, const Vector<String16>& args) {
storaged_sp->update_uid_io_interval(time_window);
}
return NO_ERROR;
return OK;
}
binder::Status StoragedService::onUserStarted(int32_t userId) {

View file

@ -32,7 +32,7 @@ status_t UidInfo::writeToParcel(Parcel* parcel) const {
parcel->writeCString(task_it.second.comm.c_str());
parcel->write(&task_it.second.io, sizeof(task_it.second.io));
}
return NO_ERROR;
return OK;
}
status_t UidInfo::readFromParcel(const Parcel* parcel) {
@ -48,5 +48,5 @@ status_t UidInfo::readFromParcel(const Parcel* parcel) {
parcel->read(&task.io, sizeof(task.io));
tasks[task.pid] = task;
}
return NO_ERROR;
return OK;
}