Modifying Code Alarms

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7LOU0
This commit is contained in:
hwx1163501 2023-07-17 15:37:07 +08:00
parent b70208ed53
commit 2785546c22
8 changed files with 25 additions and 24 deletions

View File

@ -160,7 +160,7 @@ JSTaggedValue BuiltinsAggregateError::AggregateErrorConstructor(EcmaRuntimeCallI
JSTaggedValue::DefinePropertyOrThrow(thread, taggedObj, msgKey, msgDesc); JSTaggedValue::DefinePropertyOrThrow(thread, taggedObj, msgKey, msgDesc);
} }
// InstallErrorCause // InstallErrorCause
JSHandle<JSTaggedValue> options = BuiltinsBase::GetCallArg(argv, 2); JSHandle<JSTaggedValue> options = BuiltinsBase::GetCallArg(argv, 2); // 2 : Third parameter
// If options is an Object and ? HasProperty(options, "cause") is true, then // If options is an Object and ? HasProperty(options, "cause") is true, then
// a. Let cause be ? Get(options, "cause"). // a. Let cause be ? Get(options, "cause").
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause). // b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause).

View File

@ -1624,7 +1624,7 @@ JSTaggedValue BuiltinsTypedArray::At(EcmaRuntimeCallInfo *argv)
int64_t k = 0; int64_t k = 0;
// 5. If relativeIndex ≥ 0, then Let k be relativeIndex. // 5. If relativeIndex ≥ 0, then Let k be relativeIndex.
// 6. Else, Let k be len + relativeIndex. // 6. Else, Let k be len + relativeIndex.
k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; k = relativeIndex >= 0 ? relativeIndex : static_cast<int64_t>(len) + relativeIndex;
// 7. If k < 0 or k ≥ len, return undefined. // 7. If k < 0 or k ≥ len, return undefined.
if (k < 0 || k >= len) { if (k < 0 || k >= len) {
return JSTaggedValue::Undefined(); return JSTaggedValue::Undefined();

View File

@ -59,7 +59,7 @@ void PGOBCInfo::Record(const InfoDetail &detail, Type type)
} }
void PGOBCInfo::Record(const BytecodeInstruction &bcIns, int32_t bcIndex, void PGOBCInfo::Record(const BytecodeInstruction &bcIns, int32_t bcIndex,
const CString &recordName, const MethodLiteral *method) const CString &recordName, const MethodLiteral *method)
{ {
BytecodeInstruction::Opcode opcode = static_cast<BytecodeInstruction::Opcode>(bcIns.GetOpcode()); BytecodeInstruction::Opcode opcode = static_cast<BytecodeInstruction::Opcode>(bcIns.GetOpcode());
uint32_t methodOffset = method->GetMethodId().GetOffset(); uint32_t methodOffset = method->GetMethodId().GetOffset();

View File

@ -662,12 +662,12 @@ bool SamplesRecord::PushNapiStackInfo(const FrameInfoTemp &frameInfoTemp)
std::string SamplesRecord::GetModuleName(char *recordName) std::string SamplesRecord::GetModuleName(char *recordName)
{ {
std::string recordNameStr = recordName; std::string recordNameStr = recordName;
int atPos = recordNameStr.find("@"); std::string::size_type atPos = recordNameStr.find("@");
if (atPos == std::string::npos) { if (atPos == std::string::npos) {
return ""; return "";
} }
int slashPos = recordNameStr.rfind("/", atPos); std::string::size_type slashPos = recordNameStr.rfind("/", atPos);
if (slashPos == std::string::npos) { if (slashPos == std::string::npos) {
return ""; return "";
} }

View File

@ -678,7 +678,7 @@ JSTaggedValue JSStableArray::At(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo
if (relativeIndex >= 0) { if (relativeIndex >= 0) {
k = relativeIndex; k = relativeIndex;
} else { } else {
k = thisLen + relativeIndex; k = static_cast<int64_t>(thisLen) + relativeIndex;
} }
if (k < 0 || k >= thisLen) { if (k < 0 || k >= thisLen) {
return JSTaggedValue::Undefined(); return JSTaggedValue::Undefined();

View File

@ -129,7 +129,7 @@ void PGOProfilerEncoder::AddChecksum(std::fstream &fileStream)
static constexpr uint32_t KILO_BYTES = 1024; static constexpr uint32_t KILO_BYTES = 1024;
static constexpr uint32_t STEP_IN_KB = 256; static constexpr uint32_t STEP_IN_KB = 256;
static constexpr uint32_t STEP_SIZE = STEP_IN_KB * KILO_BYTES; static constexpr uint32_t STEP_SIZE = STEP_IN_KB * KILO_BYTES;
uint32_t size = fileStream.seekp(0, std::fstream::end).tellp(); uint32_t size = static_cast<uint32_t>(fileStream.seekp(0, std::fstream::end).tellp());
std::unique_ptr<std::vector<uint8_t>> buffer = std::make_unique<std::vector<uint8_t>>(STEP_SIZE); std::unique_ptr<std::vector<uint8_t>> buffer = std::make_unique<std::vector<uint8_t>>(STEP_SIZE);
// first, calculate the version field's checksum. // first, calculate the version field's checksum.
fileStream.seekg(PGOProfilerHeader::MAGIC_SIZE, std::fstream::beg) fileStream.seekg(PGOProfilerHeader::MAGIC_SIZE, std::fstream::beg)

View File

@ -1152,7 +1152,8 @@ bool PGORecordDetailInfos::ProcessToBinaryForLayout(
} }
secInfo.offset_ = sizeof(SectionInfo); secInfo.offset_ = sizeof(SectionInfo);
secInfo.size_ = static_cast<uint32_t>(stream.tellp()) - layoutBeginPosition - sizeof(SectionInfo); secInfo.size_ = static_cast<uint32_t>(stream.tellp()) -
static_cast<uint32_t>(layoutBeginPosition) - sizeof(SectionInfo);
stream.seekp(layoutBeginPosition, std::ofstream::beg) stream.seekp(layoutBeginPosition, std::ofstream::beg)
.write(reinterpret_cast<char *>(&secInfo), sizeof(SectionInfo)) .write(reinterpret_cast<char *>(&secInfo), sizeof(SectionInfo))
.seekp(0, std::ofstream::end); .seekp(0, std::ofstream::end);

View File

@ -27,27 +27,27 @@ function advance(bodies, dt) {
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
const bodyi = bodies[i]; const bodyi = bodies[i];
let vxi = bodyi.vx; let vxi = bodyi.vx;
const xi = bodyi.x; const xi = bodyi.x;
const massi = bodyi.mass; const massi = bodyi.mass;
for (let j = i + 1; j < size; j++) { for (let j = i + 1; j < size; j++) {
const bodyj = bodies[j]; const bodyj = bodies[j];
const dx = xi - bodyj.x; const dx = xi - bodyj.x;
const d2 = dx * dx; const d2 = dx * dx;
const mag = dt / (d2 * sqrt(d2)); const mag = dt / (d2 * sqrt(d2));
const massiMag = massi * mag; const massiMag = massi * mag;
const massj = bodyj.mass; const massj = bodyj.mass;
const massjMag = massj * mag; const massjMag = massj * mag;
vxi -= dx * massjMag; vxi -= dx * massjMag;
bodyj.vx += dx * massiMag; bodyj.vx += dx * massiMag;
} }
bodyi.vx = vxi; bodyi.vx = vxi;
bodyi.x += dt * vxi; bodyi.x += dt * vxi;
} }
} }