Skip to content

Commit

Permalink
Fix clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Jul 31, 2023
1 parent 747e006 commit f02765d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
8 changes: 4 additions & 4 deletions librz/analysis/arch/arm/arm_il32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ static RzILOpEffect *qadd16(cs_insn *insn, bool is_thumb) {
}
bool is_signed = insn->id == ARM_INS_QADD16 || insn->id == ARM_INS_QSUB16 || insn->id == ARM_INS_QASX ||
insn->id == ARM_INS_QSAX;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector * val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector *val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
RzILOpBitVector *al = cast(17, UNSIGNED(16, a));
RzILOpBitVector *ah = cast(17, UNSIGNED(16, SHIFTR0(DUP(a), UN(5, 16))));
RzILOpBitVector *bl = cast(17, UNSIGNED(16, b));
Expand Down Expand Up @@ -1769,7 +1769,7 @@ static RzILOpEffect *qadd8(cs_insn *insn, bool is_thumb) {
}
bool is_signed = insn->id == ARM_INS_QADD8 || insn->id == ARM_INS_QSUB8;
bool is_sub = insn->id == ARM_INS_QSUB8 || insn->id == ARM_INS_UQSUB8;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector * val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector *val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
return SEQ5(
saturate(is_signed, is_sub, "rb0", 8,
is_sub
Expand Down Expand Up @@ -1925,7 +1925,7 @@ static RzILOpEffect *sadd16(cs_insn *insn, bool is_thumb) {
bool is_signed = insn->id == ARM_INS_SADD16 || insn->id == ARM_INS_SHADD16 || insn->id == ARM_INS_SASX ||
insn->id == ARM_INS_SSAX || insn->id == ARM_INS_SHASX || insn->id == ARM_INS_SHSAX ||
insn->id == ARM_INS_SSUB16 || insn->id == ARM_INS_SHSUB16;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector * val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector *val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
al = cast(17, al);
ah = cast(17, ah);
bl = cast(17, bl);
Expand Down Expand Up @@ -2052,7 +2052,7 @@ static RzILOpEffect *sadd8(cs_insn *insn, bool is_thumb) {
if (set_ge) {
// Retroactively patch the ops to extend to 8 before the calculation because this is needed for ge
// Note: add/sub members here use the same structure, so using just `.add` is fine.
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector * val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
RzILOpBitVector *(*cast)(ut32 length, RzILOpBitVector *val) = is_signed ? rz_il_op_new_signed : rz_il_op_new_unsigned;
r0->op.add.x = cast(9, r0->op.add.x);
r0->op.add.y = cast(9, r0->op.add.y);
r1->op.add.x = cast(9, r1->op.add.x);
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/arch/avr/avr_esil.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static OPCODE_DESC *avr_op_analyze(RzAnalysis *analysis, RzAnalysisOp *op, ut64
#define INST_HANDLER(OPCODE_NAME) static void _inst__##OPCODE_NAME(RzAnalysis *analysis, RzAnalysisOp *op, const ut8 *buf, int len, int *fail, CPU_MODEL *cpu)
#define INST_DECL(OP, M, SL, C, SZ, T) \
{ \
#OP, (M), (SL), _inst__##OP, (C), (SZ), RZ_ANALYSIS_OP_TYPE_##T \
#OP, (M), (SL), _inst__##OP, (C), (SZ), RZ_ANALYSIS_OP_TYPE_##T \
}
#define INST_LAST \
{ "unknown", 0, 0, (void *)0, 2, 1, RZ_ANALYSIS_OP_TYPE_UNK }
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/p/analysis_mips_gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ static char *mips_get_reg_profile(RzAnalysis *analysis) {
/* extra */
"gpr pc .64 272 0\n";
#endif
return strdup(p);
return strdup(p);
}

static int archinfo(RzAnalysis *a, RzAnalysisInfoType query) {
Expand Down
13 changes: 6 additions & 7 deletions librz/analysis/xrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
#include <rz_analysis.h>
#include <rz_cons.h>

#if 0
/*
DICT
====
refs 10->20 C 16->10 J 20->10 C
xrefs 20->[10 C] 10 -> [16 J, 20 C]
xrefs 20->[10 C] 10 -> [16 J, 20 C]
10 : call 20 16 : jmp 10 20 : call 10
#endif

// XXX: is it possible to have multiple type for the same (from, to) pair?
// if it is, things need to be adjusted
10 : call 20 16 : jmp 10 20 : call 10
*/
// TODO: is it possible to have multiple type for the same (from, to) pair?
// if it is, things need to be adjusted

static RzAnalysisXRef *rz_analysis_xref_new(ut64 from, ut64 to, ut64 type) {
RzAnalysisXRef *xref = RZ_NEW(RzAnalysisXRef);
Expand Down
2 changes: 1 addition & 1 deletion librz/core/hack.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ RZ_API bool rz_core_hack_x86(RzCore *core, const char *op, const RzAnalysisOp *a
RZ_API bool rz_core_hack(RzCore *core, const char *op) {
// TODO: op should not be an unstructered string
// TODO: asm/analysis plugins should provide the operations, instead of doing this here
bool (*hack)(RzCore * core, const char *op, const RzAnalysisOp *aop) = NULL;
bool (*hack)(RzCore *core, const char *op, const RzAnalysisOp *aop) = NULL;
const char *asmarch = rz_config_get(core->config, "asm.arch");
const int asmbits = core->rasm->bits;

Expand Down
2 changes: 1 addition & 1 deletion librz/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ RZ_API int rz_debug_continue_kill(RzDebug *dbg, int sig) {
#if DEBUGGER
/// if the plugin is not compiled link fails, so better do runtime linking
/// until this code gets fixed
static bool (*linux_attach_new_process)(RzDebug * dbg, int pid) = NULL;
static bool (*linux_attach_new_process)(RzDebug *dbg, int pid) = NULL;
if (!linux_attach_new_process) {
linux_attach_new_process = rz_sys_dlsym(NULL, "linux_attach_new_process");
}
Expand Down
10 changes: 7 additions & 3 deletions sys/clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def get_edited_files(args):
yield filename


def build_command(check, filenames, verbose):
cmd = ["clang-format", "--style=file"]
def build_command(clangformat, check, filenames, verbose):
cmd = [clangformat, "--style=file"]
if verbose:
cmd += ["--verbose"]
if check:
Expand All @@ -85,7 +85,7 @@ def format_files(args, files):
if len(files) == 0:
print("No C files to format.")
sys.exit(0)
cmd = build_command(args.check, files, args.verbose)
cmd = build_command(args.clang_format, args.check, files, args.verbose)
r = subprocess.run(cmd, check=False)
sys.exit(r.returncode)

Expand Down Expand Up @@ -115,6 +115,10 @@ def process(args):

def parse():
parser = argparse.ArgumentParser(description="Clang format the rizin project")

parser.add_argument(
"-C", "--clang-format", default="clang-format", help="path of clang-format"
)
parser.add_argument(
"-c", "--check", action="store_true", help="enable the check mode"
)
Expand Down

0 comments on commit f02765d

Please sign in to comment.