Re: [DynInst_API:] [RFC PATCH] Cleanup warnings


Date: Thu, 28 Apr 2016 21:02:31 +0000
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] [RFC PATCH] Cleanup warnings
I'll give this one a more detailed look tomorrow. Unused params in temporary stubs are fine to silence via anonymizing parameters; unused error codes need good handling. And I'm mostly okay with comparisons that can't fail when they're making the facts being asserted more legible.

I really need to check the dead code in context and make sure we're not missing functionality in a stupid way, too.
________________________________________
From: Dyninst-api <dyninst-api-bounces@xxxxxxxxxxx> on behalf of Peter Foley <pefoley2@xxxxxxxxxxx>
Sent: Thursday, April 28, 2016 9:18:02 AM
To: dyninst-api@xxxxxxxxxxx
Subject: [DynInst_API:] [RFC PATCH] Cleanup warnings

Fix a bunch of misc warnings.

[  8%] Building CXX object common/CMakeFiles/common.dir/src/arch-aarch64.C.o
/home/peter/dyninst/common/src/arch-aarch64.C:111:45: warning: unused parameter ‘ptr’ [-Wunused-parameter]
 void instruction::setInstruction(codeBuf_t *ptr, Address) {
                                             ^
/home/peter/dyninst/common/src/arch-aarch64.C:143:40: warning: unused parameter ‘from’ [-Wunused-parameter]
 unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) {
                                        ^
/home/peter/dyninst/common/src/arch-aarch64.C:143:54: warning: unused parameter ‘to’ [-Wunused-parameter]
 unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) {
                                                      ^
/home/peter/dyninst/common/src/arch-aarch64.C:143:67: warning: unused parameter ‘addr_width’ [-Wunused-parameter]
 unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) {
                                                                   ^
/home/peter/dyninst/common/src/arch-aarch64.C:149:40: warning: unused parameter ‘disp’ [-Wunused-parameter]
 unsigned instruction::jumpSize(Address disp, unsigned addr_width) {
                                        ^
/home/peter/dyninst/common/src/arch-aarch64.C:149:55: warning: unused parameter ‘addr_width’ [-Wunused-parameter]
 unsigned instruction::jumpSize(Address disp, unsigned addr_width) {
                                                       ^
In file included from /home/peter/dyninst/common/h/dyn_regs.h:38:0,
                 from /home/peter/dyninst/common/h/dyntypes.h:170,
                 from /home/peter/dyninst/common/src/Types.h:168,
                 from /home/peter/dyninst/common/src/arch-aarch64.C:31:
/home/peter/dyninst/common/src/arch-aarch64.C: In member function ‘unsigned int NS_aarch64::instruction::getBranchTargetReg() const’:
/home/peter/dyninst/common/src/arch-aarch64.C:204:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
         assert( regNum >= 0 || regNum <= 30);
                        ^
[ 14%] Building CXX object symtabAPI/CMakeFiles/symtabAPI.dir/src/Function.C.o
/home/peter/dyninst/symtabAPI/src/Function.C:54:36: warning: unused parameter ‘sym’ [-Wunused-parameter]
 FunctionBase::FunctionBase(Symbol *sym) :
                                    ^
/home/peter/dyninst/symtabAPI/src/Function.C:76:36: warning: unused parameter ‘m’ [-Wunused-parameter]
 FunctionBase::FunctionBase(Module *m) :
                                    ^
/home/peter/dyninst/symtabAPI/src/Function.C:475:61: warning: unused parameter ‘isPrimary’ [-Wunused-parameter]
 bool InlinedFunction::addMangledName(std::string name, bool isPrimary)
                                                             ^
/home/peter/dyninst/symtabAPI/src/Function.C:481:60: warning: unused parameter ‘isPrimary’ [-Wunused-parameter]
 bool InlinedFunction::addPrettyName(std::string name, bool isPrimary)
                                                            ^
[ 22%] Building CXX object symtabAPI/CMakeFiles/symtabAPI.dir/src/dwarfWalker.C.o
In file included from /home/peter/dyninst/symtabAPI/src/dwarfWalker.C:31:0:
/home/peter/dyninst/symtabAPI/src/dwarfWalker.h: In constructor ‘Dyninst::SymtabAPI::DwarfWalker::DwarfWalker(Dyninst::SymtabAPI::Symtab*, Dwarf_Debug_s*&)’:
/home/peter/dyninst/symtabAPI/src/dwarfWalker.h:314:14: warning: ‘Dyninst::SymtabAPI::DwarfWalker::compile_offset’ will be initialized after [-Wreorder]
    Dwarf_Off compile_offset;
              ^
/home/peter/dyninst/symtabAPI/src/dwarfWalker.h:292:12: warning:   ‘char** Dyninst::SymtabAPI::DwarfWalker::srcFileList_’ [-Wreorder]
     char** srcFileList_;
            ^
/home/peter/dyninst/symtabAPI/src/dwarfWalker.C:76:1: warning:   when initialized here [-Wreorder]
 DwarfWalker::DwarfWalker(Symtab *symtab, Dwarf_Debug &dbg)
 ^
[ 22%] Building CXX object symtabAPI/CMakeFiles/symtabAPI.dir/src/emitElf-64.C.o
/home/peter/dyninst/symtabAPI/src/emitElf-64.C: In member function ‘bool Dyninst::SymtabAPI::emitElf64<ElfTypes>::driver(std::string) [with ElfTypes = Dyninst::SymtabAPI::ElfTypes32; std::string = std::basic_string<char>]’:
/home/peter/dyninst/symtabAPI/src/emitElf-64.C:868:9: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
         write(newfd, &offset, sizeof(Elf_Off));
         ^
/home/peter/dyninst/symtabAPI/src/emitElf-64.C: In member function ‘bool Dyninst::SymtabAPI::emitElf64<ElfTypes>::driver(std::string) [with ElfTypes = Dyninst::SymtabAPI::ElfTypes64; std::string = std::basic_string<char>]’:
/home/peter/dyninst/symtabAPI/src/emitElf-64.C:868:9: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
[ 26%] Building CXX object instructionAPI/CMakeFiles/instructionAPI.dir/src/InstructionDecoder-x86.C.o
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-x86.C: In member function ‘bool Dyninst::InstructionAPI::InstructionDecoder_x86::decodeOneOperand(const Dyninst::InstructionAPI::InstructionDecoder::buffer&, const NS_x86::ia32_operand&, int&, const Dyninst::InstructionAPI::Instruction*, bool, bool)’:
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-x86.C:795:12: warning: variable ‘has_vex’ set but not used [-Wunused-but-set-variable]
       bool has_vex = 0;
            ^
[ 27%] Building CXX object instructionAPI/CMakeFiles/instructionAPI.dir/src/InstructionDecoder-aarch64.C.o
In file included from /home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.C:31:0:
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.h: In constructor ‘Dyninst::InstructionAPI::InstructionDecoder_aarch64::InstructionDecoder_aarch64(Dyninst::Architecture)’:
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.h:387:30: warning: ‘Dyninst::InstructionAPI::InstructionDecoder_aarch64::_Q’ will be initialized after [-Wreorder]
                 unsigned int _Q;
                              ^
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.h:239:31: warning:   ‘int Dyninst::InstructionAPI::InstructionDecoder_aarch64::size’ [-Wreorder]
                 int _szField, size;
                               ^
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.C:141:5: warning:   when initialized here [-Wreorder]
     InstructionDecoder_aarch64::InstructionDecoder_aarch64(Architecture a)
     ^
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.C: In member function ‘Dyninst::InstructionAPI::Expression::Ptr Dyninst::InstructionAPI::InstructionDecoder_aarch64::makeMemRefIndexLiteral()’:
/home/peter/dyninst/instructionAPI/src/InstructionDecoder-aarch64.C:1086:85: warning: ‘rt’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     return makeDereferenceExpression(makeAddExpression(makePCExpr(), label, u64), rt);
                                                                                     ^
[ 27%] Building CXX object parseAPI/CMakeFiles/parseAPI.dir/src/Parser.C.o
/home/peter/dyninst/parseAPI/src/Parser.C: In member function ‘void Dyninst::ParseAPI::Parser::parse_frame(Dyninst::ParseAPI::ParseFrame&, bool)’:
/home/peter/dyninst/parseAPI/src/Parser.C:888:20: warning: variable ‘ce’ set but not used [-Wunused-but-set-variable]
             Edge * ce = NULL;
                    ^
[ 32%] Building CXX object parseAPI/CMakeFiles/parseAPI.dir/src/IA_aarch64Details.C.o
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:111:59: warning: unused parameter ‘blockToCheck’ [-Wunused-parameter]
 bool IA_aarch64Details::findTableAddrNoTOC(const IA_IAPI* blockToCheck)
                                                           ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:136:33: warning: unused parameter ‘e’ [-Wunused-parameter]
   void processPredecessor(Edge* e, std::set<Block*>& visited, std::deque<Block*>& worklist)
                                 ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:136:54: warning: unused parameter ‘visited’ [-Wunused-parameter]
   void processPredecessor(Edge* e, std::set<Block*>& visited, std::deque<Block*>& worklist)
                                                      ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:136:83: warning: unused parameter ‘worklist’ [-Wunused-parameter]
   void processPredecessor(Edge* e, std::set<Block*>& visited, std::deque<Block*>& worklist)
                                                                                   ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:142:81: warning: unused parameter ‘start’ [-Wunused-parameter]
 bool IA_aarch64Details::scanForAdjustOrBase(IA_IAPI::allInsns_t::const_iterator start,
                                                                                 ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:143:44: warning: unused parameter ‘end’ [-Wunused-parameter]
        IA_IAPI::allInsns_t::const_iterator end,
                                            ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:144:26: warning: unused parameter ‘jumpAddrReg’ [-Wunused-parameter]
        RegisterAST::Ptr &jumpAddrReg) {
                          ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:150:75: warning: unused parameter ‘start’ [-Wunused-parameter]
 bool IA_aarch64Details::findTableBase(IA_IAPI::allInsns_t::const_iterator start,
                                                                           ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:151:45: warning: unused parameter ‘end’ [-Wunused-parameter]
         IA_IAPI::allInsns_t::const_iterator end) {
                                             ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:159:47: warning: unused parameter ‘currBlk’ [-Wunused-parameter]
 bool IA_aarch64Details::parseJumpTable(Block* currBlk,
                                               ^
/home/peter/dyninst/parseAPI/src/IA_aarch64Details.C:160:59: warning: unused parameter ‘outEdges’ [-Wunused-parameter]
          std::vector<std::pair< Address, EdgeTypeEnum> >& outEdges)
                                                           ^
[ 33%] Building CXX object parseAPI/CMakeFiles/parseAPI.dir/src/BoundFactData.C.o
/home/peter/dyninst/parseAPI/src/BoundFactData.C:604:39: warning: unused parameter ‘b’ [-Wunused-parameter]
 static bool IsInReadOnlyRegion(Block *b, Address low, Address high) {
                                       ^
[ 54%] Building CXX object proccontrol/CMakeFiles/pcontrol.dir/src/loadLibrary/codegen-aarch64.C.o
/home/peter/dyninst/proccontrol/src/loadLibrary/codegen-aarch64.C: In member function ‘bool Dyninst::ProcControlAPI::Codegen::generateCallAARCH64(Dyninst::Address, const std::vector<long unsigned int>&)’:
/home/peter/dyninst/proccontrol/src/loadLibrary/codegen-aarch64.C:53:10: warning: unused variable ‘blr_buf’ [-Wunused-variable]
     char blr_buf[] = {
          ^
[ 56%] Building CXX object proccontrol/CMakeFiles/pcontrol.dir/src/mmapalloc.C.o
/home/peter/dyninst/proccontrol/src/mmapalloc.C: In member function ‘virtual bool mmap_alloc_process::plat_createAllocationSnippet(Dyninst::Address, bool, long unsigned int, void*&, long unsigned int&, long unsigned int&)’:
/home/peter/dyninst/proccontrol/src/mmapalloc.C:597:22: warning: variable ‘addr_size’ set but not used [-Wunused-but-set-variable]
         unsigned int addr_size;
                      ^
[ 56%] Building CXX object proccontrol/CMakeFiles/pcontrol.dir/src/linux.C.o
In file included from /home/peter/dyninst/proccontrol/src/linux.C:48:0:
/home/peter/dyninst/proccontrol/src/linux.C: In member function ‘virtual bool DecoderLinux::decode(Dyninst::ProcControlAPI::ArchEvent*, std::vector<boost::shared_ptr<Dyninst::ProcControlAPI::Event> >&)’:
/home/peter/dyninst/proccontrol/h/PCErrors.h:100:108: warning: format ‘%p’ expects argument of type ‘void*’, but argument 6 has type ‘Dyninst::MachRegisterVal {aka long unsigned int}’ [-Wformat=]
          fprintf(pctrl_err_out, "[%s:%u-%s] - Error: " format, FILE__, __LINE__, thrdName(), ## __VA_ARGS__); \
                                                                                                            ^
/home/peter/dyninst/proccontrol/src/linux.C:341:25: note: in expansion of macro ‘perr_printf’
                         perr_printf("ARM-error: Failed to remove inserted BP, addr %p.\n",
                         ^
/home/peter/dyninst/proccontrol/src/linux.C: In member function ‘virtual bool linux_process::plat_attachWillTriggerStop()’:
/home/peter/dyninst/proccontrol/src/linux.C:1144:42: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
             &tmpPid, &tmpPid, &ttyNumber);
                                          ^
/home/peter/dyninst/proccontrol/src/linux.C: In member function ‘bool linux_process::readStatM(long unsigned int&, long unsigned int&, long unsigned int&)’:
/home/peter/dyninst/proccontrol/src/linux.C:1927:35: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
           &text, &lib, &data, &dt);
                                   ^
[ 77%] Building CXX object dyninstAPI/CMakeFiles/dyninstAPI.dir/src/function.C.o
/home/peter/dyninst/dyninstAPI/src/function.C: In member function ‘bool func_instance::createOffsetVector_Symbols()’:
/home/peter/dyninst/dyninstAPI/src/function.C:1205:18: warning: variable ‘bp’ set but not used [-Wunused-but-set-variable]
     MachRegister bp = MachRegister::getFramePointer(arch);
                  ^
/home/peter/dyninst/dyninstAPI/src/function.C: In member function ‘void func_instance::createTMap_internal(StackMod*, StackLocation*, TMap*)’:
/home/peter/dyninst/dyninstAPI/src/function.C:1530:27: warning: variable ‘size’ set but not used [-Wunused-but-set-variable]
     StackAnalysis::Height size = loc->size();
                           ^
[ 95%] Building CXX object dyninstAPI/CMakeFiles/dyninstAPI.dir/src/codegen-x86.C.o
/home/peter/dyninst/dyninstAPI/src/codegen-x86.C: In static member function ‘static bool insnCodeGen::modifyDisp(long int, NS_x86::instruction&, codeGen&, Dyninst::Architecture, Dyninst::Address)’:
/home/peter/dyninst/dyninstAPI/src/codegen-x86.C:1394:13: warning: variable ‘sib_scale_factor’ set but not used [-Wunused-but-set-variable]
         int sib_scale_factor;
             ^
[ 96%] Building CXX object dyninstAPI/CMakeFiles/dyninstAPI.dir/src/linux.C.o
/home/peter/dyninst/dyninstAPI/src/linux.C: In static member function ‘static bool BinaryEdit::getResolvedLibraryPath(const string&, std::vector<std::basic_string<char> >&)’:
/home/peter/dyninst/dyninstAPI/src/linux.C:223:37: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
         fgets(buffer, 512, ldconfig); // ignore first line
                                     ^

Signed-off-by: Peter Foley <pefoley2@xxxxxxxxxxx>
---
 common/src/arch-aarch64.C                       |  8 ++++----
 dyninstAPI/src/codegen-x86.C                    |  7 +++++--
 dyninstAPI/src/function.C                       |  2 --
 dyninstAPI/src/linux.C                          |  5 ++++-
 instructionAPI/src/InstructionDecoder-aarch64.C | 13 +++++++++----
 instructionAPI/src/InstructionDecoder-aarch64.h |  2 +-
 instructionAPI/src/InstructionDecoder-x86.C     |  2 --
 parseAPI/src/BoundFactData.C                    |  2 ++
 parseAPI/src/IA_aarch64Details.C                | 18 +++++++++---------
 parseAPI/src/Parser.C                           |  6 +++---
 proccontrol/src/linux.C                         | 19 ++++++++++++++-----
 proccontrol/src/loadLibrary/codegen-aarch64.C   |  2 ++
 proccontrol/src/mmapalloc.C                     |  4 +++-
 symtabAPI/src/Function.C                        |  8 ++++----
 symtabAPI/src/dwarfWalker.C                     |  4 ++--
 symtabAPI/src/emitElf-64.C                      |  5 ++++-
 16 files changed, 66 insertions(+), 41 deletions(-)

diff --git a/common/src/arch-aarch64.C b/common/src/arch-aarch64.C
index a73e14a..7f38e68 100644
--- a/common/src/arch-aarch64.C
+++ b/common/src/arch-aarch64.C
@@ -108,7 +108,7 @@ bool instruction::isCall() const
     return false;
 }

-void instruction::setInstruction(codeBuf_t *ptr, Address) {
+void instruction::setInstruction(codeBuf_t * /*ptr*/, Address) {
                assert(0);
 }

@@ -140,13 +140,13 @@ bool instruction::isCondBranch() const {
     return false;
 }

-unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) {
+unsigned instruction::jumpSize(Address /*from*/, Address /*to*/, unsigned /*addr_width*/) {
                assert(0);
         return -1;
 }

 // -1 is infinite, don't ya know.
-unsigned instruction::jumpSize(Address disp, unsigned addr_width) {
+unsigned instruction::jumpSize(Address /*disp*/, unsigned /*addr_width*/) {
                assert(0);
    return instruction::size();
 }
@@ -201,7 +201,7 @@ unsigned instruction::getBranchTargetReg() const{
         regNum = GET_OFFSET32(UNCOND_BR.REG)>>2;

         // be sure the reg num is in the range
-        assert( regNum >= 0 || regNum <= 30);
+        assert(regNum <= 30);

         return regNum;
     }
diff --git a/dyninstAPI/src/codegen-x86.C b/dyninstAPI/src/codegen-x86.C
index bbc8f87..2cb5256 100644
--- a/dyninstAPI/src/codegen-x86.C
+++ b/dyninstAPI/src/codegen-x86.C
@@ -1387,17 +1387,20 @@ bool insnCodeGen::modifyDisp(signed long newDisp, instruction &insn, codeGen &ge
     if (modrm_rm == 4) {

         unsigned char sib = *origInsn++;
-        unsigned char sib_scale = MODRM_MOD(sib);
-        //unsigned char sib_index = MODRM_REG(sib);
+        // unsigned char sib_scale = MODRM_MOD(sib);
+        // unsigned char sib_index = MODRM_REG(sib);
         unsigned char sib_base = MODRM_RM(sib);

+        /*
         int sib_scale_factor;
+
         switch((int)sib_scale) {
             case 0: sib_scale_factor = 1; break;
             case 1: sib_scale_factor = 2; break;
             case 2: sib_scale_factor = 4; break;
             case 3: sib_scale_factor = 8; break;
         }
+        */

         // Check for displacement in the SIB
         if (sib_base == 5 && modrm_mod == 0) {
diff --git a/dyninstAPI/src/function.C b/dyninstAPI/src/function.C
index ab6940b..2b2d8ee 100644
--- a/dyninstAPI/src/function.C
+++ b/dyninstAPI/src/function.C
@@ -1202,7 +1202,6 @@ bool func_instance::createOffsetVector_Symbols()
     if (!ifunc()->hasNoStackFrame()) {
         base -= width; // account for BP save
     }
-    MachRegister bp = MachRegister::getFramePointer(arch);

     for (auto vIter = _vars.begin(); vIter != _vars.end(); ++vIter) {
         SymtabAPI::localVar* var = *vIter;
@@ -1527,7 +1526,6 @@ bool func_instance::addToOffsetVector(StackAnalysis::Height off, int size, Stack
 void func_instance::createTMap_internal(StackMod* mod, StackLocation* loc, TMap* tMap)
 {
     StackAnalysis::Height off = loc->off();
-    StackAnalysis::Height size = loc->size();
     switch(mod->type()) {
         case(StackMod::INSERT): {
                           /* Model:
diff --git a/dyninstAPI/src/linux.C b/dyninstAPI/src/linux.C
index e42a0db..9154a80 100644
--- a/dyninstAPI/src/linux.C
+++ b/dyninstAPI/src/linux.C
@@ -220,7 +220,10 @@ bool BinaryEdit::getResolvedLibraryPath(const string &filename, std::vector<stri
     // search ld.so.cache
     ldconfig = popen("/sbin/ldconfig -p", "r");
     if (ldconfig) {
-        fgets(buffer, 512, ldconfig);  // ignore first line
+        if(!fgets(buffer, 512, ldconfig)) {    // ignore first line
+          free(ldconfig);
+          return false;
+        }
         while (fgets(buffer, 512, ldconfig) != NULL) {
             pos = buffer;
             while (*pos == ' ' || *pos == '\t') pos++;
diff --git a/instructionAPI/src/InstructionDecoder-aarch64.C b/instructionAPI/src/InstructionDecoder-aarch64.C
index 6d1aa06..8ff750d 100644
--- a/instructionAPI/src/InstructionDecoder-aarch64.C
+++ b/instructionAPI/src/InstructionDecoder-aarch64.C
@@ -143,8 +143,8 @@ namespace Dyninst
         is64Bit(true), isValid(true), insn(0), insn_in_progress(NULL),
         hasHw(false), hasShift(false), hasOption(false), hasN(false),
         immr(0), immrLen(0), sField(0), nField(0), nLen(0),
-        immlo(0), immloLen(0), _szField(-1), _Q(1), size(-1),
-       cmode(0), op(0), simdAlphabetImm(0)
+        immlo(0), immloLen(0), _szField(-1), size(-1),
+       cmode(0), op(0), simdAlphabetImm(0), _Q(1)
     {
         aarch64_insn_entry::buildInsnTable();
         aarch64_mask_entry::buildDecoderTable();
@@ -1045,8 +1045,9 @@ void InstructionDecoder_aarch64::getMemRefIndexLiteral_OffsetLen(int &immVal, in
     return;
 }

-void InstructionDecoder_aarch64::getMemRefIndexLiteral_RT(Result_Type &rt)
+bool InstructionDecoder_aarch64::getMemRefIndexLiteral_RT(Result_Type &rt)
 {
+    bool status = true;
     int size = field<30, 31>(insn);
     switch(size)
        {
@@ -1060,11 +1061,14 @@ void InstructionDecoder_aarch64::getMemRefIndexLiteral_RT(Result_Type &rt)
                        rt = s32;
                        break;
                case 0x3:
+                        status = false;
                        break;
                default:
+                        status = false;
                        isValid = false;
                        break;
        }
+    return status;
 }

 // ****************************************
@@ -1081,7 +1085,8 @@ Expression::Ptr InstructionDecoder_aarch64::makeMemRefIndexLiteral()
     Expression::Ptr label = Immediate::makeImmediate(Result(s64, sign_extend64(immLen, immVal)));

     Result_Type rt;
-    getMemRefIndexLiteral_RT(rt);
+    if(!getMemRefIndexLiteral_RT(rt))
+        return nullptr;

     return makeDereferenceExpression(makeAddExpression(makePCExpr(), label, u64), rt);
 }
diff --git a/instructionAPI/src/InstructionDecoder-aarch64.h b/instructionAPI/src/InstructionDecoder-aarch64.h
index c2e6651..4b6d99c 100644
--- a/instructionAPI/src/InstructionDecoder-aarch64.h
+++ b/instructionAPI/src/InstructionDecoder-aarch64.h
@@ -300,7 +300,7 @@ namespace Dyninst {
                 void getMemRefPair_ImmImmlen(unsigned int &immVal, unsigned int &immLen);

                 void getMemRefEx_RT(Result_Type &rt);
-                void getMemRefIndexLiteral_RT(Result_Type &);
+                bool getMemRefIndexLiteral_RT(Result_Type &);
                 void getMemRefExPair_RT(Result_Type &rt);
                 void getMemRefPair_RT(Result_Type &rt);
                 void getMemRefIndex_RT(Result_Type &);
diff --git a/instructionAPI/src/InstructionDecoder-x86.C b/instructionAPI/src/InstructionDecoder-x86.C
index 265ecc6..431a31a 100644
--- a/instructionAPI/src/InstructionDecoder-x86.C
+++ b/instructionAPI/src/InstructionDecoder-x86.C
@@ -792,10 +792,8 @@ namespace Dyninst

       unsigned int optype = operand.optype;
       int vex_vvvv = 0;
-      bool has_vex = 0;
       if(decodedInstruction && decodedInstruction->getPrefix()->vex_prefix[0])
       {
-        has_vex = true;
         /* The vvvv bits are bits 3, 4, 5, 6 and are in 1's complement */
         if(decodedInstruction->getPrefix()->vex_prefix[2]) /* AVX512 (EVEX) */
         {
diff --git a/parseAPI/src/BoundFactData.C b/parseAPI/src/BoundFactData.C
index f7595e0..0d5e6af 100644
--- a/parseAPI/src/BoundFactData.C
+++ b/parseAPI/src/BoundFactData.C
@@ -605,6 +605,8 @@ static bool IsInReadOnlyRegion(Block *b, Address low, Address high) {
 #if defined(os_windows)
     low -= b->obj()->cs()->loadAddress();
     high -= b->obj()->cs()->loadAddress();
+#else
+    (void)b;
 #endif
        // Now let's assume it is always in a read only region
        // unless it is reading a single memory location
diff --git a/parseAPI/src/IA_aarch64Details.C b/parseAPI/src/IA_aarch64Details.C
index f6143ac..bb47baf 100644
--- a/parseAPI/src/IA_aarch64Details.C
+++ b/parseAPI/src/IA_aarch64Details.C
@@ -108,7 +108,7 @@ namespace Dyninst
 };


-bool IA_aarch64Details::findTableAddrNoTOC(const IA_IAPI* blockToCheck)
+bool IA_aarch64Details::findTableAddrNoTOC(const IA_IAPI* /*blockToCheck*/)
 {
        assert(0);
   return tableStartAddress == 0;
@@ -133,22 +133,22 @@ namespace detail_aarch64
         Block* src = e->src();
         return visited.find(src) != visited.end();
     }
-  void processPredecessor(Edge* e, std::set<Block*>& visited, std::deque<Block*>& worklist)
+  void processPredecessor(Edge* /*e*/, std::set<Block*>& /*visited*/, std::deque<Block*>& /*worklist*/)
   {
                assert(0);
   }
 };

-bool IA_aarch64Details::scanForAdjustOrBase(IA_IAPI::allInsns_t::const_iterator start,
-                                         IA_IAPI::allInsns_t::const_iterator end,
-                                         RegisterAST::Ptr &jumpAddrReg) {
+bool IA_aarch64Details::scanForAdjustOrBase(IA_IAPI::allInsns_t::const_iterator /*start*/,
+                                         IA_IAPI::allInsns_t::const_iterator /*end*/,
+                                         RegisterAST::Ptr &/*jumpAddrReg*/) {
        assert(0);
   return true;
 }

 // Like the above, but a wider net
-bool IA_aarch64Details::findTableBase(IA_IAPI::allInsns_t::const_iterator start,
-                                   IA_IAPI::allInsns_t::const_iterator end) {
+bool IA_aarch64Details::findTableBase(IA_IAPI::allInsns_t::const_iterator /*start*/,
+                                   IA_IAPI::allInsns_t::const_iterator /*end*/) {
        assert(0);
   return true;
 }
@@ -156,8 +156,8 @@ bool IA_aarch64Details::findTableBase(IA_IAPI::allInsns_t::const_iterator start,


 // This should only be called on a known indirect branch...
-bool IA_aarch64Details::parseJumpTable(Block* currBlk,
-                                    std::vector<std::pair< Address, EdgeTypeEnum> >& outEdges)
+bool IA_aarch64Details::parseJumpTable(Block* /*currBlk*/,
+                                    std::vector<std::pair< Address, EdgeTypeEnum> >& /*outEdges*/)
 {
        assert(0);
   return true;
diff --git a/parseAPI/src/Parser.C b/parseAPI/src/Parser.C
index ef8aca8..b6afaa0 100644
--- a/parseAPI/src/Parser.C
+++ b/parseAPI/src/Parser.C
@@ -885,7 +885,7 @@ Parser::parse_frame(ParseFrame & frame, bool recursive) {
         ParseWorkElem * work = frame.popWork();
         if (work->order() == ParseWorkElem::call) {
             Function * ct = NULL;
-            Edge * ce = NULL;
+            // Edge * ce = NULL;

             if (!work->callproc()) {
              // If we're not doing recursive traversal, skip *all* of the call edge processing.
@@ -909,12 +909,12 @@ Parser::parse_frame(ParseFrame & frame, bool recursive) {
                               work->edge()->src(),
                               work->edge());
                 ct = ctp.first;
-                ce = ctp.second;
+                // ce = ctp.second;

                 work->mark_call();
             } else {
                 ct = _parse_data->findFunc(frame.codereg,work->target());
-                ce = work->edge();
+                // ce = work->edge();
             }

             if (recursive && ct &&
diff --git a/proccontrol/src/linux.C b/proccontrol/src/linux.C
index 97846ed..2ac30ea 100644
--- a/proccontrol/src/linux.C
+++ b/proccontrol/src/linux.C
@@ -338,7 +338,7 @@ bool DecoderLinux::decode(ArchEvent *ae, std::vector<Event::ptr> &events)
                    // do not handle the bp and clear the bp.
                     bool rst = lthread->proc()->rmBreakpoint(addr, lthread->BPptr_fakeSyscallExitBp );
                     if( !rst){
-                        perr_printf("ARM-error: Failed to remove inserted BP, addr %p.\n",
+                        perr_printf("ARM-error: Failed to remove inserted BP, addr %lx.\n",
                                 addr);
                     }
                     lthread->isSet_fakeSyscallExitBp = false;
@@ -1139,9 +1139,13 @@ bool linux_process::plat_attachWillTriggerStop() {
         return true;
     }

-    fscanf(sfile, "%d %255s %c %d %d %d",
+    if(fscanf(sfile, "%d %255s %c %d %d %d",
             &tmpPid, cmd, &state,
-            &tmpPid, &tmpPid, &ttyNumber);
+            &tmpPid, &tmpPid, &ttyNumber) < 0) {
+        perr_printf("Failed to determine whether attach would trigger stop -- assuming it will\n");
+        fclose(sfile);
+        return true;
+    }
     fclose(sfile);

     // If the process is stopped and it has a controlling tty, an attach
@@ -1923,8 +1927,13 @@ bool linux_process::readStatM(unsigned long &stk, unsigned long &heap, unsigned
       setLastError(err_internal, "Could not access /proc");
       return false;
    }
-   fscanf(f, "%lu %lu %lu %lu %lu %lu %lu", &size, &resident, &shared,
-          &text, &lib, &data, &dt);
+   if(fscanf(f, "%lu %lu %lu %lu %lu %lu %lu", &size, &resident, &shared,
+          &text, &lib, &data, &dt) < 0) {
+      perr_printf("Could not read from %s: %s\n", path, strerror(errno));
+      setLastError(err_internal, "Could not read from /proc");
+      fclose(f);
+      return false;
+   }
    fclose(f);
    unsigned long page_size = getpagesize();

diff --git a/proccontrol/src/loadLibrary/codegen-aarch64.C b/proccontrol/src/loadLibrary/codegen-aarch64.C
index 895cdbe..3c1e273 100644
--- a/proccontrol/src/loadLibrary/codegen-aarch64.C
+++ b/proccontrol/src/loadLibrary/codegen-aarch64.C
@@ -50,9 +50,11 @@ bool Codegen::generateCallAARCH64(Address addr, const std::vector<Address> &args
         (char)0xf2, (char)0xe0, (char)0x00, (char)0x00,     // movk x0, #0, lsl #48
     };

+    /*
     char blr_buf[] = {
         (char)0xd6, (char)0x3f, (char)0x00, (char)0x00,     // blr x0
     };
+    */

     char* _buf;
     _buf = (char *)malloc(sizeof(movLong_buf));
diff --git a/proccontrol/src/mmapalloc.C b/proccontrol/src/mmapalloc.C
index b58eb1b..69a4680 100644
--- a/proccontrol/src/mmapalloc.C
+++ b/proccontrol/src/mmapalloc.C
@@ -592,7 +592,7 @@ bool mmap_alloc_process::plat_createAllocationSnippet(Dyninst::Address addr, boo
        *((uint16_t *) (((char *) buffer)+addr_hi_position)) = (uint16_t)(addr >> 16);
        *((uint16_t *) (((char *) buffer)+addr_lo_position)) = (uint16_t)addr;

-    }else if( getTargetArch() == Arch_aarch64 ){
+    } else if( getTargetArch() == Arch_aarch64 ){
         const void *buf_tmp;
         unsigned int addr_size;
         unsigned int addr_pos, size_pos, flags_pos;
@@ -650,6 +650,8 @@ bool mmap_alloc_process::plat_createAllocationSnippet(Dyninst::Address addr, boo
             SWAP4BYTE(i)
         }

+        (void)addr_size;
+
 //debug
 #if 1
         pthrd_printf("ARM-info: dump alloc snippet...\n");
diff --git a/symtabAPI/src/Function.C b/symtabAPI/src/Function.C
index 09aadff..441d591 100644
--- a/symtabAPI/src/Function.C
+++ b/symtabAPI/src/Function.C
@@ -51,7 +51,7 @@ using namespace std;
 using namespace Dyninst;
 using namespace Dyninst::SymtabAPI;

-FunctionBase::FunctionBase(Symbol *sym) :
+FunctionBase::FunctionBase(Symbol*) :
    locals(NULL),
    params(NULL),
    functionSize_(0),
@@ -73,7 +73,7 @@ FunctionBase::FunctionBase() :
 {
 }

-FunctionBase::FunctionBase(Module *m) :
+FunctionBase::FunctionBase(Module*) :
     locals(NULL),
     params(NULL),
     functionSize_(0),
@@ -472,13 +472,13 @@ bool InlinedFunction::removeSymbol(Symbol *)
    return false;
 }

-bool InlinedFunction::addMangledName(std::string name, bool isPrimary)
+bool InlinedFunction::addMangledName(std::string name, bool /*isPrimary*/)
 {
     name_ = name;
     return true;
 }

-bool InlinedFunction::addPrettyName(std::string name, bool isPrimary)
+bool InlinedFunction::addPrettyName(std::string name, bool /*isPrimary*/)
 {
     name_ = name;
     return true;
diff --git a/symtabAPI/src/dwarfWalker.C b/symtabAPI/src/dwarfWalker.C
index 016a49c..074224f 100644
--- a/symtabAPI/src/dwarfWalker.C
+++ b/symtabAPI/src/dwarfWalker.C
@@ -78,6 +78,7 @@ DwarfWalker::DwarfWalker(Symtab *symtab, Dwarf_Debug &dbg)
    dbg_(dbg),
    mod_(NULL),
    symtab_(symtab),
+   srcFileList_(NULL),
    tc_(NULL),
    is_mangled_name_(false),
    modLow(0),
@@ -91,8 +92,7 @@ DwarfWalker::DwarfWalker(Symtab *symtab, Dwarf_Debug &dbg)
    signature(),
    typeoffset(0),
    next_cu_header(0),
-   compile_offset(0),
-   srcFileList_(NULL)
+   compile_offset(0)
 {
 }

diff --git a/symtabAPI/src/emitElf-64.C b/symtabAPI/src/emitElf-64.C
index e28aa21..56e3bc5 100644
--- a/symtabAPI/src/emitElf-64.C
+++ b/symtabAPI/src/emitElf-64.C
@@ -865,7 +865,10 @@ bool emitElf64<ElfTypes>::driver(std::string fName) {
         unsigned long ehdr_off = (unsigned long) &(((Elf_Ehdr *) 0x0)->e_phoff);
         lseek(newfd, ehdr_off, SEEK_SET);
         Elf_Off offset = (Elf_Off) phdr_offset;
-        write(newfd, &offset, sizeof(Elf_Off));
+        if(write(newfd, &offset, sizeof(Elf_Off)) < 0) {
+            close(newfd);
+            return false;
+        }
     }
     close(newfd);

--
2.8.1

_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

[← Prev in Thread] Current Thread [Next in Thread→]