Fixed some errors detected by PVS Studio

This commit is contained in:
Dávid Bolvanský 2021-10-09 17:19:53 +02:00
parent ea12adc169
commit 3649fb14d1
7 changed files with 5 additions and 16 deletions

View File

@ -662,7 +662,7 @@ RTLIB::Libcall RTLIB::getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize) {
/// InitCmpLibcallCCs - Set default comparison libcall CC.
static void InitCmpLibcallCCs(ISD::CondCode *CCs) {
memset(CCs, ISD::SETCC_INVALID, sizeof(ISD::CondCode)*RTLIB::UNKNOWN_LIBCALL);
std::fill(CCs, CCs + RTLIB::UNKNOWN_LIBCALL, ISD::SETCC_INVALID);
CCs[RTLIB::OEQ_F32] = ISD::SETEQ;
CCs[RTLIB::OEQ_F64] = ISD::SETEQ;
CCs[RTLIB::OEQ_F128] = ISD::SETEQ;

View File

@ -334,8 +334,6 @@ static uint16_t toSecMapFlags(uint32_t Flags) {
Ret |= static_cast<uint16_t>(OMFSegDescFlags::Write);
if (Flags & COFF::IMAGE_SCN_MEM_EXECUTE)
Ret |= static_cast<uint16_t>(OMFSegDescFlags::Execute);
if (Flags & COFF::IMAGE_SCN_MEM_EXECUTE)
Ret |= static_cast<uint16_t>(OMFSegDescFlags::Execute);
if (!(Flags & COFF::IMAGE_SCN_MEM_16BIT))
Ret |= static_cast<uint16_t>(OMFSegDescFlags::AddressIs32Bit);

View File

@ -664,7 +664,7 @@ EHFrameEdgeFixer::readEncodedPointer(uint8_t PointerEncoding,
EffectiveType = (PointerSize == 8) ? DW_EH_PE_udata8 : DW_EH_PE_udata4;
JITTargetAddress Addr;
Edge::Kind PointerEdgeKind;
Edge::Kind PointerEdgeKind == Edge::Invalid;
switch (EffectiveType) {
case DW_EH_PE_udata4: {
uint32_t Val;

View File

@ -1380,9 +1380,6 @@ void ELFState<ELFT>::writeSectionContent(
if (!Section.Entries)
return;
if (!Section.Entries)
return;
for (const ELFYAML::StackSizeEntry &E : *Section.Entries) {
CBA.write<uintX_t>(E.Address, ELFT::TargetEndianness);
SHeader.sh_size += sizeof(uintX_t) + CBA.writeULEB128(E.Size);
@ -1488,9 +1485,6 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
if (!Section.Bucket)
return;
if (!Section.Bucket)
return;
CBA.write<uint32_t>(
Section.NBucket.getValueOr(llvm::yaml::Hex64(Section.Bucket->size())),
ELFT::TargetEndianness);
@ -1663,9 +1657,6 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
if (!Section.Symbols)
return;
if (!Section.Symbols)
return;
for (StringRef Sym : *Section.Symbols)
SHeader.sh_size +=
CBA.writeULEB128(toSymbolIndex(Sym, Section.Name, /*IsDynamic=*/false));

View File

@ -185,7 +185,7 @@ raw_ostream &raw_ostream::write_escaped(StringRef Str,
// Write out the escaped representation.
if (UseHexEscapes) {
*this << '\\' << 'x';
*this << hexdigit((c >> 4 & 0xF));
*this << hexdigit((c >> 4) & 0xF);
*this << hexdigit((c >> 0) & 0xF);
} else {
// Always use a full 3-character octal escape.

View File

@ -190,7 +190,7 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
SledEntry::FunctionKinds::TAIL,
SledEntry::FunctionKinds::LOG_ARGS_ENTER,
SledEntry::FunctionKinds::CUSTOM_EVENT};
if (Kind >= sizeof(Kinds))
if (Kind >= sizeof(Kinds) / sizeof(Kinds[0]))
return errorCodeToError(
std::make_error_code(std::errc::executable_format_error));
Entry.Kind = Kinds[Kind];

View File

@ -1024,7 +1024,7 @@ int main(int argc, char **argv) {
Timers = ShowTimes ? std::make_unique<RTDyldTimers>() : nullptr;
int Result;
int Result = 0;
switch (Action) {
case AC_Execute:
Result = executeInput();