mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
More linting rules
This commit is contained in:
parent
36d13a1165
commit
b757488cf8
@ -4420,7 +4420,7 @@ arc_opval_supported (const struct arc_operand_value *opval ATTRIBUTE_UNUSED)
|
||||
return 1;
|
||||
return 0;
|
||||
#endif
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "pyc_magic.h"
|
||||
|
||||
// avoiding using r2 internals asserts
|
||||
#define if_true_return(cond,ret) if (cond){return(ret);}
|
||||
#define if_true_return(cond,ret) if (cond) { return (ret); }
|
||||
|
||||
// TODO: kill globals
|
||||
static R_TH_LOCAL ut32 magic_int;
|
||||
|
@ -1781,7 +1781,7 @@ static void visual_textlogs(RCore *core) {
|
||||
index++;
|
||||
break;
|
||||
case 'J':
|
||||
index+=10;
|
||||
index += 10;
|
||||
break;
|
||||
case '+':
|
||||
if (log_level <= R_LOGLVL_LAST) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define AES256_KEY_LENGTH 32
|
||||
|
||||
static bool aes256_key_test(const unsigned char *buf) {
|
||||
return( buf[32] == (buf[0] ^ Sbox[buf[29]] ^ 1) \
|
||||
return (buf[32] == (buf[0] ^ Sbox[buf[29]] ^ 1) \
|
||||
&& buf[33] == (buf[1] ^ Sbox[buf[30]]) \
|
||||
&& buf[34] == (buf[2] ^ Sbox[buf[31]]) \
|
||||
&& buf[35] == (buf[3] ^ Sbox[buf[28]])
|
||||
@ -31,7 +31,7 @@ static bool aes256_key_test(const unsigned char *buf) {
|
||||
}
|
||||
|
||||
static bool aes192_key_test(const unsigned char *buf) {
|
||||
return( buf[24] == (buf[0] ^ Sbox[buf[21]] ^ 1) \
|
||||
return (buf[24] == (buf[0] ^ Sbox[buf[21]] ^ 1) \
|
||||
&& buf[25] == (buf[1] ^ Sbox[buf[22]]) \
|
||||
&& buf[26] == (buf[2] ^ Sbox[buf[23]]) \
|
||||
&& buf[27] == (buf[3] ^ Sbox[buf[20]]) \
|
||||
@ -42,7 +42,7 @@ static bool aes192_key_test(const unsigned char *buf) {
|
||||
}
|
||||
|
||||
static bool aes128_key_test(const unsigned char *buf) {
|
||||
return( buf[16] == (buf[0] ^ Sbox[buf[13]] ^ 1) \
|
||||
return (buf[16] == (buf[0] ^ Sbox[buf[13]] ^ 1) \
|
||||
&& buf[17] == (buf[1] ^ Sbox[buf[14]]) \
|
||||
&& buf[18] == (buf[2] ^ Sbox[buf[15]]) \
|
||||
&& buf[19] == (buf[3] ^ Sbox[buf[12]]) \
|
||||
|
@ -633,8 +633,9 @@ static char *backref(struct match *m, char *start, char *stop, sopno startst, so
|
||||
}
|
||||
for (;;) { /* find first matching branch */
|
||||
dp = backref(m, sp, stop, ssub, esub, lev, rec);
|
||||
if (dp)
|
||||
if (dp) {
|
||||
return dp;
|
||||
}
|
||||
/* that one missed, try next one */
|
||||
if (OP (m->g->strip[esub]) == O_CH)
|
||||
return NULL; /* there is none */
|
||||
@ -658,10 +659,11 @@ static char *backref(struct match *m, char *start, char *stop, sopno startst, so
|
||||
offsave = m->pmatch[i].rm_so;
|
||||
m->pmatch[i].rm_so = sp - m->offp;
|
||||
dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
|
||||
if (dp)
|
||||
return(dp);
|
||||
if (dp) {
|
||||
return dp;
|
||||
}
|
||||
m->pmatch[i].rm_so = offsave;
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case ORPAREN: /* must undo assignment if rest fails */
|
||||
|
@ -719,7 +719,7 @@ static int p_simp_re(struct parse *p, int starordinary) { /* is a leading * an o
|
||||
return (1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -735,7 +735,7 @@ static int p_count(struct parse *p) {
|
||||
}
|
||||
|
||||
REQUIRE(ndigits > 0 && count <= DUPMAX, R_REGEX_BADBR);
|
||||
return(count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -956,7 +956,7 @@ static char p_b_symbol(struct parse *p) {
|
||||
/* collating symbol */
|
||||
value = p_b_coll_elem(p, '.');
|
||||
REQUIRE(EATTWO('.', ']'), R_REGEX_ECOLLATE);
|
||||
return(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -973,7 +973,7 @@ p_b_coll_elem(struct parse *p, int endc) { /* name ended by endc,']' */
|
||||
}
|
||||
if (!MORE()) {
|
||||
SETERROR(R_REGEX_EBRACK);
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
len = p->next - sp;
|
||||
for (cp = cnames; cp->name; cp++) {
|
||||
@ -985,7 +985,7 @@ p_b_coll_elem(struct parse *p, int endc) { /* name ended by endc,']' */
|
||||
return (*sp); /* single character */
|
||||
}
|
||||
SETERROR(R_REGEX_ECOLLATE); /* neither */
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1210,7 +1210,7 @@ seterr(struct parse *p, int e)
|
||||
}
|
||||
p->next = nuls; /* try to bring things to a halt */
|
||||
p->end = nuls;
|
||||
return(0); /* make the return value well-defined */
|
||||
return 0; /* make the return value well-defined */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1264,14 +1264,14 @@ static cset *allocset(struct parse *p) {
|
||||
cs->smultis = 0;
|
||||
cs->multis = NULL;
|
||||
|
||||
return(cs);
|
||||
return cs;
|
||||
nomem:
|
||||
R_FREE(p->g->sets);
|
||||
R_FREE(p->g->setbits);
|
||||
|
||||
SETERROR(R_REGEX_ESPACE);
|
||||
/* caller's responsibility not to do set ops */
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1328,7 +1328,7 @@ freezeset(struct parse *p, cset *cs)
|
||||
cs = cs2;
|
||||
}
|
||||
|
||||
return((int)(cs - p->g->sets));
|
||||
return (int)(cs - p->g->sets);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1345,7 +1345,7 @@ firstch(struct parse *p, cset *cs)
|
||||
return ((char)i);
|
||||
}
|
||||
}
|
||||
return(0); /* arbitrary */
|
||||
return 0; /* arbitrary */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1361,7 +1361,7 @@ static int nch(struct parse *p, cset *cs) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1413,9 +1413,7 @@ static void mccase(struct parse *p, cset *cs) {
|
||||
/*
|
||||
- isinsets - is this character in any sets?
|
||||
*/
|
||||
static int /* predicate */
|
||||
isinsets(struct re_guts *g, int c)
|
||||
{
|
||||
static int isinsets(struct re_guts *g, int c) {
|
||||
ut8 *col;
|
||||
int i;
|
||||
int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
|
||||
@ -1426,15 +1424,13 @@ isinsets(struct re_guts *g, int c)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
- samesets - are these two characters in exactly the same sets?
|
||||
*/
|
||||
static int /* predicate */
|
||||
samesets(struct re_guts *g, int c1, int c2)
|
||||
{
|
||||
static int samesets(struct re_guts *g, int c1, int c2) {
|
||||
ut8 *col;
|
||||
int i;
|
||||
int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
|
||||
@ -1446,15 +1442,13 @@ samesets(struct re_guts *g, int c1, int c2)
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
- categorize - sort out character categories
|
||||
*/
|
||||
static void
|
||||
categorize(struct parse *p, struct re_guts *g)
|
||||
{
|
||||
static void categorize(struct parse *p, struct re_guts *g) {
|
||||
cat_t *cats = g? g->categories : NULL;
|
||||
unsigned int c;
|
||||
unsigned int c2;
|
||||
@ -1498,7 +1492,7 @@ dupl(struct parse *p,
|
||||
(void) memcpy((char *)(p->strip + p->slen),
|
||||
(char *)(p->strip + start), (size_t)len*sizeof (sop));
|
||||
p->slen += len;
|
||||
return(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -1703,9 +1697,7 @@ static void findmust(struct parse *p, struct re_guts *g) {
|
||||
/*
|
||||
- pluscount - count + nesting
|
||||
*/
|
||||
static sopno /* nesting depth */
|
||||
pluscount(struct parse *p, struct re_guts *g)
|
||||
{
|
||||
static sopno pluscount(struct parse *p, struct re_guts *g) {
|
||||
sop *scan;
|
||||
sop s;
|
||||
sopno plusnest = 0;
|
||||
@ -1733,5 +1725,5 @@ pluscount(struct parse *p, struct re_guts *g)
|
||||
if (plusnest != 0) {
|
||||
g->iflags |= BAD;
|
||||
}
|
||||
return(maxnest);
|
||||
return maxnest;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ static char *regatoi(const RRegex *preg, char *localbuf, size_t localbufsize) {
|
||||
}
|
||||
|
||||
(void)snprintf (localbuf, localbufsize, "%d", r->code);
|
||||
return(localbuf);
|
||||
return localbuf;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4,7 +4,6 @@ cd "$(dirname $0)"/..
|
||||
|
||||
# (git grep -e '_[a-z][a-z](' libr | grep -v '{'| grep c:) && exit 1
|
||||
(git grep '^\ \ \ ' libr | grep -v '/arch/' | grep -v dotnet | grep -v mangl | grep c:) && exit 1
|
||||
# (git grep '^\ \ \ ' libr | grep -v '/arch/' | grep -v dotnet | grep -v mangl | grep h:) && exit 1
|
||||
(git grep 'TODO' libr | grep R_LOG_INFO) && exit 1
|
||||
( git grep r_config_set libr binr | grep -e '"fal' -e '"tru') && exit 1
|
||||
# find calls without (
|
||||
@ -44,6 +43,7 @@ cd "$(dirname $0)"/..
|
||||
( git grep '){$' libr| grep if) && exit 1
|
||||
(git grep -e 'sizeof(' -e 'for(' -e 'while(' -e 'if(' libr | grep -v :static | grep -v :R_API | grep c:) && exit 1
|
||||
( git grep 'else$' libr | grep -v '#' | grep '}' | grep 'c:') && exit 1
|
||||
( git grep 'return(' libr | grep c:) && exit 1
|
||||
# ( git grep if' (' libr| grep ')$'| grep -v '//'|grep -v '#' | grep c:) && exit 1
|
||||
# ( git grep strcmp | grep '== 0') && exit 1
|
||||
# ( git grep strncmp | grep '== 0') && exit 1 ## must use r_str_startswith
|
||||
|
Loading…
Reference in New Issue
Block a user