2 * smatch/check_input_free_device.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 * Don't call input_free_device() after calling
12 * input_unregister_device()
17 #include "smatch_slist.h"
24 static void match_assign(struct expression
*expr
)
26 if (get_state_expr(my_id
, expr
->left
)) {
27 set_state_expr(my_id
, expr
->left
, &ok
);
31 static void match_input_unregister(const char *fn
, struct expression
*expr
, void *data
)
33 struct expression
*arg
;
35 arg
= get_argument_from_call_expr(expr
->args
, 0);
36 set_state_expr(my_id
, arg
, &no_free
);
39 static void match_input_free(const char *fn
, struct expression
*expr
, void *data
)
41 struct expression
*arg
;
44 arg
= get_argument_from_call_expr(expr
->args
, 0);
45 sm
= get_sm_state_expr(my_id
, arg
);
48 if (!slist_has_state(sm
->possible
, &no_free
))
50 sm_msg("error: don't call input_free_device() after input_unregister_device()");
53 void check_input_free_device(int id
)
56 if (option_project
!= PROJ_KERNEL
)
58 add_hook(&match_assign
, ASSIGNMENT_HOOK
);
59 add_function_hook("input_unregister_device", &match_input_unregister
, NULL
);
60 add_function_hook("input_free_device", &match_input_free
, NULL
);