Add =0 and =1 lintings

This commit is contained in:
pancake 2022-08-18 13:58:40 +02:00
parent b9161f5b3c
commit a538b2b700
64 changed files with 293 additions and 299 deletions

View File

@ -523,7 +523,7 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState * state)
instrName = 0;
decodingClass = CLASS_A4_ARITH; /* default! */
repeatsOp = 0;
condCodeIsPartOfName=0;
condCodeIsPartOfName = 0;
state->commNum = 0;
state->tcnt = 0;
state->acnt = 0;
@ -724,22 +724,20 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState * state)
instrName = "nop";
decodingClass = CLASS_A4_OP3_SUBOPC3F;
} else {
instrName = "xor";
instrName = "xor";
}
break;
default:
instrName = instruction_name (state,state->_opcode,0,&flags);
/* if (instrName) printf ("FLAGS=0x%x\n", flags); */
if (!instrName)
{
instrName = "???";
state->flow=invalid_instr;
}
if (flags & IGNORE_FIRST_OPD) {
ignoreFirstOpd = 1;
}
break;
if (!instrName) {
instrName = "???";
state->flow=invalid_instr;
}
if (flags & IGNORE_FIRST_OPD) {
ignoreFirstOpd = 1;
}
break;
}
fieldAisReg = fieldBisReg = fieldCisReg = 1; /* Assume regs for now. */

View File

@ -1151,7 +1151,7 @@ insert_reg (arc_insn insn,long *ex ATTRIBUTE_UNUSED,
make it a scaled instruction, i.e. set .aa field to 3 */
if (addrwb_p == 0)
{
/* Check for ld with .aa=0 */
/* Check for ld with .aa = 0 */
if ((insn & 0xf8000000) == 0x10000000)
{
/* if an ld/ldw insn */
@ -1161,7 +1161,7 @@ insert_reg (arc_insn insn,long *ex ATTRIBUTE_UNUSED,
addrwb_p = 0x600;
}
}
/* Check for st with .aa=0 */
/* Check for st with .aa = 0 */
else if ((insn & 0xf8000001) == 0x18000000)
{
/* if an st/stw insn */
@ -2513,7 +2513,7 @@ static struct arc_opcode arc_opcodes[] = {
{ "extw%.q%.f %a,%b%F%S%L", I(-1)|C(-1), I(3)|C(8), ARC_MACH_ARC4, 0, 0 ,0,0},
{ "flag%.q %b%G%S%L", I(-1)|A(-1)|C(-1), I(3)|A(ARC_REG_SHIMM_UPDATE)|C(0), ARC_MACH_ARC4, 0, 0 ,0,0},
/* %Q: force arc_cond_p=1 --> no shimm values */
/* %Q: force arc_cond_p = 1 --> no shimm values */
/* This insn allows an optional flags spec. */
{ "j%q%Q%.n%.f %b%F%J,%j", I(-1)|A(-1)|C(-1)|R(-1,7,1), I(7)|A(0)|C(0)|R(0,7,1), ARC_MACH_ARC4 | ARC_OPCODE_COND_BRANCH, 0, 0 ,0,0},
{ "j%q%Q%.n%.f %b%F%J,%j", I(-1)|A(-1)|C(-1)|R(-1,7,1), I(7)|A(0)|C(0)|R(0,7,1), ARC_MACH_ARC4 | ARC_OPCODE_COND_BRANCH, 0, 0 ,0,0},

View File

@ -664,19 +664,18 @@ sign_extend (int value, int bits)
static int
dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
{
int subopcode, mul;
int condCodeIsPartOfName=0;
int condCodeIsPartOfName = 0;
int decodingClass;
const char *instrName;
int fieldAisReg=1, fieldBisReg=1, fieldCisReg=1;
int fieldA=0, fieldB=0, fieldC=0;
int flag=0, cond=0, is_shimm=0, is_limm=0;
int signExtend=0, addrWriteBack=0, directMem=0;
int is_linked=0;
int offset=0;
int fieldAisReg = 1, fieldBisReg = 1, fieldCisReg = 1;
int fieldA = 0, fieldB = 0, fieldC = 0;
int flag = 0, cond = 0, is_shimm = 0, is_limm = 0;
int signExtend = 0, addrWriteBack = 0, directMem = 0;
int is_linked = 0;
int offset = 0;
int usesAuxReg = 0;
int usesSimdRegA= 0, usesSimdRegB=0, usesSimdRegC=0,simd_scale_u8=-1;
int usesSimdRegA= 0, usesSimdRegB = 0, usesSimdRegC = 0,simd_scale_u8=-1;
int flags = !E_ARC_MACH_A4;
char formatString[60];
@ -718,7 +717,7 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
instrName = 0;
decodingClass = 0; /* default! */
mul = 0;
condCodeIsPartOfName=0;
condCodeIsPartOfName = 0;
state->commNum = 0;
state->tcnt = 0;
state->acnt = 0;
@ -963,8 +962,8 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
case 1: instrName = "lsr"; break;
case 2: instrName = "asr"; break;
case 3: instrName = "ror"; break;
case 4: instrName = "mul64"; mul =1; decodingClass = 2; break;
case 5: instrName = "mulu64"; mul =1; decodingClass = 2; break;
case 4: instrName = "mul64"; mul = 1; decodingClass = 2; break;
case 5: instrName = "mulu64"; mul = 1; decodingClass = 2; break;
/* ARC A700 */
case 6: instrName = "adds" ;break;
@ -1038,9 +1037,9 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
case 68:
instrName = "vld32";
decodingClass = 37;
usesSimdRegA=1;
usesSimdRegB=2;
usesSimdRegC=0;
usesSimdRegA = 1;
usesSimdRegB = 2;
usesSimdRegC = 0;
simd_scale_u8 = 2;
break;
@ -1300,12 +1299,12 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
{
case 0:
instrName = "vaddw"; decodingClass = 42;
usesSimdRegA = usesSimdRegB = usesSimdRegC =1;
usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
break;
case 1:
instrName = "vaddaw"; decodingClass = 42;
usesSimdRegA = usesSimdRegB = usesSimdRegC =1;
usesSimdRegA = usesSimdRegB = usesSimdRegC = 1;
break;
case 2:
@ -2122,7 +2121,7 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
case 6 : instrName = "bic_s"; break;
case 7 : instrName = "xor_s"; break;
case 11: instrName = "tst_s"; decodingClass = 14; break;
case 12: instrName = "mul64_s"; mul =1; decodingClass = 14; break;
case 12: instrName = "mul64_s"; mul = 1; decodingClass = 14; break;
case 13: instrName = "sexb_s"; decodingClass = 14; break;
case 14: instrName = "sexw_s"; decodingClass = 14; break;
case 15: instrName = "extb_s"; decodingClass = 14; break;
@ -2818,7 +2817,7 @@ dsmOneArcInst (bfd_vma addr, struct arcDisState *state, disassemble_info * info)
state->source_operand.registerNum = fieldC;
state->sourceType = fieldCisReg ? ARC_REGISTER : ARC_LIMM ;
fieldA = FIELDD9(state->words[0]); /* shimm */
fieldAisReg=0;
fieldAisReg = 0;
/* [B,A offset] */
#if 0

View File

@ -85,10 +85,10 @@ R_API int r_anal_cond_eval(RAnal *anal, RAnalCond *cond) {
switch (cond->type) {
case R_ANAL_COND_EQ: return !arg0;
case R_ANAL_COND_NE: return arg0;
case R_ANAL_COND_GT: return arg0>0;
case R_ANAL_COND_GE: return arg0>=0;
case R_ANAL_COND_LT: return arg0<0;
case R_ANAL_COND_LE: return arg0<=0;
case R_ANAL_COND_GT: return arg0 > 0;
case R_ANAL_COND_GE: return arg0 >= 0;
case R_ANAL_COND_LT: return arg0 < 0;
case R_ANAL_COND_LE: return arg0 <= 0;
}
}
return false;
@ -96,14 +96,13 @@ R_API int r_anal_cond_eval(RAnal *anal, RAnalCond *cond) {
// XXX conflict naming with tostring()
R_API char *r_anal_cond_to_string(RAnalCond *cond) {
char *val0, *val1, *out = NULL;
const char *cnd;
char *out = NULL;
if (!cond) {
return NULL;
}
cnd = condstring (cond);
val0 = r_anal_value_to_string (cond->arg[0]);
val1 = r_anal_value_to_string (cond->arg[1]);
const char *cnd = condstring (cond);
char *val0 = r_anal_value_to_string (cond->arg[0]);
char *val1 = r_anal_value_to_string (cond->arg[1]);
if (val0) {
if (R_ANAL_COND_SINGLE (cond)) {
int val0len = strlen (val0) + 10;

View File

@ -28,8 +28,8 @@ R_API void r_anal_diff_setup(RAnal *anal, int doops, double thbb, double thfcn)
if (doops >= 0) {
anal->diff_ops = doops;
}
anal->diff_thbb = (thbb>=0)? thbb: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? thfcn: R_ANAL_THRESHOLDFCN;
anal->diff_thbb = (thbb >= 0)? thbb: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn >= 0)? thfcn: R_ANAL_THRESHOLDFCN;
}
/* 0-100 */
@ -37,8 +37,8 @@ R_API void r_anal_diff_setup_i(RAnal *anal, int doops, int thbb, int thfcn) {
if (doops >= 0) {
anal->diff_ops = doops;
}
anal->diff_thbb = (thbb>=0)? ((double)thbb) / 100: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn>=0)? ((double)thfcn) / 100: R_ANAL_THRESHOLDFCN;
anal->diff_thbb = (thbb >= 0)? ((double)thbb) / 100: R_ANAL_THRESHOLDBB;
anal->diff_thfcn = (thfcn >= 0)? ((double)thfcn) / 100: R_ANAL_THRESHOLDFCN;
}
// Fingerprint function basic block

View File

@ -253,7 +253,7 @@ static void _6502_anal_esil_mov(RAnalOp *op, ut8 data0) {
static void _6502_anal_esil_push(RAnalOp *op, ut8 data0) {
// case 0x08: // php
// case 0x48: // pha
char *reg = (data0==0x08) ? "flags" : "a";
char *reg = (data0 == 0x08) ? "flags" : "a";
// stack is on page one: sp + 0x100
r_strbuf_setf (&op->esil, "%s,sp,0x100,+,=[1],sp,--=", reg);
}
@ -261,7 +261,7 @@ static void _6502_anal_esil_push(RAnalOp *op, ut8 data0) {
static void _6502_anal_esil_pop(RAnalOp *op, ut8 data0) {
// case 0x28: // plp
// case 0x68: // pla
char *reg = (data0==0x28) ? "flags" : "a";
char *reg = (data0 == 0x28) ? "flags" : "a";
// stack is on page one: sp + 0x100
r_strbuf_setf (&op->esil, "sp,++=,sp,0x100,+,[1],%s,=", reg);
@ -271,7 +271,7 @@ static void _6502_anal_esil_pop(RAnalOp *op, ut8 data0) {
}
static void _6502_anal_esil_flags(RAnalOp *op, ut8 data0) {
int enabled=0;
int enabled = 0;
char flag ='u';
switch(data0) {
case 0x78: // sei
@ -441,7 +441,8 @@ static int _6502_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
op->type = R_ANAL_OP_TYPE_SWI;
// override 65816 code which seems to be wrong: size is 1, but pc = pc + 2
op->size = 1;
// PC + 2 to Stack, P to Stack B=1 D=0 I=1. "B" is not a flag. Only its bit is pushed on the stack
// PC + 2 to Stack, P to Stack B=1 D=0 I=1. "B" is not a flag.
// Only its bit is pushed on the stack
// PC was already incremented by one at this point. Needs to incremented once more
// New PC is Interrupt Vector: $fffe. (FIXME: Confirm this is valid for all 6502)
r_strbuf_set (&op->esil, ",1,I,=,0,D,=,flags,0x10,|,0x100,sp,+,=[1],pc,1,+,0xfe,sp,+,=[2],3,sp,-=,0xfffe,[2],pc,=");

View File

@ -2080,8 +2080,8 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
case ARM64_INS_STP: // stp x6, x7, [x6,0xf90]
{
int disp = (int)MEMDISP64 (2);
char sign = disp>=0?'+':'-';
st64 abs = disp>=0? MEMDISP64 (2): -(st64)MEMDISP64 (2);
char sign = (disp >= 0)?'+':'-';
st64 abs = (disp >= 0)? MEMDISP64 (2): -(st64)MEMDISP64 (2);
int size = REGSIZE64 (0);
// Pre-index case
if (ISPREINDEX64 ()) {
@ -2095,8 +2095,8 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
// Post-index case
} else if (ISPOSTINDEX64 ()) {
int val = IMM64 (3);
sign = val>=0?'+':'-';
abs = val>=0? val: -val;
sign = (val >= 0)?'+':'-';
abs = (val >= 0)? val: -val;
// "stp x4, x5, [x8], 0x10"
// "x4,x8,=[],x5,x8,8,+,=[],16,x8,+="
r_strbuf_setf(&op->esil,
@ -2117,8 +2117,8 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
case ARM64_INS_LDP: // ldp x29, x30, [sp], 0x10
{
int disp = (int)MEMDISP64 (2);
char sign = disp>=0?'+':'-';
ut64 abs = disp>=0? MEMDISP64 (2): (ut64)(-MEMDISP64 (2));
char sign = (disp >= 0)? '+': '-';
ut64 abs = (disp >= 0)? MEMDISP64 (2): (ut64)(-MEMDISP64 (2));
int size = REGSIZE64 (0);
// Pre-index case
// x2,x8,32,+,=[8],x3,x8,32,+,8,+,=[8]
@ -2135,8 +2135,8 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
// Post-index case
} else if (ISPOSTINDEX64 ()) {
int val = IMM64 (3);
sign = val>=0?'+':'-';
abs = val>=0? val: -val;
sign = (val >= 0)?'+':'-';
abs = (val >= 0)? val: -val;
// ldp x4, x5, [x8], -0x10
// x8,[8],x4,=,x8,8,+,[8],x5,=,16,x8,+=
r_strbuf_setf (&op->esil,
@ -2739,8 +2739,8 @@ r6,r5,r4,3,sp,[*],12,sp,+=
if (OPCOUNT() == 2) {
if (ISMEM(1) && !HASMEMINDEX(1)) {
int disp = MEMDISP (1);
char sign = disp>=0?'+':'-';
disp = disp>=0?disp:-disp;
char sign = (disp >= 0)?'+':'-';
disp = (disp >= 0)? disp: -disp;
r_strbuf_appendf (&op->esil, "%s,0x%x,%s,%c,0xffffffff,&,=[%d]",
REG(0), disp, MEMBASE(1), sign, str_ldr_bytes);
if (insn->detail->arm.writeback) {
@ -2836,11 +2836,11 @@ r6,r5,r4,3,sp,[*],12,sp,+=
REG(0), MEMBASE(1), str_ldr_bytes, REG(2), MEMBASE(1));
}
}
if (ISREG(1) && str_ldr_bytes==8) { // e.g. 'strd r2, r3, [r4]', normally should be the only case for ISREG(1).
if (ISREG (1) && str_ldr_bytes == 8) { // e.g. 'strd r2, r3, [r4]', normally should be the only case for ISREG(1).
if (!HASMEMINDEX(2)) {
int disp = MEMDISP(2);
char sign = disp>=0?'+':'-';
disp = disp>=0?disp:-disp;
int disp = MEMDISP (2);
char sign = (disp >= 0)?'+':'-';
disp = (disp >= 0)? disp: -disp;
r_strbuf_appendf (&op->esil, "%s,%d,%s,%c,0xffffffff,&,=[4],%s,4,%d,+,%s,%c,0xffffffff,&,=[4]",
REG(0), disp, MEMBASE(2), sign, REG(1), disp, MEMBASE(2), sign);
if (insn->detail->arm.writeback) {
@ -2848,7 +2848,7 @@ r6,r5,r4,3,sp,[*],12,sp,+=
disp, MEMBASE(2), sign, MEMBASE(2));
}
} else {
if (ISSHIFTED(2)) {
if (ISSHIFTED (2)) {
// it seems strd does not support SHIFT which is good, but have a check nonetheless
} else {
r_strbuf_appendf (&op->esil, "%s,%s,%s,+,0xffffffff,&,=[4],%s,4,%s,+,%s,+,0xffffffff,&,=[4]",
@ -4446,7 +4446,7 @@ static R_TH_LOCAL int obits = 32;
static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
cs_insn *insn = NULL;
int mode = (a->config->bits==16)? CS_MODE_THUMB: CS_MODE_ARM;
int mode = (a->config->bits == 16)? CS_MODE_THUMB: CS_MODE_ARM;
int n, ret;
mode |= (a->config->big_endian)? CS_MODE_BIG_ENDIAN: CS_MODE_LITTLE_ENDIAN;
if (R_STR_ISNOTEMPTY (a->config->cpu)) {
@ -4546,7 +4546,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAn
}
static char *arm_mnemonics(RAnal *a, int id, bool json) {
int mode = (a->config->bits==16)? CS_MODE_THUMB: CS_MODE_ARM;
int mode = (a->config->bits == 16)? CS_MODE_THUMB: CS_MODE_ARM;
mode |= (a->config->big_endian)? CS_MODE_BIG_ENDIAN: CS_MODE_LITTLE_ENDIAN;
if (R_STR_ISNOTEMPTY (a->config->cpu)) {
if (strstr (a->config->cpu, "cortex")) {

View File

@ -2224,8 +2224,8 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
case ARM64_STP: // stp x6, x7, [x6,0xf90]
{
int disp = (int)MEMDISP64 (2);
char sign = disp>=0?'+':'-';
ut64 abs = disp>=0? MEMDISP64 (2): -MEMDISP64 (2);
char sign = (disp >= 0)?'+':'-';
ut64 abs = (disp >= 0)? MEMDISP64 (2): -MEMDISP64 (2);
int size = REGSIZE64 (0);
// Pre-index case
if (ISPREINDEX64 ()) {
@ -2239,8 +2239,8 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
// Post-index case
} else if (ISPOSTINDEX64 ()) {
int val = GETIMM64 (3);
sign = val>=0?'+':'-';
abs = val>=0? val: -val;
sign = (val >= 0)?'+':'-';
abs = (val >= 0)? val: -val;
// "stp x4, x5, [x8], 0x10"
// "x4,x8,=[],x5,x8,8,+,=[],16,x8,+="
r_strbuf_setf(&op->esil,
@ -2262,8 +2262,8 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
case ARM64_LDP: // ldp x29, x30, [sp], 0x10
{
int disp = (int)MEMDISP64 (2);
char sign = disp>=0?'+':'-';
ut64 abs = disp>=0? MEMDISP64 (2): -MEMDISP64 (2);
char sign = (disp >= 0)?'+':'-';
ut64 abs = (disp >= 0)? MEMDISP64 (2): -MEMDISP64 (2);
int size = REGSIZE64 (0);
// Pre-index case
// x2,x8,32,+,=[8],x3,x8,32,+,8,+,=[8]
@ -2280,8 +2280,8 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
// Post-index case
} else if (ISPOSTINDEX64 ()) {
int val = GETIMM64 (3);
sign = val>=0?'+':'-';
abs = val>=0? val: -val;
sign = (val >= 0)? '+': '-';
abs = (val >= 0)? val: -val;
// ldp x4, x5, [x8], -0x10
// x8,[8],x4,=,x8,8,+,[8],x5,=,16,x8,+=
r_strbuf_setf (&op->esil,

View File

@ -239,7 +239,7 @@ static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
// the easy parts though
if (IN_SWITCH_OP) {
NUM_CASES_SEEN++;
if (NUM_CASES_SEEN == SWITCH_OP_CASES) IN_SWITCH_OP=0;
if (NUM_CASES_SEEN == SWITCH_OP_CASES) { IN_SWITCH_OP = 0; }
op->addr = addr;
op->size = 4;
op->type2 = 0;

View File

@ -199,7 +199,7 @@ static const char *arg(csh *handle, cs_insn *insn, char *buf, int n) {
return buf;
}
#define ARG(x) (*str[x]!=0)?str[x]:arg(handle, insn, str[x], x)
#define ARG(x) (*str[x] != 0)?str[x]:arg(handle, insn, str[x], x)
static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn) {
char str[8][32] = {{0}};
@ -876,8 +876,8 @@ static int analop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
case MIPS_INS_JRADDIUSP:
case MIPS_INS_BAL:
// (no blezal/bgtzal or blezall/bgtzall, only blezalc/bgtzalc)
case MIPS_INS_BLTZAL: // Branch on <0 and link
case MIPS_INS_BGEZAL: // Branch on >=0 and link
case MIPS_INS_BLTZAL: // Branch on < 0 and link
case MIPS_INS_BGEZAL: // Branch on >= 0 and link
case MIPS_INS_BLTZALL: // "likely" versions
case MIPS_INS_BGEZALL:
case MIPS_INS_BLTZALC: // compact versions

View File

@ -846,7 +846,7 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, gnu_insn*insn) {
break;
case MIPS_INS_JALR:
case MIPS_INS_JALRS:
if (strcmp(R_REG(rd), "rd")==0) {
if (!strcmp (R_REG (rd), "rd")) {
r_strbuf_appendf (&op->esil, ES_TRAP_DS () "" ES_CALL_D ("%s"), R_REG (rs));
} else {
r_strbuf_appendf (&op->esil, ES_TRAP_DS () "" ES_CALL_DR ("%s", "%s"), R_REG (rd), R_REG (rs));
@ -1495,8 +1495,8 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, R
insn.id = MIPS_INS_BGEZ;
break;
case 17: //bal bgezal
if (rs==0) {
op->jump = addr+(imm<<2)+4;
if (rs == 0) {
op->jump = addr + (imm << 2) + 4;
snprintf ((char *)insn.i_reg.jump, REG_BUF_MAX, "0x%"PFMT64x, op->jump) ;
insn.id = MIPS_INS_BAL;
} else {

View File

@ -178,7 +178,7 @@ static const char *arg(csh *handle, cs_insn *insn, char *buf, int n) {
return buf;
}
#define ARG(x) (*str[x]!=0)?str[x]:arg(handle, insn, str[x], x)
#define ARG(x) (*str[x] != 0)? str[x]: arg (handle, insn, str[x], x)
static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn) {
char str[8][32] = {{0}};

View File

@ -218,7 +218,7 @@ static RAnalValue *anal_fill_im(RAnal *anal, st32 v) {
return ret;
}
/* Implements @(disp,Rn) , size=1 for .b, 2 for .w, 4 for .l */
/* Implements @(disp,Rn), size = 1 for .b, 2 for .w, 4 for .l */
static RAnalValue *anal_fill_reg_disp_mem(RAnal *anal, int reg, st64 delta, st64 size) {
RAnalValue *ret = anal_fill_ai_rg (anal, reg);
ret->memref = size;
@ -412,7 +412,7 @@ static int first_nibble_is_0(RAnal* anal, RAnalOp* op, ut16 code) { //STOP
return op->size;
}
//nibble=1; 0001nnnnmmmmi4*4 mov.l <REG_M>,@(<disp>,<REG_N>)
//nibble = 1; 0001nnnnmmmmi4*4 mov.l <REG_M>,@(<disp>,<REG_N>)
static int movl_reg_rdisp(RAnal* anal, RAnalOp* op, ut16 code) {
op->type = R_ANAL_OP_TYPE_STORE;
op->src[0] = anal_fill_ai_rg (anal, GET_SOURCE_REG (code));
@ -746,7 +746,7 @@ static int first_nibble_is_4(RAnal* anal, RAnalOp* op, ut16 code) {
"*,"
"0xffffffff00000000,&,>>,mach,=," //MACH > mach
"0xffffffff,&,macl,=,"
"}{," //if S==1
"}{," //if S == 1
S16_EXT("r%d,[2]")"," //@Rn sign extended
S16_EXT("r%d,[2]")"," //@Rm sign extended
"*"
@ -927,7 +927,7 @@ static int movw_pcdisp_reg(RAnal* anal, RAnalOp* op, ut16 code) {
op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG (code));
op->src[0] = r_anal_value_new ();
op->src[0]->base = (code & 0xFF) * 2+op->addr + 4;
op->src[0]->memref=1;
op->src[0]->memref = 1;
r_strbuf_setf (&op->esil, "0x%" PFMT64x ",[2],r%d,=,r%d,0x8000,&,?{,0xFFFF0000,r%d,|=,}", op->src[0]->base, GET_TARGET_REG (code), GET_TARGET_REG (code), GET_TARGET_REG (code));
return op->size;
}

View File

@ -32,9 +32,9 @@ call = 4
#define CSINC X86
#define CSINC_MODE \
(a->config->bits==64)? CS_MODE_64: \
(a->config->bits==32)? CS_MODE_32: \
(a->config->bits==16)? CS_MODE_16: 0
(a->config->bits == 64)? CS_MODE_64: \
(a->config->bits == 32)? CS_MODE_32: \
(a->config->bits == 16)? CS_MODE_16: 0
#include "capstone.inc"
#define opexprintf(op, fmt, ...) r_strbuf_setf (&op->opex, fmt, ##__VA_ARGS__)
@ -331,16 +331,16 @@ static char *getarg(struct Getarg* gop, int n, int set, char *setop, int sel, ut
size_t len = strlen (setarg);
if (len > 0 && setarg[len - 1] == ',') {
snprintf (buf_, BUF_SZ, "%s,%s%s=[%d]", out, setarg,
gop->bits == 32 ? "0xffffffff,&," : "", op.size==10?8:op.size);
gop->bits == 32 ? "0xffffffff,&," : "", op.size == 10? 8: op.size);
} else {
snprintf (buf_, BUF_SZ, "%s,%s=[%d]", out, setarg, op.size==10?8:op.size);
snprintf (buf_, BUF_SZ, "%s,%s=[%d]", out, setarg, op.size == 10? 8: op.size);
}
strncpy (out, buf_, BUF_SZ);
} else if (set == 0) {
if (!*out) {
strcpy (out, "0");
}
snprintf (buf_, BUF_SZ, "%s,[%d]", out, op.size==10? 8: op.size);
snprintf (buf_, BUF_SZ, "%s,[%d]", out, op.size == 10? 8: op.size);
strncpy (out, buf_, BUF_SZ);
}
out[BUF_SZ - 1] = 0;
@ -789,7 +789,7 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
int width = INSOP(0).size;
src = (char *)cs_reg_name(*handle, INSOP(1).mem.base);
dst = (char *)cs_reg_name(*handle, INSOP(0).mem.base);
const char *counter = (bits==16)?"cx": (bits==32)?"ecx":"rcx";
const char *counter = (bits == 16)?"cx": (bits==32)?"ecx":"rcx";
esilprintf (op, "%s,!,?{,BREAK,},%s,NUM,%s,NUM,"\
"%s,[%d],%s,=[%d],df,?{,%d,%s,-=,%d,%s,-=,},"\
"df,!,?{,%d,%s,+=,%d,%s,+=,},%s,--=,%s," \
@ -1298,7 +1298,7 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
case X86_INS_LOOPE:
case X86_INS_LOOPNE:
{
const char *cnt = (bits==16)?"cx":(bits==32)?"ecx":"rcx";
const char *cnt = (bits == 16)? "cx": (bits == 32)?"ecx":"rcx";
dst = getarg (&gop, 0, 2, NULL, DST_AR, NULL);
switch (insn->id) {
case X86_INS_JL:
@ -1765,9 +1765,9 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
//
if (arg0) {
int width = INSOP(0).size;
const char *r_quot = (width==1)?"al": (width==2)?"ax": (width==4)?"eax":"rax";
const char *r_rema = (width==1)?"ah": (width==2)?"dx": (width==4)?"edx":"rdx";
const char *r_nume = (width==1)?"ax": r_quot;
const char *r_quot = (width == 1)?"al": (width == 2)?"ax": (width == 4)?"eax":"rax";
const char *r_rema = (width == 1)?"ah": (width == 2)?"dx": (width == 4)?"edx":"rdx";
const char *r_nume = (width == 1)?"ax": r_quot;
esilprintf (op, "%d,%s,~,%d,%s,<<,%s,+,~%%,%d,%s,~,%d,%s,<<,%s,+,~/,%s,=,%s,=",
width*8, arg0, width*8, r_rema, r_nume, width*8, arg0, width*8, r_rema, r_nume, r_quot, r_rema);
@ -1786,9 +1786,9 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
{
int width = INSOP(0).size;
dst = getarg (&gop, 0, 0, NULL, DST_AR, NULL);
const char *r_quot = (width==1)?"al": (width==2)?"ax": (width==4)?"eax":"rax";
const char *r_rema = (width==1)?"ah": (width==2)?"dx": (width==4)?"edx":"rdx";
const char *r_nume = (width==1)?"ax": r_quot;
const char *r_quot = (width == 1)?"al": (width == 2)?"ax": (width == 4)?"eax":"rax";
const char *r_rema = (width == 1)?"ah": (width == 2)?"dx": (width == 4)?"edx":"rdx";
const char *r_nume = (width == 1)?"ax": r_quot;
// DIV does not change flags and is unsigned
esilprintf (op, "%s,%d,%s,<<,%s,+,%%,%s,%d,%s,<<,%s,+,/,%s,=,%s,=",
@ -1812,9 +1812,9 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
width*8, multiplier, width*8, arg1, arg0, width*8, arg0);
} else {
if (arg0) {
const char *r_quot = (width==1)?"al": (width==2)?"ax": (width==4)?"eax":"rax";
const char *r_rema = (width==1)?"ah": (width==2)?"dx": (width==4)?"edx":"rdx";
const char *r_nume = (width==1)?"ax": r_quot;
const char *r_quot = (width == 1)?"al": (width==2)?"ax": (width==4)?"eax":"rax";
const char *r_rema = (width == 1)?"ah": (width==2)?"dx": (width==4)?"edx":"rdx";
const char *r_nume = (width == 1)?"ax": r_quot;
if (width == 8) { // TODO still needs to be fixed to handle correct signed 128 bit value
esilprintf (op, "%s,%s,L*,%s,=,DUP,%s,=,!,!,DUP,cf,:=,of,:=", // flags will be sometimes wrong
@ -1832,9 +1832,9 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len,
src = getarg (&gop, 0, 0, NULL, SRC_AR, NULL);
if (src) {
int width = INSOP(0).size;
const char *r_quot = (width==1)?"al": (width==2)?"ax": (width==4)?"eax":"rax";
const char *r_rema = (width==1)?"ah": (width==2)?"dx": (width==4)?"edx":"rdx";
const char *r_nume = (width==1)?"ax": r_quot;
const char *r_quot = (width == 1)?"al": (width == 2)?"ax": (width == 4)?"eax":"rax";
const char *r_rema = (width == 1)?"ah": (width == 2)?"dx": (width == 4)?"edx":"rdx";
const char *r_nume = (width == 1)?"ax": r_quot;
if ( width == 8 ) {
esilprintf (op, "%s,%s,L*,%s,=,DUP,%s,=,!,!,DUP,cf,:=,of,:=",

View File

@ -14,11 +14,11 @@
#define AMD29K_SET_INVALID(x,i) ((x)->type[(i)]=AMD29K_TYPE_UNK)
#define AMD29K_HAS_BIT(x) (((x)[0] & 1))
// Global registers
#define AMD29K_IS_REG_GR(x) ((x)>=0&&(x)<128)
#define AMD29K_IS_REG_GR(x) ((x) >= 0 && (x) < 128)
// Local registers
#define AMD29K_IS_REG_LR(x) ((x)>=128&&(x)<256)
#define AMD29K_IS_REG_LR(x) ((x) >= 128 && (x) < 256)
#define AMD29K_REGNAME(x) (AMD29K_IS_REG_GR(x)?"gr":"lr")
#define AMD29K_LR(x) (AMD29K_IS_REG_GR(x)?(x):(x)-127)
#define AMD29K_LR(x) (AMD29K_IS_REG_GR(x)? (x): (x)-127)
static void decode_ra_rb_rci(amd29k_instr_t* instruction, const ut8* buffer) {
AMD29K_SET_VALUE (instruction, 0, buffer[1], AMD29K_TYPE_REG);

View File

@ -2748,9 +2748,9 @@ aarch64_operand_index (const enum aarch64_opnd *operands, enum aarch64_opnd oper
R (16), R (17), R (18), R (19), R (20), R (21), R (22), R (23), \
R (24), R (25), R (26), R (27), R (28), R (29), R (30), FOR31 }
/* [0][0] 32-bit integer regs with sp Wn
[0][1] 64-bit integer regs with sp Xn sf=1
[0][1] 64-bit integer regs with sp Xn sf = 1
[1][0] 32-bit integer regs with #0 Wn
[1][1] 64-bit integer regs with #0 Xn sf=1 */
[1][1] 64-bit integer regs with #0 Xn sf = 1 */
static const char *int_reg[2][2][32] = {
#define R32(X) "w" #X
#define R64(X) "x" #X

View File

@ -598,8 +598,8 @@ static char *getrange(char *s) {
char *p = NULL;
while (s && *s) {
if (*s == ',') {
p = s+1;
*p=0;
p = s + 1;
*p = 0;
}
if (*s == '[' || *s == ']') {
memmove (s, s + 1, strlen (s + 1) + 1);
@ -632,7 +632,7 @@ static int getreg(const char *str) {
return reg;
}
}
for (i=0; aliases[i]; i++) {
for (i = 0; aliases[i]; i++) {
if (!strcmpnull (str, aliases[i])) {
return 10 + i;
}
@ -1189,7 +1189,7 @@ static inline int arm_opcode_cond(ArmOpcode *ao, int delta) {
};
int i, cond = 14; // 'always' is default
char *c = ao->op+delta;
for (i=0; conds[i]; i++) {
for (i = 0; conds[i]; i++) {
if (!strcmpnull (c, conds[i])) {
cond = i;
break;
@ -5078,7 +5078,7 @@ static int thumb_assemble(ArmOpcode *ao, ut64 off, const char *str) {
ut8 reg3 = getregmemstart (ao->a[2]);
st32 num = getnummemend (ao->a[3]);
if ((strsel != 0) || (reg1 > 15) || (reg2 > 15) || (reg3 > 15) || (num < 0) || (num > 1023) || ((num % 4) !=0)) {
if ((strsel != 0) || (reg1 > 15) || (reg2 > 15) || (reg3 > 15) || (num < 0) || (num > 1023) || ((num % 4) != 0)) {
return -1;
}

View File

@ -5150,7 +5150,7 @@ const int powerpc_num_opcodes =
/* The macro table. This is only used by the assembler. */
/* The expressions of the form (-x ! 31) & (x | 31) have the value 0
when x=0; 32-x when x is between 1 and 31; are negative if x is
when x = 0; 32-x when x is between 1 and 31; are negative if x is
negative; and are 32 or more otherwise. This is what you want
when, for instance, you are emulating a right shift by a
rotate-left-and-mask, because the underlying instructions support

View File

@ -71,7 +71,7 @@ print_insn_shx (bfd_vma memaddr, struct disassemble_info *info)
int rn = 0;
int rm = 0;
int rb = 0;
int disp_pc=0;
int disp_pc = 0;
bfd_vma disp_pc_addr = 0;
for (n = 0; n < 4; n++)
@ -354,7 +354,7 @@ print_insn_shx (bfd_vma memaddr, struct disassemble_info *info)
val=(info->flags & LITTLE_BIT)? bfd_getl32 (bytes):bfd_getb32 (bytes);
}
// XXX this will not work until read_memory_func() is fixed.
//fprintf_fn (stream, " ;[0x%X]=0x%X", (unsigned int) disp_pc_addr, val);
//fprintf_fn (stream, " ;[0x%X] = 0x%X", (unsigned int) disp_pc_addr, val);
}
return 2;

View File

@ -50,17 +50,17 @@ static int decode_fixed(struct state *s, struct directive *d) {
return 0;
}
s->s_nop++;
strcpy(d->d_asm, "nop");
strcpy (d->d_asm, "nop");
break;
case INST_BRK: strcpy(d->d_asm, "brk"); break;
case INST_SLEEP: strcpy(d->d_asm, "sleep"); break;
case INST_SIF: strcpy(d->d_asm, "sif"); break;
case INST_BC: strcpy(d->d_asm, "bc"); break;
case INST_BRXL: strcpy(d->d_asm, "brxl"); break;
case INST_U: strcpy(d->d_asm, ""); s->s_u = 1; break;
case INST_RTS: strcpy(d->d_asm, "rts"); break;
case INST_BRK: strcpy (d->d_asm, "brk"); break;
case INST_SLEEP: strcpy (d->d_asm, "sleep"); break;
case INST_SIF: strcpy (d->d_asm, "sif"); break;
case INST_BC: strcpy (d->d_asm, "bc"); break;
case INST_BRXL: strcpy (d->d_asm, "brxl"); break;
case INST_U: strcpy (d->d_asm, ""); s->s_u = 1; break;
case INST_RTS: strcpy (d->d_asm, "rts"); break;
}
return d->d_asm[0]!=0;
return d->d_asm[0] != 0;
}
static char *regname(int reg) {

View File

@ -55,7 +55,7 @@ fail:
return false;
}
static int r_bin_bflt_init(struct r_bin_bflt_obj *obj, RBuffer *buf) {
static bool r_bin_bflt_init(RBinBfltObj *obj, RBuffer *buf) {
obj->b = r_buf_ref (buf);
obj->size = r_buf_size (buf);
obj->endian = false;
@ -69,19 +69,20 @@ static int r_bin_bflt_init(struct r_bin_bflt_obj *obj, RBuffer *buf) {
return true;
}
R_API void r_bin_bflt_free(struct r_bin_bflt_obj *obj) {
if (obj) {
R_FREE (obj->hdr);
r_buf_free (obj->b);
R_FREE (obj);
R_IPI void r_bin_bflt_free(RBinBfltObj *o) {
if (o) {
R_FREE (o->hdr);
r_buf_free (o->b);
free (o);
}
}
R_API struct r_bin_bflt_obj *r_bin_bflt_new_buf(RBuffer *buf) {
struct r_bin_bflt_obj *bin = R_NEW0 (struct r_bin_bflt_obj);
if (bin && r_bin_bflt_init (bin, buf)) {
return bin;
R_IPI RBinBfltObj *r_bin_bflt_new_buf(RBuffer *buf) {
r_return_val_if_fail (buf, NULL);
RBinBfltObj *o = R_NEW0 (RBinBfltObj);
if (o && r_bin_bflt_init (o, buf)) {
return o;
}
r_bin_bflt_free (bin);
r_bin_bflt_free (o);
return NULL;
}

View File

@ -15,7 +15,7 @@
#define FLAT_FLAG_GZDATA 0x8 /* only data/relocs are compressed (for XIP) */
#define FLAT_FLAG_KTRACE 0x10 /* output useful kernel trace for debugging */
struct bflt_hdr {
typedef struct bflt_hdr {
ut8 magic[4];
ut32 rev;
ut32 entry;
@ -28,28 +28,28 @@ struct bflt_hdr {
ut32 flags;
ut32 build_date;
ut32 filler[5];
};
} RBinBfltHeader;
struct reloc_struct_t {
typedef struct reloc_struct_t {
ut32 addr_to_patch;
ut32 data_offset;
};
} RBinBfltReloc;
struct r_bin_bflt_obj {
struct bflt_hdr *hdr;
struct reloc_struct_t *reloc_table;
struct reloc_struct_t *got_table;
typedef struct r_bin_bflt_obj {
RBinBfltHeader *hdr;
RBinBfltReloc *reloc_table;
RBinBfltReloc *got_table;
RBuffer *b;
ut8 endian;
size_t size;
ut32 n_got;
};
} RBinBfltObj;
#define BFLT_HDR_SIZE sizeof (struct bflt_hdr)
#define BFLT_HDR_SIZE sizeof (RBinBfltHeader)
#define VALID_GOT_ENTRY(x) (x != UT32_MAX)
R_API RBinAddr *r_bflt_get_entry(struct r_bin_bflt_obj *bin);
R_API struct r_bin_bflt_obj *r_bin_bflt_new_buf(RBuffer *buf);
R_API void r_bin_bflt_free(struct r_bin_bflt_obj *obj);
R_IPI RBinAddr *r_bflt_get_entry(RBinBfltObj *bin);
R_IPI RBinBfltObj *r_bin_bflt_new_buf(RBuffer *buf);
R_IPI void r_bin_bflt_free(RBinBfltObj *obj);
#endif

View File

@ -3023,7 +3023,7 @@ static RBinElfSection *get_sections_from_phdr(ELFOBJ *bin) {
RBinElfSection* Elf_(r_bin_elf_get_sections)(ELFOBJ *bin) {
RBinElfSection *ret = NULL;
char unknown_s[32], invalid_s[32];
int i, nidx, unknown_c=0, invalid_c=0;
int i, nidx, unknown_c = 0, invalid_c = 0;
r_return_val_if_fail (bin, NULL);
if (bin->g_sections) {

View File

@ -3550,7 +3550,7 @@ d_expr_primary (struct d_info *di)
floating point literal here. The ABI specifies that the
format of such literals is machine independent. That's fine,
but what's not fine is that versions of g++ up to 3.2 with
-fabi-version=1 used upper case letters in the hex constant,
-fabi-version = 1 used upper case letters in the hex constant,
and dumped out gcc's internal representation. That makes it
hard to tell where the constant ends, and hard to dump the
constant in any readable form anyhow. We don't attempt to
@ -3647,7 +3647,7 @@ d_local_name (struct d_info *di)
/* <discriminator> ::= _ <number> # when number < 10
::= __ <number> _ # when number >= 10
<discriminator> ::= _ <number> # when number >=10
<discriminator> ::= _ <number> # when number >= 10
is also accepted to support gcc versions that wrongly mangled that way.
We demangle the discriminator, but we don't print it out. FIXME:

View File

@ -28,9 +28,9 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data,
const bool use_linkedit = true;
ut64 filesize, codeva, datava;
ut32 ncmds, magiclen, headerlen;
ut64 p_codefsz=0, p_codeva=0, p_codesz=0, p_codepa=0;
ut64 p_datafsz=0, p_datava=0, p_datasz=0, p_datapa=0;
ut64 p_cmdsize=0, p_entry=0, p_tmp=0;
ut64 p_codefsz = 0, p_codeva = 0, p_codesz = 0, p_codepa = 0;
ut64 p_datafsz = 0, p_datava = 0, p_datasz = 0, p_datapa = 0;
ut64 p_cmdsize = 0, p_entry = 0, p_tmp = 0;
ut64 baddr = 0x100001000LL;
// TODO: baddr must be overriden with -b
RBuffer *buf = r_buf_new ();

View File

@ -161,8 +161,7 @@ static RList* sections(RBinFile *bf) {
}
} else {
for (i=0; i < ((bf->size - hdroffset)/ 0x8000) ; i++) {
for (i = 0; i < ((bf->size - hdroffset)/ 0x8000) ; i++) {
addrom(ret,"ROM",i,hdroffset + i*0x8000,0x8000 + (i*0x10000), 0x8000);
}
}

View File

@ -3,14 +3,13 @@
#include "stream_file.h"
///////////////////////////////////////////////////////////////////////////////
void parse_pe_stream(void *stream, R_STREAM_FILE *stream_file)
{
void parse_pe_stream(void *stream, R_STREAM_FILE *stream_file) {
int data_size = 0;
char *data = 0, *ptmp = 0;
int read_bytes = 0;
SIMAGE_SECTION_HEADER *sctn_header = 0;
SPEStream *pe_stream = (SPEStream *) stream;
int sctn_header_size =0;
int sctn_header_size = 0;
stream_file_get_size (stream_file, &data_size);
data = (char *) malloc (data_size);

View File

@ -10,11 +10,14 @@ R_LIB_VERSION (r_cons);
// Stub function that cb_main_output gets pointed to in util/log.c by r_cons_new
// This allows Iaito to set per-task logging redirection
static R_TH_LOCAL int oldraw = -1;
static R_TH_LOCAL RThreadLock *lock = NULL;
static R_TH_LOCAL RConsContext r_cons_context_default = {{{{0}}}};
static R_TH_LOCAL RCons g_cons_instance = {0};
static R_TH_LOCAL RCons *r_cons_instance = NULL;
static R_TH_LOCAL RThreadLock r_cons_lock = R_THREAD_LOCK_INIT;
static R_TH_LOCAL ut64 prev = 0LL; //r_time_now_mono ();
static R_TH_LOCAL RStrBuf *echodata = NULL; // TODO: move into RConsInstance? maybe nope
#define I (r_cons_instance)
#define C (getctx())
@ -973,7 +976,6 @@ static bool lastMatters(void) {
}
R_API void r_cons_echo(const char *msg) {
static R_TH_LOCAL RStrBuf *echodata = NULL; // TODO: move into RConsInstance? maybe nope
if (msg) {
if (echodata) {
r_strbuf_append (echodata, msg);
@ -1207,7 +1209,6 @@ R_API void r_cons_visual_flush(void) {
R_API void r_cons_print_fps(int col) {
int fps = 0, w = r_cons_get_size (NULL);
static R_TH_LOCAL ut64 prev = 0LL; //r_time_now_mono ();
fps = 0;
if (prev) {
ut64 now = r_time_now_mono ();
@ -1829,13 +1830,12 @@ R_API void r_cons_show_cursor(int cursor) {
*
* For optimization reasons, there's no initialization flag, so you need to
* ensure that the make the first call to r_cons_set_raw() with '1' and
* the next calls ^=1, so: 1, 0, 1, 0, 1, ...
* the next calls ^= 1, so: 1, 0, 1, 0, 1, ...
*
* If you doesn't use this order you'll probably loss your terminal properties.
*
*/
R_API void r_cons_set_raw(bool is_raw) {
static R_TH_LOCAL int oldraw = -1;
if (oldraw != -1) {
if (is_raw == oldraw) {
return;

View File

@ -111,7 +111,7 @@ static void dorender(PrintfCallback cb_printf, const ut8 *buf, int len, int w, i
const ut8 *c, *d;
int x, y;
for (y = 0; y < h; y += 2) {
for (x=0; x < w; x++) {
for (x = 0; x < w; x++) {
c = XY (buf, x, y);
d = XY (buf, x, y + 1);
if (d + 3 > (buf + len)) {

View File

@ -548,7 +548,7 @@ R_API bool core_anal_bbs_range(RCore *core, const char* input) {
lista[idx++] = b_start;
for (x = 0; x < 1024; x++) {
if (lista[x] != 0) {
cur =0;
cur = 0;
b_start = lista[x];
lista[x] = 0;
while (cur < size) {

View File

@ -971,7 +971,7 @@ static int cmd_rap(void *data, const char *input) {
case '!': // "=!"
if (input[1] == 'q') {
R_FREE (core->cmdremote);
} else if (input[1] == '=') { // =!=0 or =!= for iosystem
} else if (input[1] == '=') { // =!= or =!= for iosystem
R_FREE (core->cmdremote);
core->cmdremote = r_str_trim_dup (input + 2);
} else {

View File

@ -1428,7 +1428,7 @@ static void list_vars(RCore *core, RAnalFunction *fcn, PJ *pj, int type, const c
r_cons_printf ("f-fcnvar*\n");
r_list_foreach (list, iter, var) {
r_cons_printf ("f fcnvar.%s @ %s%s%d\n", var->name, bp,
var->delta>=0? "+":"", var->delta);
var->delta >= 0? "+":"", var->delta);
}
r_list_free (list);
return;
@ -3236,10 +3236,10 @@ static void r_core_anal_nofunclist(RCore *core, const char *input) {
}
}
chunk_size = 0;
chunk_offset = i+1;
chunk_offset = i + 1;
continue;
}
chunk_size+=1;
chunk_size += 1;
}
if (chunk_size >= 16) {
fcn = r_anal_get_fcn_in (core->anal, base_addr+chunk_offset, R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM);
@ -4732,7 +4732,7 @@ static int cmd_af(RCore *core, const char *input) {
case 'B': // "afB" // set function bits
if (input[2] == ' ') {
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0);
if (fcn) { // bits=0 means unset
if (fcn) { // bits = 0 means unset
int nbits = atoi (input + 3);
int obits = core->anal->config->bits;
if (nbits > 0) {
@ -7094,7 +7094,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
break;
case ' ':
case 'q':
//r_anal_esil_eval (core->anal, input+1);
//r_anal_esil_eval (core->anal, input + 1);
if (!esil) {
core->anal->esil = esil = esil_new_setup (core);
if (!esil) {
@ -7566,7 +7566,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
break;
}
default:
cmd_aea (core, 1, core->offset, (int)r_num_math (core->num, input[1]?input+2:input+1));
cmd_aea (core, 1, core->offset, (int)r_num_math (core->num, input[1]? input + 2:input + 1));
}
break;
case 'a': { // "aea"
@ -11913,7 +11913,7 @@ static void cmd_anal_class_vtable(RCore *core, const char *input) {
if (end) {
vtable.offset = r_num_get (core->num, end + 1);
// end + 1 won't work on extra whitespace between arguments, TODO
arg3_str = strchr (end+1, ' ');
arg3_str = strchr (end + 1, ' ');
}
if (arg3_str) {

View File

@ -1014,7 +1014,7 @@ static void macro_meta(RCmdMacro *mac) {
RListIter *iter;
r_list_foreach (mac->macros, iter, m) {
mac->cb_printf ("\"(%s %s; ", m->name, m->args);
for (j=0; m->code[j]; j++) {
for (j = 0; m->code[j]; j++) {
if (m->code[j] == '\n') {
mac->cb_printf (";");
} else {
@ -1039,7 +1039,7 @@ R_API void r_cmd_macro_list(RCmdMacro *mac, int mode) {
RListIter *iter;
r_list_foreach (mac->macros, iter, m) {
mac->cb_printf ("%d (%s %s; ", idx, m->name, m->args);
for (j=0; m->code[j]; j++) {
for (j = 0; m->code[j]; j++) {
if (m->code[j] == '\n') {
mac->cb_printf ("; ");
} else {

View File

@ -1154,7 +1154,7 @@ static int cmd_wu(void *data, const char *input) {
char sign = ' ';
int line = 0, offs = 0, hexa = 0;
int newline = 1;
for (i=0; data[i]; i++) {
for (i = 0; data[i]; i++) {
switch (data[i]) {
case '+':
if (newline)

View File

@ -97,10 +97,10 @@ R_API bool r_core_hack_arm(RCore *core, const char *op, const RAnalOp *analop) {
if (!str) {
return false;
}
for (i=0; i < len; i+=nopsize) {
memcpy (str + i * 2, nopcode, nopsize*2);
for (i = 0; i < len; i+=nopsize) {
memcpy (str + i * 2, nopcode, nopsize * 2);
}
str[len*2] = '\0';
str[len * 2] = '\0';
r_core_cmdf (core, "wx %s", str);
free (str);
} else if (!strcmp (op, "jinf")) {

View File

@ -860,7 +860,7 @@ R_API int r_core_visual_types(RCore *core) {
}
menu--;
option = _option;
if (menu==0) {
if (menu == 0) {
// if no flagspaces, just quit
if (r_flag_space_is_empty (core->flags)) {
return true;
@ -1914,7 +1914,7 @@ R_API int r_core_visual_view_rop(RCore *core) {
delta++;
break;
case 'J':
cur+=10;
cur += 10;
forceaddr = false;
delta = 0;
break;
@ -1922,7 +1922,7 @@ R_API int r_core_visual_view_rop(RCore *core) {
delta = 0;
forceaddr = false;
if (cur > 10) {
cur-=10;
cur -= 10;
} else {
cur = 0;
}
@ -2085,7 +2085,8 @@ R_API int r_core_visual_trackflags(RCore *core) {
option = 0;
}
break;
case 'K': option-=10;
case 'K':
option -= 10;
if (option < 0) {
option = 0;
}
@ -2200,7 +2201,6 @@ R_API int r_core_visual_trackflags(RCore *core) {
format = MAX_FORMAT;
}
break;
// = (format<=0)? MAX_FORMAT: format-1; break;
case 'p': format++; break;
case 'l':
case ' ':
@ -2659,7 +2659,7 @@ R_API void r_core_visual_mounts(RCore *core) {
}
} else if (mode == 1) {
r_cons_printf ("Types:\n\n");
for (i=0;;i++) {
for (i = 0; ; i++) {
n = r_fs_partition_type_get (i);
if (!n) {
break;
@ -3409,7 +3409,7 @@ static char *__prompt(const char *msg, void *p) {
r_cons_show_cursor (true);
r_cons_set_raw (false);
r_line_set_prompt (msg);
res[0] =0;
res[0] = 0;
if (!r_cons_fgets (res, sizeof (res), 0, NULL)) {
res[0] = 0;
}
@ -3657,10 +3657,10 @@ R_API void r_core_visual_anal(RCore *core, const char *input) {
delta = 0;
switch (level) {
case 1:
variable_option = (variable_option<=0)? 0: variable_option-1;
variable_option = (variable_option <= 0)? 0: variable_option-1;
break;
default:
option = (option<=0)? 0: option-1;
option = (option <= 0)? 0: option-1;
break;
}
}

View File

@ -54,7 +54,7 @@ R_API void r_debug_signal_init(RDebug *dbg) {
int i;
// XXX
DB = sdb_new (NULL, "signals", 0);
for (i=0; signals[i].k; i++) {
for (i = 0; signals[i].k; i++) {
sdb_set (DB, signals[i].k, signals[i].v, 0);
sdb_set (DB, signals[i].v, signals[i].k, 0);
}

View File

@ -266,9 +266,9 @@ R_API int bfvm_cont(BfvmCPU *c, ut64 until) {
}
R_API int bfvm_trace(BfvmCPU *c, ut64 until) {
c->trace=1;
c->trace = 1;
bfvm_cont (c, until);
c->trace=0;
c->trace = 0;
return 0;
}

View File

@ -100,7 +100,7 @@ static int r_debug_bochs_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
bochs_send_cmd (desc, "regs", true);
//r14: 00000000_00000000 r15: 00000000_00000000
//rip: 00000000_0000e07b
//eflags 0x00000046: id vip vif ac vm rf nt IOPL=0 of df if tf sf ZF af PF cf
//"eflags 0x00000046: id vip vif ac vm rf nt IOPL=0 of df if tf sf ZF af PF cf"
//<bochs:109>return -1;
pos = 0x78;
lenRec = strlen (desc->data);
@ -155,8 +155,8 @@ static int r_debug_bochs_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid = 1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid = 1
gdtr:base=0x0000000000000000, limit=0xffff
idtr:base=0x0000000000000000, limit=0xffff
*/

View File

@ -1229,7 +1229,7 @@ int linux_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
// stitch together xstate.fpstate._xmm and xstate.ymmh assuming LE
int ri,rj;
for (ri = 0; ri < 16; ri++) {
for (rj=0; rj < 4; rj++) {
for (rj = 0; rj < 4; rj++) {
#ifdef __ANDROID__
ymm_space[ri*8+rj] = ((struct _libc_fpstate*) &xstate.fpstate)->_xmm[ri].element[rj];
#else

View File

@ -45,7 +45,7 @@ vm_address_t get_kernel_base(task_t ___task) {
return 0;
ut64 naddr;
eprintf ("%d vs %d\n", task, ___task);
for (count=128; count; count--) {
for (count = 128; count; count--) {
// get next memory region
naddr = addr;
ret = vm_region_recurse_64 (task, (vm_address_t*)&naddr, (vm_size_t*)&size,
@ -127,7 +127,7 @@ static RList *ios_dbg_maps(RDebug *dbg) {
}
} else contiguous = false;
oldprot = info.protection;
if (info.max_protection!=0 && !contiguous) {
if (info.max_protection != 0 && !contiguous) {
char module_name[1024];
module_name[0] = 0;
#ifndef __POWERPC__
@ -206,18 +206,19 @@ static RList *osx_dbg_maps(RDebug *dbg) {
prev_size = size;
nsubregions = 1;
for (i=0; ; i++) {
for (i = 0; ; i++) {
int done = 0;
address = prev_address + prev_size;
print = 0;
if (prev_size==0)
if (prev_size == 0) {
break;
}
/* Check to see if address space has wrapped around. */
if (address == 0)
if (address == 0) {
done = 1;
}
if (!done) {
count = VM_REGION_BASIC_INFO_COUNT_64;
kret = mach_vm_region (task, (mach_vm_address_t *)&address,
@ -267,7 +268,7 @@ static RList *osx_dbg_maps(RDebug *dbg) {
}
}
#if 0
if (1==0 && rest) { /* XXX never pritn this info here */
if (1 == 0 && rest) { /* XXX never pritn this info here */
addr = 0LL;
addr = (ut64) (ut32) prev_address;
if (num_printed == 0)

View File

@ -66,7 +66,7 @@ R_API REgg *r_egg_new(void) {
goto beach;
}
egg->plugins = r_list_new ();
for (i=0; egg_static_plugins[i]; i++) {
for (i = 0; egg_static_plugins[i]; i++) {
r_egg_add (egg, egg_static_plugins[i]);
}
return egg;

View File

@ -41,7 +41,7 @@ static RBuffer *build(REgg *egg) {
for (i = 0; i < r_buf_size (sc); i++) {
// eprintf ("%02x -> %02x\n", sc->buf[i], sc->buf[i] ^nkey);
if ((r_buf_read8_at (sc, i) ^ nkey)==0) {
if ((r_buf_read8_at (sc, i) ^ nkey) == 0) {
eprintf ("This xor key generates null bytes. Try again.\n");
free (key);
return NULL;

View File

@ -193,39 +193,37 @@ int main(int argc, char **argv) {
#if 1
if (argc > 1) {
mpc_result_t r;
if (mpc_parse_contents(argv[1], Smallc, &r)) {
mpc_ast_print_to(r.output, stderr);
if (mpc_parse_contents (argv[1], Smallc, &r)) {
mpc_ast_print_to (r.output, stderr);
{
int i;
mpc_ast_t *root = r.output;
for (i=0; i < root->children_num; i++) {
for (i = 0; i < root->children_num; i++) {
mpc_ast_t *node = root->children[i];
eprintf ("; TAG = %s (%s)\n", node->tag, node->contents);
processNode (node);
}
}
mpc_ast_delete(r.output);
mpc_ast_delete (r.output);
} else {
mpc_err_print(r.error);
mpc_err_delete(r.error);
mpc_err_print (r.error);
mpc_err_delete (r.error);
}
} else {
mpc_result_t r;
if (mpc_parse_pipe("<stdin>", stdin, Smallc, &r)) {
mpc_ast_print(r.output);
mpc_ast_delete(r.output);
if (mpc_parse_pipe ("<stdin>", stdin, Smallc, &r)) {
mpc_ast_print (r.output);
mpc_ast_delete (r.output);
} else {
mpc_err_print(r.error);
mpc_err_delete(r.error);
mpc_err_print (r.error);
mpc_err_delete (r.error);
}
}
#endif
mpc_cleanup(17, Ident, Number, Character, String, Factor, Term, Lexp, Stmt, Exp,
mpc_cleanup (17, Ident, Number, Character, String, Factor, Term, Lexp, Stmt, Exp,
Vartype, Typeident, Decls, Args, Body, Comment, Procedure, CProcedure,
Sigdef, Includes, Smallc);

View File

@ -4,12 +4,12 @@
*** .hex format description : every line follows this pattern
:SSAAAARR<xx*SS>KK
SS: num of "xx" bytes
AAAA lower 16bits of address for resulting data (==0 for 01, 02, 04 and 05 records)
AAAA lower 16bits of address for resulting data (== 0 for 01, 02, 04 and 05 records)
RR: rec type:
00 data
01 EOF (always SS=0, AAAA=0)
02 extended segment addr reg: (always SS=02, AAAA=0); data = 0x<xxyy> => bits 4..19 of following addresses
04 extended linear addr reg: (always SS=02, AAAA=0); data = 0x<xxyy> => bits 16..31 of following addresses
01 EOF (always SS= 0, AAAA = 0)
02 extended segment addr reg: (always SS = 02, AAAA = 0); data = 0x<xxyy> => bits 4..19 of following addresses
04 extended linear addr reg: (always SS = 02, AAAA = 0); data = 0x<xxyy> => bits 16..31 of following addresses
05 non-standard; could be "start linear address" AKA "entry point".
KK = 0 - (sum of all bytes)
@ -17,7 +17,7 @@ KK = 0 - (sum of all bytes)
**** example records
:02000002fffffe #rec 02 : new seg = 0xffff, so next addresses will be (seg<<4)+AAAA
:02000000556643 #rec 00 : load 2 bytes [0x000f fff0]=0x55; [0x000f fff1]=0x66
:02000000556643 #rec 00 : load 2 bytes [0x000f fff0] = 0x55; [0x000f fff1] = 0x66
:020000040800f2 #rec 04 : new linear addr = 0x0800, so next addresses will be (0x0800 <<16) + AAAA
:10000000480F0020F948000811480008134800086C #rec 00 : load 16 bytes @ 0x0800 0000
:04000005080049099D #rec 05 : entry point = 0x0800 4909 (ignored)
@ -68,7 +68,7 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
ut16 addl0 = rbs->from & 0xffff;
ut16 addh0 = rbs->from >> 16;
ut16 addh1 = rbs->to >> 16;
ut16 tsiz =0;
ut16 tsiz = 0;
if (rbs->size == 0) {
continue;
}
@ -354,8 +354,7 @@ static bool ihex_parse(RBuffer *rbuf, char *str) {
sec_start = segreg;
if (eol) {
// checksum
byte=0; //break checksum if sscanf failed
byte = 0; //break checksum if sscanf failed
if (sscanf (str + 9 + 4, "%02x", &byte) != 1) {
cksum = 1;
}

View File

@ -102,7 +102,7 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
// /proc/pid/mem fails on latest linux
if (fd != -1) {
ret = lseek (fd, addr, SEEK_SET);
if (ret >=0) {
if (ret >= 0) {
// Workaround for the buggy Debian Wheeze's /proc/pid/mem
if (read (fd, buf, len) != -1) {
return ret;

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2008-2011 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2008-2022 pancake */
#include "r_io.h"
#include "r_lib.h"
@ -13,8 +13,9 @@ typedef struct {
#define RIOW32_HANDLE(x) (((RIOW32*)x)->hnd)
static int w32__write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
if (!fd || !fd->data)
if (!fd || !fd->data) {
return -1;
}
return WriteFile (RIOW32_HANDLE (fd), buf, count, NULL, NULL);
}
@ -33,8 +34,9 @@ static bool w32__close(RIODesc *fd) {
}
static ut64 w32__lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
SetFilePointer (RIOW32_HANDLE (fd), offset, 0, !whence?FILE_BEGIN:whence==1?FILE_CURRENT:FILE_END);
return (whence == 0)?offset:whence==1?io->off+offset:ST64_MAX;
int where = !whence? FILE_BEGIN: whence == 1? FILE_CURRENT: FILE_END;
SetFilePointer (RIOW32_HANDLE (fd), offset, 0, where);
return (whence == 0)? offset: (whence == 1)? io->off + offset: ST64_MAX;
}
static bool w32__plugin_open(RIO *io, const char *pathname, bool many) {
@ -74,6 +76,7 @@ RIOPlugin r_io_plugin_w32 = {
.name = "w32",
.desc = "w32 API io",
.license = "LGPL3",
.author = "pancake",
.uris = "w32://",
.open = w32__open,
.close = w32__close,

View File

@ -277,7 +277,7 @@ static void r2pm_setenv(void) {
free (oldpath);
free (r2_prefix);
// GLOBAL=0 # depends on r2pm.global, which is set on r2pm_install
// GLOBAL = 0 # depends on r2pm.global, which is set on r2pm_install
char *python = r_sys_getenv ("PYTHON");
if (!python) {
python = r_file_path ("python3");

View File

@ -1416,7 +1416,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
}
#if 0
if (o && o->info && compute_hashes) {
// TODO: recall with limit=0 ?
// TODO: recall with !limit ?
ut64 limit = r_config_get_i (r->config, "bin.hashlimit");
r_bin_file_set_hashes (r->bin, r_bin_file_compute_hashes (r->bin, limit));
}

View File

@ -193,21 +193,21 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ NULL }
};
for (i=0; ops[i].op; i++) {
for (i = 0; ops[i].op; i++) {
if (!strcmp (ops[i].op, argv[0])) {
if (newstr) {
for (j=k=0;ops[i].str[j]!='\0';j++,k++) {
if (ops[i].str[j]>='1' && ops[i].str[j]<='9') {
const char *w = argv[ ops[i].str[j]-'0' ];
for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) {
if (ops[i].str[j] >= '1' && ops[i].str[j] <= '9') {
const char *w = argv[ops[i].str[j] - '0'];
if (w) {
strcpy (newstr+k, w);
k += strlen(w)-1;
strcpy (newstr + k, w);
k += strlen (w) - 1;
}
} else {
newstr[k] = ops[i].str[j];
}
}
newstr[k]='\0';
newstr[k] = '\0';
}
return true;
}
@ -235,6 +235,7 @@ static int parse(RParse *p, const char *data, char *str) {
char w4[64];
if (!strcmp (data, "invalid")
|| !strcmp (data, "???")
|| !strcmp (data, "nop")
|| !strcmp (data, "DEPRECATED")) {
str[0] = 0;
@ -265,9 +266,9 @@ static int parse(RParse *p, const char *data, char *str) {
;
}
strncpy (w0, buf, sizeof (w0) - 1);
w0[sizeof(w0)-1] = '\0';
w0[sizeof (w0)-1] = '\0';
strncpy (w1, ptr, sizeof (w1) - 1);
w1[sizeof(w1)-1] = '\0';
w1[sizeof (w1)-1] = '\0';
optr=ptr;
ptr2 = strchr (ptr, '}');

View File

@ -66,10 +66,10 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ NULL }
};
for (i=0; ops[i].op; i++) {
for (i = 0; ops[i].op; i++) {
if (!strcmp (ops[i].op, argv[0])) {
if (newstr) {
for (j=k=0;ops[i].str[j]!='\0';j++,k++) {
for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) {
if (can_replace(ops[i].str, j, ops[i].max_operands)) {
const char *w = argv[ ops[i].str[j]-'0' ];
if (w) {
@ -80,7 +80,7 @@ static int replace(int argc, const char *argv[], char *newstr) {
newstr[k] = ops[i].str[j];
}
}
newstr[k]='\0';
newstr[k] = '\0';
}
return true;
}
@ -117,7 +117,7 @@ static int parse(RParse *p, const char *data, char *str) {
if (!(buf = malloc (len + 1))) {
return false;
}
memcpy (buf, data, len+1);
memcpy (buf, data, len + 1);
r_str_replace_in (buf, len+1, ".l", "", 1);
r_str_replace_in (buf, len+1, ".w", "", 1);
@ -137,9 +137,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
;
}
ptr = r_str_trim_head_ro (ptr + 1);
strncpy (w0, buf, WSZ - 1);
strncpy (w1, ptr, WSZ - 1);
@ -147,9 +145,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
;
}
ptr = r_str_trim_head_ro (ptr + 1);
strncpy (w1, optr, WSZ - 1);
strncpy (w2, ptr, WSZ - 1);
optr=ptr;

View File

@ -94,21 +94,21 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ NULL }
};
for (i=0; ops[i].op; i++) {
for (i = 0; ops[i].op; i++) {
if (!strcmp (ops[i].op, argv[0])) {
if (newstr) {
for (j=k=0;ops[i].str[j]!='\0';j++,k++) {
for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) {
if (can_replace (ops[i].str, j, ops[i].max_operands)) {
const char *w = argv[ ops[i].str[j]-'0' ];
if (w) {
strcpy (newstr+k, w);
strcpy (newstr + k, w);
k += strlen (w) - 1;
}
} else {
newstr[k] = ops[i].str[j];
}
}
newstr[k]='\0';
newstr[k] = '\0';
}
return true;
}

View File

@ -37,10 +37,10 @@ static int replace(int argc, const char *argv[], char *newstr) {
{ NULL }
};
for (i=0; ops[i].op; i++) {
for (i = 0; ops[i].op; i++) {
if (!strcmp (ops[i].op, argv[0])) {
if (newstr) {
for (j=k=0;ops[i].str[j]!='\0';j++,k++) {
for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) {
if (ops[i].str[j]>='1' && ops[i].str[j]<='9') {
const char *w = argv[ ops[i].str[j]-'0' ];
if (w) {

View File

@ -59,7 +59,7 @@ static int is_fi_present(fnditem* n, unsigned char* blk , int patlen) {
R_IPI int search_pattern(RSearch *s, ut64 from, ut64 to) {
ut8 block[BSIZE+MAX_PATLEN], sblk[BSIZE+MAX_PATLEN+1];
ut64 addr, bact, bytes, intaddr, rb, bproc = 0;
int nr,i, moar=0, pcnt, cnt = 0, k = 0;
int nr,i, moar = 0, pcnt, cnt = 0, k = 0;
int patlen = s->pattern_size;
fnditem* root;

View File

@ -193,9 +193,9 @@ R_API RSearchKeyword* r_search_keyword_new_hexmask(const char *kwstr, const char
/* Validate a regexp in the canonical format /<regexp>/<options> */
R_API RSearchKeyword *r_search_keyword_new_regexp(const char *str, const char *data) {
RSearchKeyword *kw;
int i = 0, start, length;
// TODO: use r_str_trim_head_ro (str);
while (isspace ((const unsigned char)str[i])) {
i++;
}
@ -223,19 +223,17 @@ R_API RSearchKeyword *r_search_keyword_new_regexp(const char *str, const char *d
return NULL;
}
kw = R_NEW0(RSearchKeyword);
RSearchKeyword *kw = R_NEW0 (RSearchKeyword);
if (!kw) {
return NULL;
}
kw->bin_keyword = malloc (length+1);
if (!kw->bin_keyword) {
r_search_keyword_free (kw);
return NULL;
}
kw->bin_keyword[length]=0;
memcpy(kw->bin_keyword, str + start, length);
kw->bin_keyword[length] = 0;
memcpy (kw->bin_keyword, str + start, length);
kw->keyword_length = length - specials;
kw->type = R_SEARCH_KEYWORD_TYPE_STRING;
kw->data = (void *) data;

View File

@ -2,7 +2,7 @@
// XXX. this is dupped inside the r_flist.h for optimizations
int r_flist_iterator(void **x) {
return *x!=0;
return *x != 0;
}
void** r_flist_next(void **x) {
return x;
@ -17,7 +17,7 @@ void** r_flist_get(void **x) {
#define r_flist_t void**
#define RFList void**
#define r_flist_rewind(it) for (; (it)!=*(it); (it)--) {} (it)++
#define r_flist_next(it) *(it)!=0
#define r_flist_next(it) (*(it) != 0)
#define r_flist_get(it) *((it)++)
#define r_flist_iterator(x) x
#define r_flist_unref(x) x

View File

@ -2413,7 +2413,7 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,
p->cb_printf ("f %s.%s_", fmtname, fieldname);
} else if (tmp == 'E') {
p->cb_printf ("f %s=0x%08"PFMT64x"\n", fieldname, seeki);
} else if (slide/STRUCTFLAG>0 && idx==1) {
} else if (slide/STRUCTFLAG>0 && idx == 1) {
p->cb_printf ("%s=0x%08"PFMT64x"\n", fieldname, seeki);
} else {
p->cb_printf ("f %s=0x%08" PFMT64x "\n", fieldname, seeki);

View File

@ -1452,7 +1452,6 @@ static const char* getchardiff(RPrint *p, char *fmt, ut8 a, ut8 b) {
} else {
sprintf (fmt, "%c", ch);
}
//else { fmt[0] = ch; fmt[1]=0; }
return fmt;
}

View File

@ -88,7 +88,7 @@ static int qrcodegen_getSize(const uint8_t qrcode[]);
/*
* Returns the color of the module (pixel) at the given coordinates, which is either
* false for white or true for black. The top left corner has the coordinates (x=0, y=0).
* false for white or true for black. The top left corner has the coordinates (x,y)=(0,0)
* If the given coordinates are out of bounds, then false (white) is returned.
*/
static bool qrcodegen_getModule(const uint8_t qrcode[], int x, int y);

View File

@ -200,7 +200,7 @@ R_API int r_str_binstr2bin(const char *str, ut8 *out, int outlen) {
continue;
}
if (str[j] == '1') {
ret|=1 << k;
ret |= (1 << k);
} else if (str[j] != '0') {
return n;
}

View File

@ -1,11 +1,10 @@
/* radare - LGPL - Copyright 2009-2021 - pancake, nikolai */
/* radare - LGPL - Copyright 2009-2022 - pancake, nikolai */
#include <r_util/r_diff.h>
// the non-system-diff doesnt work well
#define USE_SYSTEM_DIFF 1
R_API RDiff *r_diff_new_from(ut64 off_a, ut64 off_b) {
RDiff *d = R_NEW0 (RDiff);
if (d) {
@ -842,7 +841,8 @@ R_API st32 r_diff_levenshtein_path(RLevBuf *bufa, RLevBuf *bufb, ut32 maxdst, RL
size_t skip;
ut32 alen = bufa->len;
ut32 blen = bufb->len;
for (skip=0; skip < alen && !levdiff (bufa, bufb, skip, skip); skip++) {}
for (skip = 0; skip < alen && !levdiff (bufa, bufb, skip, skip); skip++) {
}
// strip suffix as long as bytes don't diff
size_t i;
@ -951,11 +951,11 @@ R_API st32 r_diff_levenshtein_path(RLevBuf *bufa, RLevBuf *bufb, ut32 maxdst, RL
{
// for debugging matrix
size_t total = 0;
for (i=0; i <= alen; i++) {
for (i = 0; i <= alen; i++) {
Levrow *bow = matrix + i;
ut32 j;
printf (" ");
for (j=0; j <= blen; j++) {
for (j = 0; j <= blen; j++) {
ut32 val = lev_get_val (bow, j);
if (val >= UT32_MAX - 1) {
printf (" ..");

View File

@ -440,7 +440,7 @@ LZ4_memcpy_using_offset_base(BYTE* dstPtr, const BYTE* srcPtr, BYTE* dstEnd, con
{
assert(srcPtr + offset == dstPtr);
if (offset < 8) {
LZ4_write32(dstPtr, 0); /* silence an msan warning when offset==0 */
LZ4_write32(dstPtr, 0); /* silence an msan warning when offset == 0 */
dstPtr[0] = srcPtr[0];
dstPtr[1] = srcPtr[1];
dstPtr[2] = srcPtr[2];
@ -589,7 +589,7 @@ static unsigned LZ4_NbCommonBytes (reg_t val)
Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
Note that this code path is never triggered in 32-bits mode. */
unsigned r;
if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
if (!(val>>by32)) { r=4; } else { r = 0; val >>= by32; }
if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
r += (!val);
return r;
@ -1168,7 +1168,7 @@ _next_match:
LZ4_putPosition(ip, cctx->hashTable, tableType, base);
if ( (match+LZ4_DISTANCE_MAX >= ip)
&& (LZ4_read32(match) == LZ4_read32(ip)) )
{ token=op++; *token=0; goto _next_match; }
{ token=op++; *token = 0; goto _next_match; }
} else { /* byU32, byU16 */
@ -1204,8 +1204,8 @@ _next_match:
if ( ((dictIssue==dictSmall) ? (matchIndex >= prefixIdxLimit) : 1)
&& (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
&& (LZ4_read32(match) == LZ4_read32(ip)) ) {
token=op++;
*token=0;
token = op++;
*token = 0;
if (maybe_extMem) offset = current - matchIndex;
DEBUGLOG(6, "seq.start:%i, literals=%u, match.start:%i",
(int)(anchor-(const BYTE*)source), 0, (int)(ip-(const BYTE*)source));
@ -1569,8 +1569,8 @@ static void LZ4_renormDictT(LZ4_stream_t_internal* LZ4_dict, int nextSize)
const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize;
int i;
DEBUGLOG(4, "LZ4_renormDictT");
for (i=0; i<LZ4_HASH_SIZE_U32; i++) {
if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i]=0;
for (i = 0; i < LZ4_HASH_SIZE_U32; i++) {
if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i] = 0;
else LZ4_dict->hashTable[i] -= delta;
}
LZ4_dict->currentOffset = 64 KB;
@ -1804,7 +1804,7 @@ LZ4_decompress_generic(
/* Special cases */
assert(lowPrefix <= op);
if ((endOnInput) && (unlikely(outputSize==0))) {
if ((endOnInput) && (unlikely(outputSize == 0))) {
/* Empty output buffer */
if (partialDecoding) return 0;
return ((srcSize==1) && (*ip==0)) ? 0 : -1;

View File

@ -2779,7 +2779,7 @@ static void mpc_print_unretained(mpc_parser_t *p, int force) {
if (p->type == MPC_TYPE_OR) {
printf("(");
for(i = 0; i < p->data.or.n-1; i++) {
for (i = 0; i < p->data.or.n-1; i++) {
mpc_print_unretained(p->data.or.xs[i], 0);
printf(" | ");
}
@ -2789,7 +2789,7 @@ static void mpc_print_unretained(mpc_parser_t *p, int force) {
if (p->type == MPC_TYPE_AND) {
printf("(");
for(i = 0; i < p->data.and.n-1; i++) {
for (i = 0; i < p->data.and.n-1; i++) {
mpc_print_unretained(p->data.and.xs[i], 0);
printf(" ");
}
@ -3048,7 +3048,7 @@ int mpc_ast_get_index(mpc_ast_t *ast, const char *tag) {
int mpc_ast_get_index_lb(mpc_ast_t *ast, const char *tag, int lb) {
int i;
for(i=lb; i<ast->children_num; i++) {
for (i=lb; i<ast->children_num; i++) {
if(strcmp(ast->children[i]->tag, tag) == 0) {
return i;
}
@ -3064,7 +3064,7 @@ mpc_ast_t *mpc_ast_get_child(mpc_ast_t *ast, const char *tag) {
mpc_ast_t *mpc_ast_get_child_lb(mpc_ast_t *ast, const char *tag, int lb) {
int i;
for(i=lb; i<ast->children_num; i++) {
for (i=lb; i<ast->children_num; i++) {
if(strcmp(ast->children[i]->tag, tag) == 0) {
return ast->children[i];
}
@ -3868,7 +3868,7 @@ static int mpc_nodecount_unretained(mpc_parser_t* p, int force) {
if (p->type == MPC_TYPE_OR) {
total = 1;
for(i = 0; i < p->data.or.n; i++) {
for (i = 0; i < p->data.or.n; i++) {
total += mpc_nodecount_unretained(p->data.or.xs[i], 0);
}
return total;
@ -3876,7 +3876,7 @@ static int mpc_nodecount_unretained(mpc_parser_t* p, int force) {
if (p->type == MPC_TYPE_AND) {
total = 1;
for(i = 0; i < p->data.and.n; i++) {
for (i = 0; i < p->data.and.n; i++) {
total += mpc_nodecount_unretained(p->data.and.xs[i], 0);
}
return total;
@ -3914,13 +3914,13 @@ static void mpc_optimise_unretained(mpc_parser_t *p, int force) {
if (p->type == MPC_TYPE_COUNT) { mpc_optimise_unretained(p->data.repeat.x, 0); }
if (p->type == MPC_TYPE_OR) {
for(i = 0; i < p->data.or.n; i++) {
for (i = 0; i < p->data.or.n; i++) {
mpc_optimise_unretained(p->data.or.xs[i], 0);
}
}
if (p->type == MPC_TYPE_AND) {
for(i = 0; i < p->data.and.n; i++) {
for (i = 0; i < p->data.and.n; i++) {
mpc_optimise_unretained(p->data.and.xs[i], 0);
}
}

View File

@ -9,10 +9,13 @@
(git grep -n 'for (size_t' | grep -v sys/) && exit 1
(git grep -n 'R_LOG_' | grep '\\n' | grep -v sys/) && exit 1
(git grep "`printf '\tfree('`" libr | grep c: ) && exit 1
# (git grep '=0' libr| grep c:|grep -v '"' |grep -v '=0x' | less) && exit 1
(git grep '=0' libr| grep c:|grep -v '"' |grep -v '=0x') && exit 1
(git grep '=1' libr| grep c:|grep -v '"' |grep -v '//') && exit 1
(git grep -n 'eprintf' libr | grep 'Error:') && exit 1
(git grep -n 'x ""' libr) && exit 1
(git grep -n 'x""' libr) && exit 1
# (git grep -e 'sizeof(' -e 'for(' -e 'while(' -e 'if(' libr) && exit 1
# ( git grep strcmp | grep '== 0') && exit 1
(git grep -n ';;$' libr) && exit 1
(git grep -n '0 ;' libr) && exit 1
(git grep -n -e 'i<' -e 'j<' -e 'k<' libr | grep -v '"') && exit 1