1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
diff --git a/check_locking.c b/check_locking.c
index 30a658d..595e422 100644
--- a/check_locking.c
+++ b/check_locking.c
@@ -354,7 +354,7 @@ static void do_unlock(const char *name)
static void match_lock_held(const char *fn, struct expression *call_expr,
struct expression *assign_expr, void *_index)
{
- int index = (int)_index;
+ int index = *(int*)_index;
char *lock_name;
struct lock_info *lock = &lock_table[index];
@@ -376,7 +376,7 @@ static void match_lock_held(const char *fn, struct expression *call_expr,
static void match_lock_failed(const char *fn, struct expression *call_expr,
struct expression *assign_expr, void *_index)
{
- int index = (int)_index;
+ int index = *(int*)_index;
char *lock_name;
struct lock_info *lock = &lock_table[index];
@@ -399,7 +399,7 @@ static void match_returns_locked(const char *fn, struct expression *expr,
void *_index)
{
char *full_name = NULL;
- int index = (int)_index;
+ int index = *(int*)_index;
struct lock_info *lock = &lock_table[index];
if (lock->arg != RETURN_VAL)
@@ -411,7 +411,7 @@ static void match_returns_locked(const char *fn, struct expression *expr,
static void match_lock_unlock(const char *fn, struct expression *expr, void *_index)
{
char *full_name = NULL;
- int index = (int)_index;
+ int index = *(int*)_index;
struct lock_info *lock = &lock_table[index];
full_name = get_full_name(expr, index);
@@ -624,7 +624,7 @@ static void match_func_end(struct symbol *sym)
static void register_lock(int index)
{
struct lock_info *lock = &lock_table[index];
- void *idx = (void *)index;
+ void *idx = &index;
if (lock->return_type == ret_non_zero) {
return_implies_state(lock->function, 1, POINTER_MAX, &match_lock_held, idx);
@@ -649,7 +649,7 @@ static void load_table(struct lock_info *_lock_table, int size)
if (lock_table[i].action == LOCK)
register_lock(i);
else
- add_function_hook(lock_table[i].function, &match_lock_unlock, (void *)i);
+ add_function_hook(lock_table[i].function, &match_lock_unlock, &i);
}
}
diff --git a/check_unused_ret.c b/check_unused_ret.c
index 2f277c2..94afb66 100644
--- a/check_unused_ret.c
+++ b/check_unused_ret.c
@@ -59,7 +59,7 @@ static struct smatch_state *my_alloc_state(int assign_id)
snprintf(buff, 255, "assign_%d", assign_id);
buff[255] = '\0';
state->name = alloc_string(buff);
- state->data = (void *) assign_id;
+ state->data = &assign_id;
return state;
}
@@ -122,7 +122,7 @@ static void delete_used_symbols(struct state_list *possible)
struct sm_state *tmp;
FOR_EACH_PTR(possible, tmp) {
- delete_used((int)tmp->state->data);
+ delete_used(*(int*)tmp->state->data);
} END_FOR_EACH_PTR(tmp);
}
diff --git a/smatch_extra.c b/smatch_extra.c
index 45e8bf7..c094be6 100644
--- a/smatch_extra.c
+++ b/smatch_extra.c
@@ -12,7 +12,6 @@
*/
#include <stdlib.h>
-#define __USE_ISOC99
#include <limits.h>
#include "parse.h"
#include "smatch.h"
|