projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Print scalar initialisers as assignment expressions instead of plain expressions...
[cparser]
/
format_check.c
diff --git
a/format_check.c
b/format_check.c
index
a283323
..
5990248
100644
(file)
--- a/
format_check.c
+++ b/
format_check.c
@@
-157,11
+157,11
@@
static void check_printf_format(const call_argument_t *arg, const format_spec_t
{
/* find format arg */
unsigned idx = 0;
{
/* find format arg */
unsigned idx = 0;
- for (; idx < spec->fmt_idx && arg != NULL; ++idx)
+ for (; idx < spec->fmt_idx; ++idx) {
+ if (arg == NULL)
+ return;
arg = arg->next;
arg = arg->next;
-
- if (arg == NULL)
- return;
+ }
const expression_t *fmt_expr = arg->expression;
if (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
const expression_t *fmt_expr = arg->expression;
if (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
@@
-518,6
+518,10
@@
eval_fmt_mod_unsigned:
default:
warningf(pos, "encountered unknown conversion specifier '%%%C' at position %u", (wint_t)fmt, num_fmt);
default:
warningf(pos, "encountered unknown conversion specifier '%%%C' at position %u", (wint_t)fmt, num_fmt);
+ if (arg == NULL) {
+ warningf(pos, "too few arguments for format string");
+ return;
+ }
goto next_arg;
}
goto next_arg;
}
@@
-576,7
+580,7
@@
next_arg:
arg = arg->next;
}
if (!atend(&vchar)) {
arg = arg->next;
}
if (!atend(&vchar)) {
- warningf(pos, "format string contains
NUL
");
+ warningf(pos, "format string contains
'\\0'
");
}
if (arg != NULL) {
unsigned num_args = num_fmt;
}
if (arg != NULL) {
unsigned num_args = num_fmt;
@@
-597,8
+601,11
@@
static void check_scanf_format(const call_argument_t *arg, const format_spec_t *
{
/* find format arg */
unsigned idx = 0;
{
/* find format arg */
unsigned idx = 0;
- for (; idx < spec->fmt_idx; ++idx)
+ for (; idx < spec->fmt_idx; ++idx) {
+ if (arg == NULL)
+ return;
arg = arg->next;
arg = arg->next;
+ }
const expression_t *fmt_expr = arg->expression;
if (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
const expression_t *fmt_expr = arg->expression;
if (fmt_expr->kind == EXPR_UNARY_CAST_IMPLICIT) {
@@
-622,7
+629,7
@@
static void check_scanf_format(const call_argument_t *arg, const format_spec_t *
return;
}
/* find the real args */
return;
}
/* find the real args */
- for (; idx < spec->arg_idx; ++idx)
+ for (; idx < spec->arg_idx
&& arg != NULL
; ++idx)
arg = arg->next;
const source_position_t *pos = &fmt_expr->base.source_position;
arg = arg->next;
const source_position_t *pos = &fmt_expr->base.source_position;
@@
-846,6
+853,10
@@
eval_fmt_mod_unsigned:
default:
warningf(pos, "encountered unknown conversion specifier '%%%C' at position %u", (wint_t)fmt, num_fmt);
default:
warningf(pos, "encountered unknown conversion specifier '%%%C' at position %u", (wint_t)fmt, num_fmt);
+ if (arg == NULL) {
+ warningf(pos, "too few arguments for format string");
+ return;
+ }
goto next_arg;
}
goto next_arg;
}
@@
-891,7
+902,7
@@
next_arg:
arg = arg->next;
}
if (!atend(&vchar)) {
arg = arg->next;
}
if (!atend(&vchar)) {
- warningf(pos, "format string contains
NUL
");
+ warningf(pos, "format string contains
'\\0'
");
}
if (arg != NULL) {
unsigned num_args = num_fmt;
}
if (arg != NULL) {
unsigned num_args = num_fmt;
@@
-899,7
+910,7
@@
next_arg:
++num_args;
arg = arg->next;
}
++num_args;
arg = arg->next;
}
- warningf(pos, "%u argument%s but only %u format s
tring
%s",
+ warningf(pos, "%u argument%s but only %u format s
pecifier
%s",
num_args, num_args != 1 ? "s" : "",
num_fmt, num_fmt != 1 ? "s" : "");
}
num_args, num_args != 1 ? "s" : "",
num_fmt, num_fmt != 1 ? "s" : "");
}