Code alarm cleaning

issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5SJ3B

Signed-off-by: Berlinnerly <zhouwenxuan1@huawei.com>
This commit is contained in:
Berlinnerly 2022-09-23 08:44:11 +08:00
parent 1386e8435d
commit 8225a613ba
24 changed files with 44 additions and 51 deletions

View File

@ -20,7 +20,6 @@
#include "ecmascript/ecma_runtime_call_info.h"
namespace panda::ecmascript::builtins {
using JSTaggedValue = JSTaggedValue;
class BuiltinsJson : public base::BuiltinsBase {
public:

View File

@ -469,7 +469,7 @@ JSTaggedValue BuiltinsString::Includes(EcmaRuntimeCallInfo *argv)
u16strSearch = base::StringHelper::Utf8ToU16String(uint8Search, searchLen);
}
uint32_t idx = base::StringHelper::Find(u16strThis, u16strSearch, start);
if (idx < 0 || idx > thisLen) {
if (idx > thisLen) {
return BuiltinsString::GetTaggedBoolean(false);
}
return BuiltinsString::GetTaggedBoolean(true);
@ -552,7 +552,7 @@ JSTaggedValue BuiltinsString::LastIndexOf(EcmaRuntimeCallInfo *argv)
u16strSearch = base::StringHelper::Utf8ToU16String(uint8Search, searchLen);
}
uint32_t res = base::StringHelper::RFind(u16strThis, u16strSearch, pos);
if (res >= 0 && res < thisLen) {
if (res < thisLen) {
return GetTaggedInt(res);
}
res = -1;

View File

@ -1378,7 +1378,7 @@ JSTaggedValue BuiltinsTypedArray::Sort(EcmaRuntimeCallInfo *argv)
compareResult > 0 ? (endIndex = middleIndex) : (beginIndex = middleIndex + 1);
}
if (endIndex >= 0 && endIndex < i) {
if (endIndex < i) {
for (uint32_t j = i; j > endIndex; j--) {
key2.Update(JSTaggedValue(j - 1));
previousValue.Update(

View File

@ -248,7 +248,7 @@ uint32_t AssemblerAarch64::GetOpcFromScale(Scale scale, bool ispair)
opc = ispair ? 0 : 1;
break;
case Scale::D:
opc = ispair ? 1 : 1;
opc = 1;
break;
case Scale::Q:
// 3 : means opc bit is 11

View File

@ -791,13 +791,15 @@ void Environment::SubCfgEntry(Label *entry)
void Environment::SubCfgExit()
{
GateRef control = currentLabel_->GetControl();
GateRef depend = currentLabel_->GetDepend();
if (!stack_.empty()) {
currentLabel_ = stack_.top();
currentLabel_->SetControl(control);
currentLabel_->SetDepend(depend);
stack_.pop();
if (currentLabel_ != nullptr) {
GateRef control = currentLabel_->GetControl();
GateRef depend = currentLabel_->GetDepend();
if (!stack_.empty()) {
currentLabel_ = stack_.top();
currentLabel_->SetControl(control);
currentLabel_->SetDepend(depend);
stack_.pop();
}
}
}

View File

@ -29,7 +29,10 @@ public:
GateRef operator*() const
{
return circuit_->GetGateRef(out_->GetGateConst());
if (out_ != nullptr) {
return circuit_->GetGateRef(out_->GetGateConst());
}
return 0;
}
const ConstUseIterator operator++()
@ -82,7 +85,10 @@ public:
GateRef operator*() const
{
return circuit_->GetGateRef(out_->GetGate());
if (out_ != nullptr) {
return circuit_->GetGateRef(out_->GetGate());
}
return 0;
}
const UseIterator& operator++()

View File

@ -325,7 +325,6 @@ std::optional<std::unordered_map<GateRef, size_t>> Scheduler::CalculateSchedulin
GateAccessor acc(const_cast<Circuit*>(circuit));
std::unordered_map<GateRef, size_t> lowerBound;
std::unordered_map<GateRef, size_t> useCount;
std::deque<GateRef> pendingList;
std::vector<GateRef> bbAndFixedGatesList;
for (const auto &item : bbGatesAddrToIdx) {
bbAndFixedGatesList.push_back(item.first);

View File

@ -1855,11 +1855,7 @@ void SlowPathLowering::LowerSuperCallSpread(GateRef gate, GateRef glue, GateRef
void SlowPathLowering::LowerIsTrueOrFalse(GateRef gate, GateRef glue, bool flag)
{
if (flag) {
DebugPrintBC(gate, glue);
} else {
DebugPrintBC(gate, glue);
}
DebugPrintBC(gate, glue);
Label isTrue(&builder_);
Label isFalse(&builder_);
Label successExit(&builder_);

View File

@ -648,7 +648,7 @@ JSTaggedValue ContainersVector::Sort(EcmaRuntimeCallInfo *argv)
}
}
if (endIndex >= 0 && endIndex < i) {
if (endIndex < i) {
for (uint32_t j = i; j > endIndex; j--) {
previousValue.Update(elements->Get(j - 1));
elements->Set(thread, j, previousValue.GetTaggedValue());

View File

@ -316,7 +316,10 @@ bool CpuProfiler::ParseMethodInfo(Method *method, FrameHandler &frameHandler, bo
if (!CheckAndCopy(codeEntry.codeType, sizeof(codeEntry.codeType), "JS")) {
return false;
}
const char *tempVariable = method->GetMethodName();
const char *tempVariable = nullptr;
if (method != nullptr) {
tempVariable = method->GetMethodName();
}
uint8_t length = strlen(tempVariable);
if (length != 0 && tempVariable[0] == '#') {
uint8_t index = length - 1;

View File

@ -63,14 +63,14 @@ void ModuleSectionDes::SaveSectionsInfo(std::ofstream &file)
void ModuleSectionDes::LoadStackMapSection(BinaryBufferParser &parser, uintptr_t secBegin, uint32_t &curUnitOffset)
{
uint32_t size;
uint32_t size = 0;
parser.ParseBuffer(&size, sizeof(size));
parser.ParseBuffer(reinterpret_cast<void *>(secBegin), size);
SetArkStackMapSize(size);
SetArkStackMapPtr(reinterpret_cast<uint8_t *>(secBegin));
curUnitOffset += size;
uint32_t index;
uint32_t cnt;
uint32_t index = 0;
uint32_t cnt = 0;
parser.ParseBuffer(&index, sizeof(index));
parser.ParseBuffer(&cnt, sizeof(cnt));
SetStartIndex(index);
@ -80,14 +80,14 @@ void ModuleSectionDes::LoadStackMapSection(BinaryBufferParser &parser, uintptr_t
void ModuleSectionDes::LoadSectionsInfo(BinaryBufferParser &parser,
uint32_t &curUnitOffset, uint64_t codeAddress)
{
uint32_t secInfoSize;
uint32_t secInfoSize = 0;
parser.ParseBuffer(&secInfoSize, sizeof(secInfoSize));
auto secBegin = codeAddress + static_cast<uintptr_t>(curUnitOffset);
for (uint8_t i = 0; i < secInfoSize; i++) {
uint8_t secName;
uint8_t secName = 0;
parser.ParseBuffer(&secName, sizeof(secName));
auto secEnumName = static_cast<ElfSecName>(secName);
uint32_t secSize;
uint32_t secSize = 0;
parser.ParseBuffer(&secSize, sizeof(secSize));
SetSecSize(secSize, secEnumName);
parser.ParseBuffer(reinterpret_cast<void *>(secBegin), secSize);
@ -181,7 +181,7 @@ bool StubModulePackInfo::Load(EcmaVM *vm)
vm->GetFileLoader()->SetStubmmap(pool.GetMem(), pool.GetSize());
uint64_t codeAddress = reinterpret_cast<uint64_t>(pool.GetMem());
uint32_t curUnitOffset = 0;
uint32_t asmStubSize;
uint32_t asmStubSize = 0;
binBufparser.ParseBuffer(&asmStubSize, sizeof(asmStubSize));
SetAsmStubSize(asmStubSize);
binBufparser.ParseBuffer(reinterpret_cast<void *>(codeAddress), asmStubSize);

View File

@ -430,7 +430,6 @@ ARK_INLINE void AsmInterpretedFrame::GCIterate(const FrameIterator &it,
visitor(Root::ROOT_FRAME, ObjectSlot(ToUintPtr(&frame->env)));
}
std::set<uintptr_t> slotAddrs;
bool ret = it.IteratorStackMap(visitor, derivedVisitor);
if (!ret) {
#ifndef NDEBUG

View File

@ -260,7 +260,7 @@ bool JSAPILightWeightSet::Equal(JSThread *thread, const JSHandle<JSAPILightWeigh
bool result = false;
JSHandle<TaggedArray> destHashes(thread, obj->GetHashes());
uint32_t destSize = obj->GetLength();
uint32_t srcSize;
uint32_t srcSize = 0;
JSMutableHandle<TaggedArray> srcHashes(thread, obj->GetHashes());
if (value.GetTaggedValue().IsJSAPILightWeightSet()) {
JSAPILightWeightSet *srcLightWeightSet = JSAPILightWeightSet::Cast(value.GetTaggedValue().GetTaggedObject());

View File

@ -166,7 +166,7 @@ bool JSAPIQueue::GetOwnProperty(JSThread *thread, const JSHandle<JSAPIQueue> &ob
}
uint32_t length = obj->GetLength().GetArrayLength();
if (index < 0 || index >= length) {
if (index >= length) {
THROW_RANGE_ERROR_AND_RETURN(thread, "GetOwnProperty index out-of-bounds", false);
}

View File

@ -1106,7 +1106,7 @@ std::vector<IcuPatternDesc> InitializePattern(const IcuPatternDesc &hourData)
} else {
result.emplace_back(hourData);
}
item++;
++item;
}
return result;
}

View File

@ -225,6 +225,7 @@ public:
void Update(JSTaggedValue value)
{
auto addr = reinterpret_cast<JSTaggedValue *>(this->GetAddress());
ASSERT(addr != nullptr);
*addr = value;
}

View File

@ -147,7 +147,6 @@ JSHandle<NameDictionary> JSObject::TransitionToDictionary(const JSThread *thread
ASSERT(!jshclass->IsDictionaryMode());
uint32_t propNumber = jshclass->NumberOfProps();
ASSERT(propNumber >= 0);
ASSERT(!jshclass->GetLayout().IsNull());
JSHandle<LayoutInfo> layoutInfoHandle(thread, jshclass->GetLayout());
ASSERT(layoutInfoHandle->GetLength() != 0);

View File

@ -38,12 +38,6 @@ void BlockSignals()
LOG_ECMA(ERROR) << "sigemptyset failed";
return;
}
int rc = 0;
if (rc < 0) {
LOG_ECMA(ERROR) << "sigaddset failed";
return;
}
#endif // PANDA_TARGET_UNIX
}

View File

@ -240,6 +240,7 @@ TaggedObject *Heap::AllocateClassClass(JSHClass *hclass, size_t size)
auto object = reinterpret_cast<TaggedObject *>(nonMovableSpace_->Allocate(size));
if (UNLIKELY(object == nullptr)) {
LOG_ECMA_MEM(FATAL) << "Heap::AllocateClassClass can not allocate any space";
UNREACHABLE();
}
*reinterpret_cast<MarkWordType *>(ToUintPtr(object)) = reinterpret_cast<MarkWordType>(hclass);
OnAllocateEvent(reinterpret_cast<TaggedObject*>(object));

View File

@ -120,7 +120,7 @@ private:
class Callback {
public:
static ecmascript::JSTaggedValue RegisterCallback(ecmascript::EcmaRuntimeCallInfo *info);
static ecmascript::JSTaggedValue RegisterCallback(ecmascript::EcmaRuntimeCallInfo *ecmaRuntimeCallInfo);
};
} // namespace panda
#endif // ECMASCRIPT_NAPI_JSNAPI_HELPER_H

View File

@ -39,12 +39,6 @@ void BlockSignals()
LOG_ECMA(ERROR) << "sigemptyset failed";
return;
}
int rc = 0;
if (rc < 0) {
LOG_ECMA(ERROR) << "sigaddset failed";
return;
}
#endif // PANDA_TARGET_UNIX
}
@ -89,7 +83,6 @@ int Main(const int argc, const char **argv)
std::cout << "\n"
<< "Startup start time: " << startTime << std::endl;
}
bool ret = true;
EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions);
if (vm == nullptr) {
std::cerr << "Cannot Create vm" << std::endl;
@ -172,7 +165,7 @@ int Main(const int argc, const char **argv)
}
JSNApi::DestroyJSVM(vm);
return ret ? 0 : -1;
return 0;
}
} // namespace panda::ecmascript

View File

@ -368,7 +368,7 @@ void RegExpExecutor::ReAllocStack(uint32_t stackLen)
UNREACHABLE();
}
if (stateStack_ != nullptr) {
size_t stackSize = stateStackSize_ * stateSize_;
auto stackSize = stateStackSize_ * stateSize_;
if (memcpy_s(newStack, stackSize, stateStack_, stackSize) != EOK) {
return;
}

View File

@ -1235,6 +1235,7 @@ void SnapshotProcessor::DeserializeString(uintptr_t stringBegin, uintptr_t strin
}
if (newObj == 0) {
LOG_ECMA_MEM(FATAL) << "Snapshot Allocate OldLocalSpace OOM";
UNREACHABLE();
}
if (memcpy_s(ToVoidPtr(newObj), strSize, str, strSize) != EOK) {
LOG_FULL(FATAL) << "memcpy_s failed";

View File

@ -73,7 +73,7 @@ public:
return TaggedArray::Get(idxInArray);
}
void SetKey(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &typeId);
void SetKey(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &typeIdVal);
inline uint32_t GetLength() const
{