2 * sparse/check_dma_on_stack.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 static void match_dma_func(const char *fn
, struct expression
*expr
, void *param
)
16 struct expression
*arg
;
20 arg
= get_argument_from_call_expr(expr
->args
, PTR_INT(param
));
21 arg
= strip_expr(arg
);
24 if (arg
->type
== EXPR_PREOP
&& arg
->op
== '&') {
25 if (arg
->unop
->type
!= EXPR_SYMBOL
)
27 name
= get_variable_from_expr(arg
, NULL
);
28 sm_msg("error: doing dma on the stack (%s)", name
);
32 if (arg
->type
!= EXPR_SYMBOL
)
35 if (!sym
|| sym
->type
!= SYM_ARRAY
)
37 name
= get_variable_from_expr(arg
, NULL
);
38 sm_msg("error: doing dma on the stack (%s)", name
);
42 static void register_funcs_from_file(void)
48 token
= get_tokens_file("kernel.dma_funcs");
51 if (token_type(token
) != TOKEN_STREAMBEGIN
)
54 while (token_type(token
) != TOKEN_STREAMEND
) {
55 if (token_type(token
) != TOKEN_IDENT
)
57 func
= show_ident(token
->ident
);
59 if (token_type(token
) != TOKEN_NUMBER
)
61 arg
= atoi(token
->number
);
62 add_function_hook(func
, &match_dma_func
, INT_PTR(arg
));
68 void check_dma_on_stack(int id
)
70 if (option_project
!= PROJ_KERNEL
)
73 register_funcs_from_file();