diff options
| author | Jan Pokorný <pokorny_jan@seznam.cz> | 2011-04-26 00:29:46 -0700 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2011-04-26 00:29:46 -0700 |
| commit | 7988e483ef47abb97004d7fb7f72b7037aa06bb6 (patch) | |
| tree | 9e940de3ad9aae42f2785ad0ea4b0e0763148fdd /expression.c | |
| parent | d04fa1196af5678574d3e1b88bdb1cda85ad7f58 (diff) | |
| download | sparse-dev-7988e483ef47abb97004d7fb7f72b7037aa06bb6.tar.gz | |
use ARRAY_SIZE() when possible (continued)
Some cases were omitted with the patch from Namhyung Kim
(commit c5e425e in Chris Li's repo).
My curiosity led me to try out coccinelle/spatch as suggested by
Nicholas Mc Guire in reply to Kim's patch, but it*) only discovered
occurrences in show-parse.c, probably because of "const vs. non-const"
differences of array item types and the expression given to sizeof.
*) sequence to try coccinelle out on this case (when coccinelle installed):
$ wget http://coccinelle.lip6.fr/rules/array.cocci
$ sed 's/<linux\/kernel.h>/"lib.h"/' array.cocci > array-sparse.cocci
$ for i in $(find . -path ./validation -prune -o -name "*.c" -print); \
> do spatch -sp_file array-sparse.cocci $i; done
Beside proceeding messages, this will print out any "real" patch
generated according to the semantic patch in `array-sparse.cocci'
(it can also reflect these changes directly etc.).
Signed-off-by: Jan Pokorny <pokorny_jan@seznam.cz>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'expression.c')
| -rw-r--r-- | expression.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/expression.c b/expression.c index 7e06e601..d9cdfd39 100644 --- a/expression.c +++ b/expression.c @@ -916,7 +916,7 @@ struct token *assignment_expression(struct token *token, struct expression **tre SPECIAL_SHR_ASSIGN, SPECIAL_AND_ASSIGN, SPECIAL_OR_ASSIGN, SPECIAL_XOR_ASSIGN }; int i, op = token->special; - for (i = 0; i < sizeof(assignments)/sizeof(int); i++) + for (i = 0; i < ARRAY_SIZE(assignments); i++) if (assignments[i] == op) { struct expression * expr = alloc_expression(token->pos, EXPR_ASSIGNMENT); expr->left = *tree; |
