Move the preincrement and void arg from tests to lint.sh ##syntax

* The regex was not correct, so it was missing a lot of cases
This commit is contained in:
pancake 2022-11-30 17:13:32 +01:00 committed by GitHub
parent 55d59eea17
commit 05947def03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 136 additions and 131 deletions

View File

@ -2715,7 +2715,7 @@ redo:
if (s1->macro_ptr) {
p = s1->macro_ptr;
while (is_space (t = *p) || TOK_LINEFEED == t) {
++p;
p++;
}
if (t == 0 && can_read_stream) {
/* end of macro stream: we must look at the token
@ -2886,10 +2886,13 @@ static inline int *macro_twosharps(TCCState *s1, const int *macro_str) {
macro_str1.len = start_of_nosubsts;
}
/* given 'a##b', skip '##' */
t = *++ptr;
ptr++;
t = *ptr;
/* given 'a##b', remove nosubsts preceding 'b' */
while (t == TOK_NOSUBST)
t = *++ptr;
while (t == TOK_NOSUBST) {
ptr++;
t = *ptr;
}
if (t && t != TOK_TWOSHARPS) {
CValue cval;
TOK_GET (&t, &ptr, &cval);

View File

@ -438,7 +438,8 @@ R_API char *r_anal_rtti_msvc_demangle_class_name(RVTableContext *context, const
char *ret = context->anal->binb.demangle (NULL, "msvc", name, 0, false);
if (ret && *ret) {
char *n = strchr (ret, ' ');
if (n && *(++n)) {
n++;
if (R_STR_ISNOTEMPTY (n)) {
char *tmp = strdup (n);
free (ret);
ret = tmp;

View File

@ -321,7 +321,8 @@ R_API RList *r_anal_var_deserialize(const char *ser) {
if ((!v->delta && nxt == ser) || *nxt != ':') {
goto bad_serial;
}
ser = ++nxt;
nxt++;
ser = nxt;
// name
int i;
@ -335,7 +336,8 @@ R_API RList *r_anal_var_deserialize(const char *ser) {
if (!v->name) {
goto bad_serial;
}
ser = ++nxt;
nxt++;
ser = nxt;
// type
for (i = 0; *nxt && *nxt != ','; i++) {

View File

@ -3771,13 +3771,13 @@ d_clone_suffix (struct d_info *di, struct demangle_component *encoding)
{
pend += 2;
while (IS_LOWER (*pend) || *pend == '_')
++pend;
pend++;
}
while (*pend == '.' && IS_DIGIT (pend[1]))
{
pend += 2;
while (IS_DIGIT (*pend))
++pend;
pend++;
}
d_advance (di, pend - suffix);
n = d_make_name (di, suffix, pend - suffix);
@ -3875,7 +3875,7 @@ d_substitution (struct d_info *di, int prefix)
}
while (c != '_');
++id;
id++;
}
if (id >= (unsigned int) di->next_sub)
@ -4457,7 +4457,7 @@ d_pack_length (const struct demangle_component *dc)
while (dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST
&& d_left (dc))
{
++count;
count++;
dc = d_right (dc);
}
return count;
@ -4482,7 +4482,7 @@ d_args_length (struct d_print_info *dpi, const struct demangle_component *dc)
count += d_pack_length (a);
}
else
++count;
count++;
}
return count;
}
@ -4719,7 +4719,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
adpm[i].mod = typed_name;
adpm[i].printed = 0;
adpm[i].templates = dpi->templates;
++i;
i++;
if (!is_fnqual_component_type (typed_name->type))
break;
@ -4758,7 +4758,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
adpm[i - 1].mod = typed_name;
adpm[i - 1].printed = 0;
adpm[i - 1].templates = dpi->templates;
++i;
i++;
typed_name = d_left (typed_name);
}
@ -5230,7 +5230,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
adpm[i].next = dpi->modifiers;
dpi->modifiers = &adpm[i];
pdpm->printed = 1;
++i;
i++;
}
pdpm = pdpm->next;

View File

@ -373,7 +373,8 @@ static size_t get_operator_code(const char *buf, RList *names_l, bool memorize)
}
SStrInfo *str_info;
size_t read_len = 1;
switch (*++buf) {
buf++;
switch (*buf) {
case '0': SET_OPERATOR_CODE ("constructor"); break;
case '1': SET_OPERATOR_CODE ("~destructor"); break;
case '2': SET_OPERATOR_CODE ("operator new"); break;
@ -426,7 +427,8 @@ static size_t get_operator_code(const char *buf, RList *names_l, bool memorize)
break;
}
case '_':
switch (*++buf) {
buf++;
switch (*buf) {
case '0': SET_OPERATOR_CODE ("operator/="); break;
case '1': SET_OPERATOR_CODE ("operator%="); break;
case '2': SET_OPERATOR_CODE ("operator>>="); break;
@ -451,7 +453,8 @@ static size_t get_operator_code(const char *buf, RList *names_l, bool memorize)
case 'N': SET_OPERATOR_CODE ("eh_vector_vbase_ctor_iter"); break;
case 'O': SET_OPERATOR_CODE ("copy_ctor_closure"); break;
case 'R':
switch (*++buf) {
buf++;
switch (*buf) {
case '0': {
size_t len;
char *str = NULL;
@ -1096,7 +1099,7 @@ static inline void parse_type_modifier(SStateInfo *state, STypeCodeStr *type_cod
free (str);
} else {
if (is_pin_ptr && *modifier_str) {
while (*++modifier_str == ' ') {};
modifier_str = r_str_trim_head_ro (modifier_str + 1);
}
copy_string (&tmp_str, modifier_str, 0);
}

View File

@ -1445,7 +1445,7 @@ R_API int r_cons_get_cursor(int *rows) {
i += 18;
}
} else if (ch2 == '[') {
for (++i; str[i] && str[i] != 'J' && str[i] != 'm' && str[i] != 'H'; i++) {
for (i++; str[i] && str[i] != 'J' && str[i] != 'm' && str[i] != 'H'; i++) {
;
}
}

View File

@ -202,7 +202,8 @@ static void parse_grep_expression(const char *str) {
ptr++;
}
if (*ptr == ':') {
grep->sort_row = atoi (++ptr);
ptr++;
grep->sort_row = atoi (ptr);
ptr++;
}
break;
@ -211,7 +212,8 @@ static void parse_grep_expression(const char *str) {
grep->amp = 1;
break;
case '<':
grep->zoom = atoi (++ptr);
ptr++;
grep->zoom = atoi (ptr);
//grep->zoomy = atoi (arg);
break;
case '+':

View File

@ -193,7 +193,8 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
str = ptr;
continue;
} else if (ptr[0] == '0' && ptr[1] == 'm') {
str = (++ptr) + 1;
ptr++;
str = ptr + 1;
esc = 0;
inv = false;
text_color[0] = '\0';
@ -210,7 +211,8 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
continue;
// reset invert color
} else if (ptr[0] == '7' && ptr[1] == 'm') {
str = (++ptr) + 1;
ptr++;
str = ptr + 1;
inv = true;
need_to_set = true;
esc = 0;

View File

@ -529,7 +529,7 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
asmlen = strlen (c->assembly);
for (ii = 0; ii < asmlen; ii++) {
if (c->assembly[ii] == '\n') {
++numinstr;
numinstr++;
}
}
r_asm_code_free (c);

View File

@ -3593,7 +3593,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
core->print->cur_enabled = ocur_enabled;
}
if (colon && colon[1]) {
for (++colon; *colon == ';'; colon++) {
for (colon++; *colon == ';'; colon++) {
;
}
r_core_cmd_subst (core, colon);

View File

@ -692,8 +692,7 @@ static int cmd_info(void *data, const char *input) {
} else {
RBININFO ("exports", R_CORE_BIN_ACC_EXPORTS, input + 1, 0);
}
while (*(++input)) ;
input--;
input = input + strlen (input) - 1;
break;
}
case 't': // "it"
@ -827,11 +826,7 @@ static int cmd_info(void *data, const char *input) {
}
//we move input until get '\0'
while (*(++input)) {};
//input-- because we are inside a while that does input++
// oob read if not input--
input--;
input = input + strlen (input) - 1;
break;
case 'H': // "iH"
if (input[1] == 'H') { // "iHH"
@ -912,8 +907,7 @@ static int cmd_info(void *data, const char *input) {
RBININFO ("symbols", R_CORE_BIN_ACC_SYMBOLS, input + 1, (obj && obj->symbols)? r_list_length (obj->symbols): 0);
}
}
while (*(++input)) ;
input--;
input = input + strlen (input) - 1;
r_list_free (objs);
break;
}

View File

@ -7923,15 +7923,16 @@ static int cmd_print(void *data, const char *input) {
break;
case 'k': // "pk"
if (input[1] == '?') {
r_cons_printf ("|Usage: pk [len] print key in randomart\n");
r_cons_printf ("|Usage: pkill [process-name]\n");
r_cons_printf ("Usage: pk [len] print key in randomart\n");
r_cons_printf ("Usage: pkill [process-name]\n");
} else if (!strncmp (input, "kill", 4)) {
RListIter *iter;
RDebugPid *pid;
const char *arg = strchr (input, ' ');
RList *pids = (core->dbg->h && core->dbg->h->pids)
? core->dbg->h->pids (core->dbg, 0): NULL;
if (arg && *++arg) {
if (R_STR_ISNOTEMPTY (arg)) {
arg++;
r_list_foreach (pids, iter, pid) {
if (strstr (pid->path, arg)) {
r_cons_printf ("dk 9 %d\n", pid->pid);

View File

@ -1383,11 +1383,12 @@ static int r_cmd_java_handle_set_flags(RCore *core, const char *input) {
? r_cmd_java_get_input_num_value (core, p)
: (ut64)-1;
p = r_cmd_java_strtok (p + 1, ' ', -1);
if (!p || !*p) {
if (R_STR_ISEMPTY (p)) {
r_cmd_java_print_cmd_help (JAVA_CMDS + SET_ACC_FLAGS_IDX);
return true;
}
const char f_type = p && *p? r_cmd_java_is_valid_java_mcf (*(++p)): '?';
p++;
const char f_type = r_cmd_java_is_valid_java_mcf (*p);
int flag_value = r_cmd_java_is_valid_input_num_value (core, p)? r_cmd_java_get_input_num_value (core, p): -1;

View File

@ -8,7 +8,7 @@ R_API bool r_core_patch_line(RCore *core, char *str) {
return false;
}
*p = 0;
for (++p; *p == ' '; p++) {
for (p++; *p == ' '; p++) {
; // XXX: skipsspaces here
}
@ -29,7 +29,7 @@ R_API bool r_core_patch_line(RCore *core, char *str) {
q = strchr (p + 1,' ');
if (q) {
*q = 0;
for (++q; *q == ' '; q++) {
for (q++; *q == ' '; q++) {
; // XXX: skipsspaces here
}
} else {

View File

@ -1578,12 +1578,14 @@ R_API int r_core_visual_anal_classes(RCore *core) {
}
break;
case 'j':
if (++index >= list->length) {
if (index + 1 >= list->length) {
index = 0;
} else {
index++;
}
break;
case 'k':
if (--index < 0) {
if (index-- < 1) {
index = list->length - 1;
}
break;
@ -2975,7 +2977,7 @@ static void variable_rename(RCore *core, ut64 addr, int vindex, const char *name
r_core_seek (core, a_tmp, false);
break;
}
++i;
i++;
}
r_list_free (list);
}
@ -3124,7 +3126,7 @@ static ut64 var_variables_show(RCore* core, int idx, int *vindex, int show, int
break;
}
}
++i;
i++;
}
r_list_free (list);
return addr;

View File

@ -1015,18 +1015,18 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
m->lineno = lineno;
if (*l == '&') { /* m->cont_level == 0 checked below. */
++l; /* step over */
l++; /* step over */
m->flag |= OFFADD;
}
if (*l == '(') {
++l; /* step over */
l++; /* step over */
m->flag |= INDIR;
if (m->flag & OFFADD) {
m->flag = (m->flag & ~OFFADD) | INDIROFFADD;
}
if (*l == '&') { /* m->cont_level == 0 checked below */
++l; /* step over */
l++; /* step over */
m->flag |= OFFADD;
}
}
@ -1137,7 +1137,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
EATAB;
if (*l == 'u') {
++l;
l++;
m->flag |= UNSIGNED;
}
@ -1159,7 +1159,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
} else if (ms->flags & R_MAGIC_CHECK) {
file_magwarn (ms, "'~' invalid for string types");
}
++l;
l++;
}
m->str_range = 0;
m->str_flags = 0;
@ -1167,7 +1167,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
if ((op = get_op (*l)) != -1) {
if (!MAGIC_IS_STRING (m->type)) {
ut64 val;
++l;
l++;
m->mask_op |= op;
val = (ut64)strtoull (l, &t, 0);
l = t;
@ -1176,7 +1176,7 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
}
else if (op == FILE_OPDIVIDE) {
int have_range = 0;
while (!isspace ((ut8)*++l)) {
for (l++; !isspace (*l); l++) {
switch (*l) {
case '0': case '1': case '2':
case '3': case '4': case '5':
@ -1248,22 +1248,22 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
case '^':
case '=':
m->reln = *l;
++l;
l++;
if (*l == '=') {
/* HP compat: ignore &= etc. */
++l;
l++;
}
break;
case '!':
m->reln = *l;
++l;
l++;
break;
default:
m->reln = '='; /* the default relation */
if (*l == 'x' && ((isascii((ut8)l[1]) &&
isspace ((ut8)l[1])) || !l[1])) {
m->reln = *l;
++l;
l++;
}
break;
}
@ -1285,11 +1285,11 @@ static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, con
*/
EATAB;
if (l[0] == '\b') {
++l;
l++;
m->flag |= NOSPACE;
} else if ((l[0] == '\\') && (l[1] == 'b')) {
++l;
++l;
l++;
l++;
m->flag |= NOSPACE;
}
for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof (m->desc);) {}
@ -1969,7 +1969,8 @@ static char *mkdbname(const char *fn, int strip) {
if (strip) {
const char *p;
if ((p = strrchr (fn, '/'))) {
fn = ++p;
p++;
fn = p;
}
}
fnlen = strlen (fn);

View File

@ -148,7 +148,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w0, buf, sizeof (w0) - 1);
@ -157,7 +157,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w1, optr, sizeof (w1) - 1);

View File

@ -123,7 +123,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w0, buf, sizeof (w0) - 1);
@ -133,7 +133,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w1, optr, sizeof (w1)-1);
@ -141,7 +141,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w2, optr, sizeof (w2)-1);

View File

@ -161,7 +161,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w0, buf, WSZ - 1);
@ -171,7 +171,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w1, optr, WSZ - 1);
@ -180,7 +180,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w2, optr, WSZ - 1);
@ -190,7 +190,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w3, optr, WSZ - 1);

View File

@ -262,7 +262,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w0, buf, sizeof (w0) - 1);
@ -278,7 +278,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w1, optr, sizeof (w1) - 1);
@ -289,7 +289,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w2, optr, sizeof (w2) - 1);
@ -301,7 +301,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w3, optr, sizeof (w3) - 1);

View File

@ -152,7 +152,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w2, optr, WSZ - 1);
@ -162,7 +162,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w3, optr, WSZ - 1);

View File

@ -163,7 +163,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w0, buf, WSZ - 1);
@ -173,7 +173,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w1, optr, WSZ - 1);
@ -182,7 +182,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w2, optr, WSZ - 1);
@ -192,7 +192,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w3, optr, WSZ - 1);

View File

@ -1647,7 +1647,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w0, buf, WSZ - 1);
@ -1657,7 +1657,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w1, optr, WSZ - 1);
@ -1666,7 +1666,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w2, optr, WSZ - 1);
@ -1676,7 +1676,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w3, optr, WSZ - 1);
@ -1686,7 +1686,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w4, optr, WSZ - 1);

View File

@ -127,7 +127,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w0, buf, sizeof (w0) - 1);
@ -151,7 +151,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w1, optr, sizeof (w1) - 1);
@ -160,7 +160,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
strncpy (w2, optr, sizeof (w2) - 1);

View File

@ -185,7 +185,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w0, buf, WSZ - 1);
@ -203,7 +203,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w1, optr, WSZ - 1);
@ -220,7 +220,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w2, optr, WSZ - 1);
@ -238,7 +238,7 @@ static int parse(RParse *p, const char *data, char *str) {
}
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
//nothing to see here
}
strncpy (w3, optr, WSZ - 1);

View File

@ -212,7 +212,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr++ = '\0';
for (++ptr; ptr < end ; ptr++) {
for (ptr++; ptr < end ; ptr++) {
if (*ptr != ')' && *ptr != ' ') {
// ptr++;
break;
@ -224,7 +224,7 @@ static int parse(RParse *p, const char *data, char *str) {
ptr = strchr (ptr, ',');
if (ptr) {
*ptr = '\0';
for (++ptr; *ptr == ' '; ptr++) {
for (ptr++; *ptr == ' '; ptr++) {
;
}
r_str_ncpy (w2, optr, sizeof (w2));

View File

@ -301,7 +301,7 @@ R_API RASN1String *r_asn1_stringify_oid(const ut8* buffer, ut32 length) {
return newstr (X509OIDList[i].name);
}
}
++i;
i++;
} while (X509OIDList[i].oid && X509OIDList[i].name);
RASN1String* asn1str = r_asn1_create_string (str, true, ASN1_OID_LEN);
if (!asn1str) {

View File

@ -1629,7 +1629,8 @@ R_API void r_print_raw(RPrint *p, ut64 addr, const ut8 *buf, int len, int offlin
}
p->cb_printf ("\n");
linenum++;
o = ++q;
q++;
o = q;
i++;
} while (!mustbreak);
break;
@ -1644,7 +1645,8 @@ R_API void r_print_c(RPrint *p, const ut8 *str, int len) {
len);
for (i = 0; !r_print_is_interrupted () && i < len;) {
r_print_byte (p, (ut64)i, "0x%02x", i, str[i]);
if (++i < len) {
i++;
if (i < len) {
p->cb_printf (", ");
}
if (!(i % inc)) {
@ -2216,7 +2218,7 @@ R_API char* r_print_colorize_opcode(RPrint *print, char *p, const char *reg, con
#define STRIP_ANSI 1
#if STRIP_ANSI
/* skip until 'm' */
for (++i; p[i] && p[i] != 'm'; i++) {
for (i++; p[i] && p[i] != 'm'; i++) {
o[j] = p[i];
}
j--;

View File

@ -24,7 +24,8 @@ R_API int r_print_pack7bit(const char *src, char *dest) {
sprintf (tmp, "%x", (ch1 & 0x0F));
dest[j++] = tmp[0];
dest[j++] = '\0';
if (7 == ++shift) {
shift++;
if (7 == shift) {
shift = 0;
i++;
}

View File

@ -275,7 +275,7 @@ R_API void *r_skiplist_get_n(RSkipList *list, int n) {
if (count == n) {
return data;
}
++count;
count++;
}
return NULL;
}

View File

@ -2374,7 +2374,8 @@ R_API bool r_str_glob(const char* str, const char *glob) {
}
char* begin = strchr (glob, '^');
if (begin) {
glob = ++begin;
begin++;
glob = begin;
}
while (*str) {
if (!*glob) {
@ -2382,12 +2383,14 @@ R_API bool r_str_glob(const char* str, const char *glob) {
}
switch (*glob) {
case '*':
if (!*++glob) {
glob++;
if (!*glob) {
return true;
}
// Advance glob an additional time if it is a '**'
if (*glob == '*') {
if (!*++glob) {
glob++;
if (!*glob) {
return true;
}
}
@ -2428,7 +2431,9 @@ R_API bool r_str_glob(const char* str, const char *glob) {
glob++;
}
}
while (*glob == '*') { ++glob; }
while (*glob == '*') {
glob++;
}
return ((*glob == '$' && !*glob++) || !*glob);
}
@ -3492,7 +3497,7 @@ R_API bool r_str_isnumber(const char *str) {
return false;
}
while (*++str) {
for (str++; *str; str++) {
if (!IS_DIGIT (*str)) {
return false;
}

View File

@ -269,7 +269,7 @@ R_API int r_str_ansi_trim(char *str, int str_len, int n) {
i += 18;
}
} else if (ch2 == '[') {
for (++i; (i < str_len) && str[i] && str[i] != 'J' && str[i] != 'm' && str[i] != 'H';
for (i++; (i < str_len) && str[i] && str[i] != 'J' && str[i] != 'm' && str[i] != 'H';
i++) {
;
}

View File

@ -635,7 +635,7 @@ R_API char *r_utf16_to_utf8_l(const wchar_t *wc, int len) {
WideCharToMultiByte (CP_UTF8, 0, wc, len, rutf8, csize, NULL, NULL);
#if 0
if ((csize = WideCharToMultiByte (CP_UTF8, 0, wc, len, NULL, 0, NULL, NULL))) {
++csize;
csize++;
if ((rutf8 = malloc (csize))) {
WideCharToMultiByte (CP_UTF8, 0, wc, len, rutf8, csize, NULL, NULL);
if (len != -1) {
@ -676,7 +676,7 @@ R_API char *r_utf8_to_acp_l(const char *str, int len) {
int wcsize, csize;
if ((wcsize = MultiByteToWideChar (CP_UTF8, 0, str, len, NULL, 0))) {
wchar_t *rutf16;
++wcsize;
wcsize++;
if ((rutf16 = (wchar_t *)calloc (wcsize, sizeof (wchar_t)))) {
MultiByteToWideChar (CP_UTF8, 0, str, len, rutf16, wcsize);
if (len != -1) {

View File

@ -2,6 +2,14 @@
cd "$(dirname $0)"/..
# NAME=no preincrement/predecrement in 3rd part of for statement
(git grep -n -e '++[a-z][a-z]*[);]' libr | grep -v arch) && exit 1
# Bad: static void foo() {
# Good: static void foo(void) {
# NAME=use void on functions without parameters
(git grep -e ^R_API -e ^static libr | grep -e '[a-z]() {' -e '[a-z]();') && exit 1
# (git grep -e '_[a-z][a-z](' libr | grep -v '{'| grep c:) && exit 1
# TODO : also check for '{0x'
(git grep '\t{"' libr | grep -v strcmp | grep -v format | grep -v '{",' | grep -v esil | grep c:) && exit 1

View File

@ -1,26 +1,3 @@
NAME=no preincrement/predecrement in 3rd part of for statement
# Bad: for (;; ++i, --j)
# Good: for (;; i++, j--)
FILE=-
# TODO: multiline
CMDS="!git grep \"for[[:space:]]*([^;)]*;[^;)]*;\([^,)(]*,\)*[[:space:]]*\(++\|--\)[[:space:]]*[[:alpha:]_][[:alnum:]_]*[[:space:]]*[,)]\" -- .. :!db/tools/r2 :!../shlr/** :!../libr/asm/arch/** :!../**/mangling/cxx/cp-demangle.c"
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
EOF
RUN
NAME=use void on functions without parameters
# Bad: static void foo() {
# Good: static void foo(void) {
FILE=-
CMDS="!git grep -e ^R_API -e ^static ../libr | grep -e '[a-z]() {' -e '[a-z]();'"
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
EOF
RUN
NAME=r2 --
FILE=bins/elf/bomb
CMDS=r2 -s main -qcs bins/elf/bomb