Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Sep 12, 2023
1 parent f4ea7e1 commit 2d8dad6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
6 changes: 3 additions & 3 deletions MCInst.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ uint64_t MCInst_getOpVal(MCInst *MI, unsigned OpNum)
return MCOperand_getReg(op);
else if (MCOperand_isImm(op))
return MCOperand_getImm(op);
else
assert(0 && "Operand type not handled in this getter.");
return false;

assert(0 && "Operand type not handled in this getter.");
return false;
}

void MCInst_setIsAlias(MCInst *MI, bool Flag) {
Expand Down
12 changes: 8 additions & 4 deletions arch/ARM/ARMInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,10 @@ void printOperandAddr(MCInst *MI, uint64_t Address, unsigned OpNum, SStream *O)
{
MCOperand *Op = MCInst_getOperand(MI, (OpNum));
if (!MCOperand_isImm(Op) || MI->csh->PrintBranchImmNotAsAddress ||
getUseMarkup())
return printOperand(MI, OpNum, O);
getUseMarkup()) {
printOperand(MI, OpNum, O);
return;
}
int64_t Imm = MCOperand_getImm(Op);
// For ARM instructions the PC offset is 8 bytes, for Thumb instructions it
// is 4 bytes.
Expand Down Expand Up @@ -1556,8 +1558,10 @@ void printModImmOperand(MCInst *MI, unsigned OpNum, SStream *O)
MCOperand *Op = MCInst_getOperand(MI, (OpNum));

// Support for fixups (MCFixup)
if (MCOperand_isExpr(Op))
return printOperand(MI, OpNum, O);
if (MCOperand_isExpr(Op)) {
printOperand(MI, OpNum, O);
return;
}

unsigned Bits = MCOperand_getImm(Op) & 0xFF;
unsigned Rot = (MCOperand_getImm(Op) & 0xF00) >> 7;
Expand Down
2 changes: 1 addition & 1 deletion arch/PowerPC/PPCGenDisassemblerTables.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9819,7 +9819,7 @@ static DecodeStatus fname(const uint8_t DecodeTable[], MCInst *MI, \
NumToSkip |= (*Ptr++) << 16; \
/* Perform the decode operation. */ \
MCInst_setOpcode(MI, Opc); \
bool DecodeComplete; \
bool DecodeComplete = false; \
S = decoder(S, DecodeIdx, insn, MI, Address, &DecodeComplete); \
if (DecodeComplete) { \
/* Decoding complete. */ \
Expand Down
12 changes: 8 additions & 4 deletions arch/PowerPC/PPCInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,10 @@ void printU16ImmOperand(MCInst *MI, unsigned OpNo, SStream *O)
void printBranchOperand(MCInst *MI, uint64_t Address, unsigned OpNo, SStream *O)
{
add_cs_detail(MI, PPC_OP_GROUP_BranchOperand, OpNo);
if (!MCOperand_isImm(MCInst_getOperand(MI, (OpNo))))
return printOperand(MI, OpNo, O);
if (!MCOperand_isImm(MCInst_getOperand(MI, (OpNo)))) {
printOperand(MI, OpNo, O);
return;
}
int32_t Imm = SignExtend32(
((unsigned)MCOperand_getImm(MCInst_getOperand(MI, (OpNo)))
<< 2),
Expand Down Expand Up @@ -532,8 +534,10 @@ void printBranchOperand(MCInst *MI, uint64_t Address, unsigned OpNo, SStream *O)
void printAbsBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
{
add_cs_detail(MI, PPC_OP_GROUP_AbsBranchOperand, OpNo);
if (!MCOperand_isImm(MCInst_getOperand(MI, (OpNo))))
return printOperand(MI, OpNo, O);
if (!MCOperand_isImm(MCInst_getOperand(MI, (OpNo)))) {
printOperand(MI, OpNo, O);
return;
}

printInt32(O, SignExtend32(((unsigned)MCOperand_getImm(
MCInst_getOperand(MI, (OpNo)))
Expand Down
2 changes: 1 addition & 1 deletion cstool/cstool_powerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void print_insn_detail_ppc(csh handle, cs_insn *ins)
}
if (ppc->bc.pred_ctr != PPC_PRED_INVALID)
printf("\t\tpred CTR: %s\n", get_pred_name(ppc->bc.pred_ctr));
if (ppc->bc.hint != PPC_BH_INVALID)
if (ppc->bc.hint != PPC_BR_NOT_GIVEN)
printf("\t\thint: %u\n", ppc->bc.hint);
}

Expand Down
5 changes: 4 additions & 1 deletion include/capstone/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,17 @@ typedef enum PredBlockMask {
inline static const char *ARMVPTPredToString(ARMVCC_VPTCodes CC)
{
switch (CC) {
default:
assert(0 && "Unknown VPT code");
break;
case ARMVCC_None:
return "none";
case ARMVCC_Then:
return "t";
case ARMVCC_Else:
return "e";
}
assert(0 && "Unknown VPT code");
return NULL;
}

inline static unsigned ARMVectorCondCodeFromString(const char CC)
Expand Down

0 comments on commit 2d8dad6

Please sign in to comment.