Skip to content

Commit

Permalink
Fix uninitialized member variables (#1431)
Browse files Browse the repository at this point in the history
These were detected by cppcheck's uninitMemberVar*.
  • Loading branch information
hainest committed May 10, 2023
1 parent 6a73aba commit f0c88be
Show file tree
Hide file tree
Showing 27 changed files with 143 additions and 133 deletions.
6 changes: 3 additions & 3 deletions common/h/IBSTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class SimpleInterval
virtual T high() const { return high_; }
virtual U id() const { return id_; }
protected:
T low_;
T high_;
U id_; // some arbitrary unique identifier
T low_{};
T high_{};
U id_{}; // some arbitrary unique identifier
};

template<class ITYPE>
Expand Down
2 changes: 1 addition & 1 deletion dataflowAPI/rose/SgAsmExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ class SgAsmRegisterReferenceExpression : public SgAsmExpression {

protected:
// Start of memberFunctionString
SgAsmType *p_type;
SgAsmType *p_type{};

// End of memberFunctionString
public:
Expand Down
2 changes: 1 addition & 1 deletion dataflowAPI/rose/SgAsmPowerpcInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SgAsmPowerpcInstruction : public SgAsmInstruction
powerpc_unknown_instruction);

protected:
rose_addr_t p_address;
rose_addr_t p_address{};
PowerpcInstructionKind p_kind;
SgAsmOperandList* p_operandList;
std::string p_mnemonic;
Expand Down
2 changes: 1 addition & 1 deletion dataflowAPI/rose/util/PoolAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class PoolAllocatorBase {
Pool(const Pool&); // nonsense

public:
Pool(): cellSize_(0) {}
Pool(): cellSize_(0), freeLists_{} {}

void init(size_t cellSize) {
assert(cellSize_ == 0);
Expand Down
8 changes: 4 additions & 4 deletions dwarf/h/dwarfResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ class DYNDWARF_EXPORT ConcreteDwarfResult : public DwarfResult {
bool eval(MachRegisterVal &v);

private:
ProcessReader *reader;
ProcessReader *reader{};

// For getting access to other expressions
Address pc;
Dwarf * dbg;
Elf * dbg_eh_frame;
Address pc{};
Dwarf * dbg{};
Elf * dbg_eh_frame{};

// Dwarf lets you access within the "stack", so we model
// it as a vector.
Expand Down
2 changes: 1 addition & 1 deletion dynC_API/h/snippetGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SnippetGenerator{

private:
std::stringstream lastError;
SGError lastErrorInfo;
SGError lastErrorInfo{};
BPatch_point *point;
BPatch_addressSpace *addSpace;
BPatch_image *image;
Expand Down
8 changes: 4 additions & 4 deletions dyninstAPI/h/BPatch_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class BPATCH_DLL_EXPORT BPatch_cblock {
// which functions use this list
BPatch_Vector<BPatch_function *> functions;

Dyninst::SymtabAPI::CBlock *cBlk;
Dyninst::SymtabAPI::CBlock *cBlk{};

void fixupUnknowns(BPatch_module *);
public:
Expand Down Expand Up @@ -323,11 +323,11 @@ class BPATCH_DLL_EXPORT BPatch_localVar{
friend class BPatch;
friend class BPatch_function;

BPatch_type *type;
BPatch_storageClass storageClass;
BPatch_type *type{};
BPatch_storageClass storageClass{};
// scope_t scope;

Dyninst::SymtabAPI::localVar *lVar;
Dyninst::SymtabAPI::localVar *lVar{};

public:
// Internal use only
Expand Down
30 changes: 15 additions & 15 deletions dyninstAPI/h/StackMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class BPATCH_DLL_EXPORT StackMod
virtual std::string format() const { return ""; }

protected:
MOrder _order;
MType _type;
MOrder _order{};
MType _type{};
};

/* Modification to insert stack space at [low, high) */
Expand All @@ -99,8 +99,8 @@ class BPATCH_DLL_EXPORT Insert : public StackMod
private:
Insert(MOrder, int, int);

int _low;
int _high;
int _low{};
int _high{};
};

/* Modification to remove stack space at [low, high) */
Expand All @@ -121,8 +121,8 @@ class BPATCH_DLL_EXPORT Remove : public StackMod
private:
Remove(MOrder, int, int);

int _low;
int _high;
int _low{};
int _high{};
};

/* Modification to move stack space from [srcLow, srcHigh)
Expand All @@ -144,10 +144,10 @@ class BPATCH_DLL_EXPORT Move : public StackMod
std::string format() const;

private:
int _srcLow;
int _srcHigh;
int _destLow;
int _destHigh;
int _srcLow{};
int _srcHigh{};
int _destLow{};
int _destHigh{};
};

/* Modification to insert a stack canary at function entry
Expand Down Expand Up @@ -180,9 +180,9 @@ class BPATCH_DLL_EXPORT Canary : public StackMod
std::string format() const;

private:
int _low;
int _high;
BPatch_function* _failFunc;
int _low{};
int _high{};
BPatch_function* _failFunc{};
};

/* Modification to randomize the locations of the DWARF-specified
Expand All @@ -201,8 +201,8 @@ class BPATCH_DLL_EXPORT Randomize : public StackMod
std::string format() const;

private:
bool _isSeeded;
int _seed;
bool _isSeeded{};
int _seed{};
};

#endif
8 changes: 4 additions & 4 deletions dyninstAPI/src/Relocation/Widgets/RelDataWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ struct RelDataPatch : public Patch {
void setBlock(block_instance *_block) { block = _block; }

InstructionAPI::Instruction orig_insn;
Address target_addr;
Address orig;
Address target_addr{};
Address orig{};

private:
func_instance *func;
block_instance *block;
func_instance *func{};
block_instance *block{};
};


Expand Down
5 changes: 4 additions & 1 deletion dyninstAPI/src/StackMod/StackLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ class StackLocation {
{}

StackLocation() :
_type(StackAccess::StackAccessType::UNKNOWN),
_size{},
_isStackMemory(false),
_isRegister(false),
_reg{},
_isNull(true),
_valid(NULL)
{}
Expand Down Expand Up @@ -122,7 +125,7 @@ class StackLocation {

bool _isStackMemory;
StackAnalysis::Height _off;
bool _isRegisterHeight;
bool _isRegisterHeight{};

bool _isRegister;
MachRegister _reg;
Expand Down
12 changes: 6 additions & 6 deletions dyninstAPI/src/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ class AstStackRemoveNode : public AstNode {
int size;
MSpecialType type;

func_instance* func_;
bool canaryAfterPrologue_;
long canaryHeight_;
func_instance* func_{};
bool canaryAfterPrologue_{};
long canaryHeight_{};
};

class AstStackGenericNode : public AstNode {
Expand Down Expand Up @@ -570,7 +570,7 @@ class AstOperatorNode : public AstNode {
bool generateOptimizedAssignment(codeGen &gen, int size, bool noCost);

AstOperatorNode() {}
opCode op;
opCode op{};
AstNodePtr loperand;
AstNodePtr roperand;
AstNodePtr eoperand;
Expand Down Expand Up @@ -839,8 +839,8 @@ class AstMemoryNode : public AstNode {
Register &retReg);

AstMemoryNode() {}
memoryType mem_;
unsigned which_;
memoryType mem_{};
unsigned which_{};
};

class AstOriginalAddrNode : public AstNode {
Expand Down
4 changes: 2 additions & 2 deletions dyninstAPI/src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ class image_variable {
pdmodule *pdmod() const { return pdmod_; }
SymtabAPI::Variable *svar() const { return var_; }

SymtabAPI::Variable *var_;
pdmodule *pdmod_;
SymtabAPI::Variable *var_{};
pdmodule *pdmod_{};

};

Expand Down
2 changes: 1 addition & 1 deletion dyninstAPI/src/inst-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ struct stackItem {
reg_item,
stacktop,
framebase
} item;
} item{};
RealRegister reg;
stackItem(stackItem_t i) { assert(i != reg_item); item = i; }
stackItem(RealRegister r) { item = reg_item; reg = r; }
Expand Down
10 changes: 5 additions & 5 deletions dyninstAPI/src/mapped_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class int_variable {
//AddressSpace *as() const { return mod()->proc(); }
const image_variable *ivar() const { return ivar_; }

Address addr_;
unsigned size_;
Address addr_{};
unsigned size_{};
// type?
image_variable *ivar_;
image_variable *ivar_{};

mapped_module *mod_;
mapped_module *mod_{};
};

struct edgeStub {
Expand All @@ -114,7 +114,7 @@ struct edgeStub {
block_instance* src;
Address trg;
EdgeTypeEnum type;
bool checked;
bool checked{};
};


Expand Down
8 changes: 7 additions & 1 deletion dyninstAPI/src/registerSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ class registerSlot {
name("DEFAULT REGISTER"),
initialState(deadAlways),
offLimits(true),
type(invalid)
type(invalid),
refCount(0),
liveState(live),
keptValue(false),
beenUsed(false),
spilledState(unspilled),
saveOffset(-1)
{}

registerSlot(Register num,
Expand Down
3 changes: 2 additions & 1 deletion dyninstAPI/src/syscallNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class syscallNotification {
syscallNotification() :
preForkInst(NULL), postForkInst(NULL),
preExecInst(NULL), postExecInst(NULL),
preExitInst(NULL), preLwpExitInst(NULL)
preExitInst(NULL), preLwpExitInst(NULL),
proc(NULL)
{ assert(0 && "ILLEGAL USE OF DEFAULT CONSTRUCTOR"); }

syscallNotification(PCProcess *p) :
Expand Down
26 changes: 13 additions & 13 deletions elf/h/Elf_X.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,24 @@ class DYNELF_EXPORT Elf_X {
Dyninst::Architecture getArch() const;

protected:
Elf *elf;
Elf32_Ehdr *ehdr32;
Elf64_Ehdr *ehdr64;
Elf32_Phdr *phdr32;
Elf64_Phdr *phdr64;
int filedes;
bool is64;
bool isArchive;
bool isBigEndian;
Elf *elf{};
Elf32_Ehdr *ehdr32{};
Elf64_Ehdr *ehdr64{};
Elf32_Phdr *phdr32{};
Elf64_Phdr *phdr64{};
int filedes{};
bool is64{};
bool isArchive{};
bool isBigEndian{};
std::vector<Elf_X_Shdr> shdrs;
std::vector<Elf_X_Phdr> phdrs;
unsigned int ref_count;
unsigned int ref_count{};
std::string filename;

char *cached_debug_buffer;
unsigned long cached_debug_size;
char *cached_debug_buffer{};
unsigned long cached_debug_size{};
std::string cached_debug_name;
bool cached_debug;
bool cached_debug{};

Elf_X();
Elf_X(int input, Elf_Cmd cmd, Elf_X *ref = NULL);
Expand Down
2 changes: 1 addition & 1 deletion instructionAPI/h/Ternary.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Dyninst
Expression::Ptr cond;
Expression::Ptr first;
Expression::Ptr second;
Result_Type result_type;
Result_Type result_type{};

protected:
virtual bool isStrictEqual(const InstructionAST& rhs) const;
Expand Down

0 comments on commit f0c88be

Please sign in to comment.