!3956 Modifying Code Alarms

Merge pull request !3956 from hwx1163501/master
This commit is contained in:
openharmony_ci 2023-04-21 03:58:13 +00:00 committed by Gitee
commit f9b145223b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 34 additions and 31 deletions

View File

@ -306,7 +306,7 @@ ElfSecName ElfBuilder::FindLastSection(ElfSecName segment) const
llvm::ELF::Elf64_Word ElfBuilder::FindShName(std::string name, uintptr_t strTabPtr, int strTabSize)
{
llvm::ELF::Elf64_Word ans = -1;
int len = name.size();
int len = static_cast<int>(name.size());
if (strTabSize < len + 1) {
return ans;
}
@ -387,7 +387,7 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
curSecOffset = AlignUp(curSecOffset, TEXT_SEC_ALIGN);
file.seekp(curSecOffset);
}
sectionToFileOffset_[s.first] = file.tellp();
sectionToFileOffset_[s.first] = static_cast<uint8_t>(file.tellp());
file.write(reinterpret_cast<char *>(curSecAddr), curSecSize);
llvm::ELF::Elf64_Word shName = FindShName(secName, strTab.first, strTab.second);
ASSERT(shName != static_cast<llvm::ELF::Elf64_Word>(-1));
@ -411,7 +411,7 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
LOG_COMPILER(DEBUG) << " shdr[i].sh_entsize " << std::hex << shdr[i].sh_entsize << std::endl;
++i;
}
uint32_t secEnd = file.tellp();
uint32_t secEnd = static_cast<uint32_t>(file.tellp());
file.seekp(sizeof(llvm::ELF::Elf64_Ehdr));
file.write(reinterpret_cast<char *>(shdr.get()), secNum * sizeof(llvm::ELF::Elf64_Shdr));
file.seekp(secEnd);
@ -437,7 +437,7 @@ Program Headers:
*/
void ElfBuilder::PackELFSegment(std::ofstream &file)
{
llvm::ELF::Elf64_Off e_phoff = file.tellp();
llvm::ELF::Elf64_Off e_phoff = static_cast<uint64_t>(file.tellp());
long phoff = (long)offsetof(struct llvm::ELF::Elf64_Ehdr, e_phoff);
// write Elf32_Off e_phoff
file.seekp(phoff);

View File

@ -52,7 +52,7 @@ void ElfReader::ParseELFSections(ModuleSectionDes &des, std::vector<ElfSecName>
llvm::ELF::Elf64_Word shName = shdr[i].sh_name;
char *curShName = reinterpret_cast<char *>(addr) + shName + strdr.sh_offset;
if (sectionName.compare(curShName) == 0) {
secId = i;
secId = static_cast<int>(i);
break;
}
}

View File

@ -1311,10 +1311,10 @@ DEF_CALL_SIGNATURE(PGOProfiler)
DEF_CALL_SIGNATURE(PGOTypeProfiler)
{
// 4 : 4 input parameters
// 4: 4 input parameters
CallSignature typeProfInstruction("PGOTypeProfiler", 0, 4, ArgumentsOrder::DEFAULT_ORDER, VariableType::VOID());
*callSign = typeProfInstruction;
// 4 : 4 input parameters
// 4: 4 input parameters
std::array<VariableType, 4> params = {
VariableType::NATIVE_POINTER(),
VariableType::JS_ANY(),

View File

@ -51,8 +51,6 @@ void Module::CollectFuncEntryInfo(std::map<uintptr_t, std::string> &addr2name, S
{
auto engine = assembler_->GetEngine();
auto callSigns = llvmModule_->GetCSigns();
std::map<uintptr_t, int> addr2FpToPrevFrameSpDelta;
std::vector<uint64_t> funSizeVec;
std::vector<uintptr_t> entrys;
for (size_t j = 0; j < llvmModule_->GetFuncCount(); j++) {
LLVMValueRef func = llvmModule_->GetFunction(j);

View File

@ -3958,7 +3958,8 @@ DECLARE_ASM_HANDLER(HandleNewobjrangeImm16Imm8V8)
Bind(&ctorNotBase);
GateRef argv = PtrAdd(sp, PtrMul(
PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM16_IMM8_V8));
GateRef jumpSize =
IntPtr(-static_cast<int64_t>(BytecodeInstruction::Size(BytecodeInstruction::Format::IMM16_IMM8_V8)));
res = JSCallDispatch(glue, ctor, actualNumArgs, jumpSize, hotnessCounter,
JSCallMode::CALL_CONSTRUCTOR_WITH_ARGV,
{ ZExtInt32ToPtr(actualNumArgs), argv, *thisObj }, callback);

View File

@ -416,7 +416,10 @@ static uint32_t GetInstrValue(size_t instrSize, uint8_t *instrAddr)
{
uint32_t value = 0;
if (instrSize <= sizeof(uint32_t)) {
memcpy_s(&value, sizeof(uint32_t), instrAddr, instrSize);
if (memcpy_s(&value, sizeof(uint32_t), instrAddr, instrSize) != EOK) {
LOG_FULL(FATAL) << "memcpy_s failed";
UNREACHABLE();
}
}
return value;
}
@ -479,7 +482,10 @@ static void DecodeDebugInfo(uint64_t addr, uint64_t secIndex, char* outString, s
debugInfo += std::string(">");
size_t len = strlen(outString);
if (len + debugInfo.size() <= outStringSize) {
strcpy_s(outString + len, outStringSize - len, debugInfo.c_str());
if (strcpy_s(outString + len, outStringSize - len, debugInfo.c_str()) != EOK) {
LOG_FULL(FATAL) << "strcpy_s failed";
UNREACHABLE();
}
}
}
}

View File

@ -1291,7 +1291,8 @@ JSHandle<JSTaggedValue> SourceTextModule::ResolveLocalExport(JSThread *thread,
ModuleManager::IsNativeModule(moduleType)) {
// Adapter new module
if (module->GetIsNewBcVersion()) {
return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module, ee->GetLocalIndex()));
return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module,
ee->GetLocalIndex()));
}
// i. Assert: module provides the direct binding for this export.
// ii. Return ResolvedBinding Record { [[Module]]: module, [[BindingName]]: e.[[LocalName]] }.

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -39,7 +39,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -41,7 +41,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -39,12 +39,9 @@ namespace OHOS {
FunctionCallback nativeFunc = FuncRefConCallbackForTest;
Deleter deleter = nullptr;
Local<FunctionRef> func = FunctionRef::New(vm, nativeFunc, deleter, (void *)(data + size));
const int32_t argvLen = 3;
Local<JSValueRef> argv[argvLen];
for (int32_t i = 0; i < argvLen; i++) {
argv[i] = JSValueRef::Undefined(vm);
}
func->Constructor(vm, argv, argvLen);
Local<JSValueRef> argv[1];
argv[0] = NumberRef::New(vm, 1.3); // 1.3 : test case of input
func->Constructor(vm, argv, 1);
JSNApi::DestroyJSVM(vm);
}
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -39,7 +39,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}

View File

@ -40,7 +40,7 @@ namespace OHOS {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}
const int32_t MaxMenory = 1073741824;
const int32_t MaxMenory = 1024;
if (input > MaxMenory) {
input = MaxMenory;
}