From a538b2b7009fe77a6fb406ba0d2cbd42b561ba96 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 18 Aug 2022 13:58:40 +0200 Subject: [PATCH] Add =0 and =1 lintings --- libr/anal/arch/arc/gnu/arc-dis.c | 22 +++++++------- libr/anal/arch/arc/gnu/arc-opc.c | 6 ++-- libr/anal/arch/arc/gnu/arcompact-dis.c | 37 +++++++++++------------ libr/anal/cond.c | 17 +++++------ libr/anal/diff.c | 8 ++--- libr/anal/p/anal_6502.c | 9 +++--- libr/anal/p/anal_arm_cs.c | 34 ++++++++++----------- libr/anal/p/anal_arm_v35.c | 16 +++++----- libr/anal/p/anal_java.c | 2 +- libr/anal/p/anal_mips_cs.c | 6 ++-- libr/anal/p/anal_mips_gnu.c | 6 ++-- libr/anal/p/anal_riscv_cs.c | 2 +- libr/anal/p/anal_sh.c | 8 ++--- libr/anal/p/anal_x86_cs.c | 40 ++++++++++++------------- libr/asm/arch/amd29k/amd29k.c | 6 ++-- libr/asm/arch/arm/aarch64/aarch64-opc.c | 4 +-- libr/asm/arch/arm/armass.c | 10 +++---- libr/asm/arch/ppc/gnu/ppc-opc.c | 2 +- libr/asm/arch/sh/gnu/sh-dis.c | 4 +-- libr/asm/arch/xap/dis.c | 18 +++++------ libr/bin/format/bflt/bflt.c | 23 +++++++------- libr/bin/format/bflt/bflt.h | 26 ++++++++-------- libr/bin/format/elf/elf.c | 2 +- libr/bin/mangling/cxx/cp-demangle.c | 4 +-- libr/bin/p/bin_mach064.c | 6 ++-- libr/bin/p/bin_sfc.c | 3 +- libr/bin/pdb/stream_pe.c | 5 ++-- libr/cons/cons.c | 8 ++--- libr/cons/stiv.c | 2 +- libr/core/blaze.c | 2 +- libr/core/cmd.c | 2 +- libr/core/cmd_anal.c | 14 ++++----- libr/core/cmd_api.c | 4 +-- libr/core/cmd_write.c | 2 +- libr/core/hack.c | 6 ++-- libr/core/vmenus.c | 18 +++++------ libr/debug/dsignal.c | 2 +- libr/debug/p/bfvm.c | 4 +-- libr/debug/p/debug_bochs.c | 6 ++-- libr/debug/p/native/linux/linux_debug.c | 2 +- libr/debug/p/native/maps/darwin.c | 15 +++++----- libr/egg/egg.c | 2 +- libr/egg/p/egg_xor.c | 2 +- libr/egg/rlcc/rlcc.c | 26 ++++++++-------- libr/io/p/io_ihex.c | 15 +++++----- libr/io/p/io_ptrace.c | 2 +- libr/io/p/io_w32.c | 11 ++++--- libr/main/r2pm.c | 2 +- libr/main/radare2.c | 2 +- libr/parse/p/parse_dalvik_pseudo.c | 19 ++++++------ libr/parse/p/parse_m68k_pseudo.c | 16 ++++------ libr/parse/p/parse_mips_pseudo.c | 8 ++--- libr/parse/p/parse_z80_pseudo.c | 4 +-- libr/search/bytepat.c | 2 +- libr/search/keyword.c | 10 +++---- libr/util/flist.c | 4 +-- libr/util/format.c | 2 +- libr/util/print.c | 1 - libr/util/qrcode.c | 2 +- libr/util/str.c | 2 +- libr/util/udiff.c | 10 +++---- shlr/lz4/lz4.c | 16 +++++----- shlr/mpc/mpc.c | 16 +++++----- sys/lint.sh | 5 +++- 64 files changed, 293 insertions(+), 299 deletions(-) diff --git a/libr/anal/arch/arc/gnu/arc-dis.c b/libr/anal/arch/arc/gnu/arc-dis.c index 594902e315..82641c7ec1 100644 --- a/libr/anal/arch/arc/gnu/arc-dis.c +++ b/libr/anal/arch/arc/gnu/arc-dis.c @@ -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. */ diff --git a/libr/anal/arch/arc/gnu/arc-opc.c b/libr/anal/arch/arc/gnu/arc-opc.c index c65140779c..43b8f905cb 100644 --- a/libr/anal/arch/arc/gnu/arc-opc.c +++ b/libr/anal/arch/arc/gnu/arc-opc.c @@ -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}, diff --git a/libr/anal/arch/arc/gnu/arcompact-dis.c b/libr/anal/arch/arc/gnu/arcompact-dis.c index d4dd7a7550..59d16a64d8 100644 --- a/libr/anal/arch/arc/gnu/arcompact-dis.c +++ b/libr/anal/arch/arc/gnu/arcompact-dis.c @@ -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 diff --git a/libr/anal/cond.c b/libr/anal/cond.c index 457954ae2d..8db7e2d9e4 100644 --- a/libr/anal/cond.c +++ b/libr/anal/cond.c @@ -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; diff --git a/libr/anal/diff.c b/libr/anal/diff.c index c166569468..f396e02725 100644 --- a/libr/anal/diff.c +++ b/libr/anal/diff.c @@ -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 diff --git a/libr/anal/p/anal_6502.c b/libr/anal/p/anal_6502.c index 1527868745..a389a531a2 100644 --- a/libr/anal/p/anal_6502.c +++ b/libr/anal/p/anal_6502.c @@ -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,="); diff --git a/libr/anal/p/anal_arm_cs.c b/libr/anal/p/anal_arm_cs.c index fc81083e45..96f2dbd3dd 100644 --- a/libr/anal/p/anal_arm_cs.c +++ b/libr/anal/p/anal_arm_cs.c @@ -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")) { diff --git a/libr/anal/p/anal_arm_v35.c b/libr/anal/p/anal_arm_v35.c index 9e7b48f5f4..60ccfcd135 100644 --- a/libr/anal/p/anal_arm_v35.c +++ b/libr/anal/p/anal_arm_v35.c @@ -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, diff --git a/libr/anal/p/anal_java.c b/libr/anal/p/anal_java.c index d24090972b..f662252f37 100644 --- a/libr/anal/p/anal_java.c +++ b/libr/anal/p/anal_java.c @@ -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; diff --git a/libr/anal/p/anal_mips_cs.c b/libr/anal/p/anal_mips_cs.c index 13dabcbffc..c3467c5221 100644 --- a/libr/anal/p/anal_mips_cs.c +++ b/libr/anal/p/anal_mips_cs.c @@ -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 diff --git a/libr/anal/p/anal_mips_gnu.c b/libr/anal/p/anal_mips_gnu.c index 17effd167c..ac3056917c 100644 --- a/libr/anal/p/anal_mips_gnu.c +++ b/libr/anal/p/anal_mips_gnu.c @@ -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 { diff --git a/libr/anal/p/anal_riscv_cs.c b/libr/anal/p/anal_riscv_cs.c index 8a0513508c..bdd9ed916f 100644 --- a/libr/anal/p/anal_riscv_cs.c +++ b/libr/anal/p/anal_riscv_cs.c @@ -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}}; diff --git a/libr/anal/p/anal_sh.c b/libr/anal/p/anal_sh.c index 6004d4d2d0..8f5266a50e 100644 --- a/libr/anal/p/anal_sh.c +++ b/libr/anal/p/anal_sh.c @@ -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 ,@(,) +//nibble = 1; 0001nnnnmmmmi4*4 mov.l ,@(,) 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; } diff --git a/libr/anal/p/anal_x86_cs.c b/libr/anal/p/anal_x86_cs.c index d2de0a0a0f..3e32072c39 100644 --- a/libr/anal/p/anal_x86_cs.c +++ b/libr/anal/p/anal_x86_cs.c @@ -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,:=", diff --git a/libr/asm/arch/amd29k/amd29k.c b/libr/asm/arch/amd29k/amd29k.c index faa82ca50f..b3e38fe5d8 100644 --- a/libr/asm/arch/amd29k/amd29k.c +++ b/libr/asm/arch/amd29k/amd29k.c @@ -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); diff --git a/libr/asm/arch/arm/aarch64/aarch64-opc.c b/libr/asm/arch/arm/aarch64/aarch64-opc.c index 44917d526a..07daf32e6a 100644 --- a/libr/asm/arch/arm/aarch64/aarch64-opc.c +++ b/libr/asm/arch/arm/aarch64/aarch64-opc.c @@ -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 diff --git a/libr/asm/arch/arm/armass.c b/libr/asm/arch/arm/armass.c index 1e37e2db62..86d35a5a3b 100644 --- a/libr/asm/arch/arm/armass.c +++ b/libr/asm/arch/arm/armass.c @@ -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; } diff --git a/libr/asm/arch/ppc/gnu/ppc-opc.c b/libr/asm/arch/ppc/gnu/ppc-opc.c index 51b89a4c80..5d385d038c 100644 --- a/libr/asm/arch/ppc/gnu/ppc-opc.c +++ b/libr/asm/arch/ppc/gnu/ppc-opc.c @@ -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 diff --git a/libr/asm/arch/sh/gnu/sh-dis.c b/libr/asm/arch/sh/gnu/sh-dis.c index 199cf3d003..76f9b451a8 100644 --- a/libr/asm/arch/sh/gnu/sh-dis.c +++ b/libr/asm/arch/sh/gnu/sh-dis.c @@ -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; diff --git a/libr/asm/arch/xap/dis.c b/libr/asm/arch/xap/dis.c index 9bb1f95198..9b872f93e1 100644 --- a/libr/asm/arch/xap/dis.c +++ b/libr/asm/arch/xap/dis.c @@ -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) { diff --git a/libr/bin/format/bflt/bflt.c b/libr/bin/format/bflt/bflt.c index 0b0e07c612..4351c765fd 100644 --- a/libr/bin/format/bflt/bflt.c +++ b/libr/bin/format/bflt/bflt.c @@ -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; } diff --git a/libr/bin/format/bflt/bflt.h b/libr/bin/format/bflt/bflt.h index 9fbf602010..e375a92448 100644 --- a/libr/bin/format/bflt/bflt.h +++ b/libr/bin/format/bflt/bflt.h @@ -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 diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index a7f653923c..f9fe9e3eed 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -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) { diff --git a/libr/bin/mangling/cxx/cp-demangle.c b/libr/bin/mangling/cxx/cp-demangle.c index db30b97bb4..1265d274ad 100644 --- a/libr/bin/mangling/cxx/cp-demangle.c +++ b/libr/bin/mangling/cxx/cp-demangle.c @@ -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) /* ::= _ # when number < 10 ::= __ _ # when number >= 10 - ::= _ # when number >=10 + ::= _ # 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: diff --git a/libr/bin/p/bin_mach064.c b/libr/bin/p/bin_mach064.c index 63c003d532..4c04f1eb50 100644 --- a/libr/bin/p/bin_mach064.c +++ b/libr/bin/p/bin_mach064.c @@ -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 (); diff --git a/libr/bin/p/bin_sfc.c b/libr/bin/p/bin_sfc.c index acb4d1eb77..cf7b7a3fb3 100644 --- a/libr/bin/p/bin_sfc.c +++ b/libr/bin/p/bin_sfc.c @@ -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); } } diff --git a/libr/bin/pdb/stream_pe.c b/libr/bin/pdb/stream_pe.c index aa058994b3..fb7b663786 100644 --- a/libr/bin/pdb/stream_pe.c +++ b/libr/bin/pdb/stream_pe.c @@ -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); diff --git a/libr/cons/cons.c b/libr/cons/cons.c index 206b281b2d..9a57bdbe8c 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -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; diff --git a/libr/cons/stiv.c b/libr/cons/stiv.c index 99a0b53e8c..5534fa8a16 100644 --- a/libr/cons/stiv.c +++ b/libr/cons/stiv.c @@ -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)) { diff --git a/libr/core/blaze.c b/libr/core/blaze.c index 57f989a5ea..ae9c6c5345 100644 --- a/libr/core/blaze.c +++ b/libr/core/blaze.c @@ -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) { diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 8c0db7d4d5..b93f86c512 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -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 { diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index c9a125e930..56cde14d73 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -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) { diff --git a/libr/core/cmd_api.c b/libr/core/cmd_api.c index 62c7bd589c..272754e67f 100644 --- a/libr/core/cmd_api.c +++ b/libr/core/cmd_api.c @@ -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 { diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 6a7e81b118..a131fc3802 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -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) diff --git a/libr/core/hack.c b/libr/core/hack.c index cd47aef348..46256c4c97 100644 --- a/libr/core/hack.c +++ b/libr/core/hack.c @@ -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")) { diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 383791e077..f1fdc05b8c 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -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; } } diff --git a/libr/debug/dsignal.c b/libr/debug/dsignal.c index f81c1b281d..94f65dccd1 100644 --- a/libr/debug/dsignal.c +++ b/libr/debug/dsignal.c @@ -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); } diff --git a/libr/debug/p/bfvm.c b/libr/debug/p/bfvm.c index f49b640975..cbeb9ee21a 100644 --- a/libr/debug/p/bfvm.c +++ b/libr/debug/p/bfvm.c @@ -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; } diff --git a/libr/debug/p/debug_bochs.c b/libr/debug/p/debug_bochs.c index da56a516ed..45d3ed4f79 100644 --- a/libr/debug/p/debug_bochs.c +++ b/libr/debug/p/debug_bochs.c @@ -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" //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 */ diff --git a/libr/debug/p/native/linux/linux_debug.c b/libr/debug/p/native/linux/linux_debug.c index 06d820f958..d02c637017 100644 --- a/libr/debug/p/native/linux/linux_debug.c +++ b/libr/debug/p/native/linux/linux_debug.c @@ -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 diff --git a/libr/debug/p/native/maps/darwin.c b/libr/debug/p/native/maps/darwin.c index d7a1aa3d45..23019d1af4 100644 --- a/libr/debug/p/native/maps/darwin.c +++ b/libr/debug/p/native/maps/darwin.c @@ -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) diff --git a/libr/egg/egg.c b/libr/egg/egg.c index 70eaf2ae69..91f86731f8 100644 --- a/libr/egg/egg.c +++ b/libr/egg/egg.c @@ -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; diff --git a/libr/egg/p/egg_xor.c b/libr/egg/p/egg_xor.c index b9f8556eeb..4679fc83be 100644 --- a/libr/egg/p/egg_xor.c +++ b/libr/egg/p/egg_xor.c @@ -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; diff --git a/libr/egg/rlcc/rlcc.c b/libr/egg/rlcc/rlcc.c index 8f1226be42..46881302f4 100644 --- a/libr/egg/rlcc/rlcc.c +++ b/libr/egg/rlcc/rlcc.c @@ -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, Smallc, &r)) { - mpc_ast_print(r.output); - mpc_ast_delete(r.output); + if (mpc_parse_pipe ("", 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); diff --git a/libr/io/p/io_ihex.c b/libr/io/p/io_ihex.c index a6efa4f635..edd9f19601 100644 --- a/libr/io/p/io_ihex.c +++ b/libr/io/p/io_ihex.c @@ -4,12 +4,12 @@ *** .hex format description : every line follows this pattern :SSAAAARRKK 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 => bits 4..19 of following addresses - 04 extended linear addr reg: (always SS=02, AAAA=0); data = 0x => 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 => bits 4..19 of following addresses + 04 extended linear addr reg: (always SS = 02, AAAA = 0); data = 0x => 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; } diff --git a/libr/io/p/io_ptrace.c b/libr/io/p/io_ptrace.c index c3b35593d6..cbae664ac2 100644 --- a/libr/io/p/io_ptrace.c +++ b/libr/io/p/io_ptrace.c @@ -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; diff --git a/libr/io/p/io_w32.c b/libr/io/p/io_w32.c index 0f53c843c1..4bbd7eb23e 100644 --- a/libr/io/p/io_w32.c +++ b/libr/io/p/io_w32.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2008-2011 pancake */ +/* 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, diff --git a/libr/main/r2pm.c b/libr/main/r2pm.c index 5c439f340d..48ce84da17 100644 --- a/libr/main/r2pm.c +++ b/libr/main/r2pm.c @@ -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"); diff --git a/libr/main/radare2.c b/libr/main/radare2.c index b66110ea40..800e13ffbb 100644 --- a/libr/main/radare2.c +++ b/libr/main/radare2.c @@ -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)); } diff --git a/libr/parse/p/parse_dalvik_pseudo.c b/libr/parse/p/parse_dalvik_pseudo.c index b8eb2e9e95..fd30999f99 100644 --- a/libr/parse/p/parse_dalvik_pseudo.c +++ b/libr/parse/p/parse_dalvik_pseudo.c @@ -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, '}'); diff --git a/libr/parse/p/parse_m68k_pseudo.c b/libr/parse/p/parse_m68k_pseudo.c index 8dc1dbc8a4..ce67b5244e 100644 --- a/libr/parse/p/parse_m68k_pseudo.c +++ b/libr/parse/p/parse_m68k_pseudo.c @@ -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; diff --git a/libr/parse/p/parse_mips_pseudo.c b/libr/parse/p/parse_mips_pseudo.c index 639c95b0d2..54e71dbe39 100644 --- a/libr/parse/p/parse_mips_pseudo.c +++ b/libr/parse/p/parse_mips_pseudo.c @@ -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; } diff --git a/libr/parse/p/parse_z80_pseudo.c b/libr/parse/p/parse_z80_pseudo.c index 421d5a5ade..ca7d424cbb 100644 --- a/libr/parse/p/parse_z80_pseudo.c +++ b/libr/parse/p/parse_z80_pseudo.c @@ -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) { diff --git a/libr/search/bytepat.c b/libr/search/bytepat.c index 6c9373eb14..9f43ab2cbd 100644 --- a/libr/search/bytepat.c +++ b/libr/search/bytepat.c @@ -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; diff --git a/libr/search/keyword.c b/libr/search/keyword.c index d63030e1fc..a029573d22 100644 --- a/libr/search/keyword.c +++ b/libr/search/keyword.c @@ -193,9 +193,9 @@ R_API RSearchKeyword* r_search_keyword_new_hexmask(const char *kwstr, const char /* Validate a regexp in the canonical format // */ 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; diff --git a/libr/util/flist.c b/libr/util/flist.c index dc0369b1a4..9518609073 100644 --- a/libr/util/flist.c +++ b/libr/util/flist.c @@ -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 diff --git a/libr/util/format.c b/libr/util/format.c index 777121d59a..f749919d5d 100644 --- a/libr/util/format.c +++ b/libr/util/format.c @@ -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); diff --git a/libr/util/print.c b/libr/util/print.c index 4d99ae101b..f5286c06f6 100644 --- a/libr/util/print.c +++ b/libr/util/print.c @@ -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; } diff --git a/libr/util/qrcode.c b/libr/util/qrcode.c index 05c447b4ef..aa924a61d0 100644 --- a/libr/util/qrcode.c +++ b/libr/util/qrcode.c @@ -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); diff --git a/libr/util/str.c b/libr/util/str.c index a379b5a80d..d015653edb 100644 --- a/libr/util/str.c +++ b/libr/util/str.c @@ -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; } diff --git a/libr/util/udiff.c b/libr/util/udiff.c index fb3db6e3f7..2bd8e03458 100644 --- a/libr/util/udiff.c +++ b/libr/util/udiff.c @@ -1,11 +1,10 @@ -/* radare - LGPL - Copyright 2009-2021 - pancake, nikolai */ +/* radare - LGPL - Copyright 2009-2022 - pancake, nikolai */ #include // 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 (" .."); diff --git a/shlr/lz4/lz4.c b/shlr/lz4/lz4.c index 8de5ce290e..e25718d272 100644 --- a/shlr/lz4/lz4.c +++ b/shlr/lz4/lz4.c @@ -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; ihashTable[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; diff --git a/shlr/mpc/mpc.c b/shlr/mpc/mpc.c index d75d603dd2..1a34abba48 100644 --- a/shlr/mpc/mpc.c +++ b/shlr/mpc/mpc.c @@ -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; ichildren_num; i++) { + for (i=lb; ichildren_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; ichildren_num; i++) { + for (i=lb; ichildren_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); } } diff --git a/sys/lint.sh b/sys/lint.sh index 42ef379b1b..aa97a4903d 100755 --- a/sys/lint.sh +++ b/sys/lint.sh @@ -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