#include "smatch.h"
#include "smatch_slist.h"
static int my_id;
static void match_test_bit(const char *fn, struct expression *expr, void *data)
{
struct expression *arg;
char *macro;
arg = get_argument_from_call_expr(expr->args, 0);
arg = strip_expr(arg);
if (!arg || arg->type != EXPR_BINOP)
return;
if (arg->op != '|' && arg->op != SPECIAL_LEFTSHIFT)
return;
macro = get_macro_name(arg->pos);
if (macro && strstr(macro, "cpu_has"))
return;
sm_warning("test_bit() takes a bit number");
}
void check_test_bit(int id)
{
my_id = id;
if (option_project != PROJ_KERNEL)
return;
add_function_hook("test_bit", &match_test_bit, NULL);
add_function_hook("variable_test_bit", &match_test_bit, NULL);
add_function_hook("set_bit", &match_test_bit, NULL);
add_function_hook("clear_bit", &match_test_bit, NULL);
add_function_hook("test_and_clear_bit", &match_test_bit, NULL);
add_function_hook("test_and_set_bit", &match_test_bit, NULL);
}