db: make member_info callbacks take 1 or 0 instead of "static" or "global"
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 12 Feb 2013 07:31:59 +0000 (12 10:31 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 14 Feb 2013 12:03:13 +0000 (14 15:03 +0300)
I want to just print raw SQL here and in the SQL it's just a 1 or 0.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_user_data.c
smatch.h
smatch_buf_size.c
smatch_capped.c
smatch_db.c
smatch_extra.c

index e114e90..7b24b34 100644 (file)
@@ -310,11 +310,11 @@ static void match_caller_info(struct expression *expr)
        free_string(func);
 }
 
-static void struct_member_callback(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state)
+static void struct_member_callback(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state)
 {
        if (state == &capped)
                return;
-       sm_msg("info: passes user_data '%s' %d '%s' %s", fn, param, printed_name, global_static);
+       sm_msg("info: passes user_data '%s' %d '%s' %s", fn, param, printed_name, static_flag ? "static" : "global");
 }
 
 static void print_returned_user_data(int return_id, char *return_ranges, struct expression *expr, struct state_list *slist)
index 705bab8..afe60e7 100644 (file)
--- a/smatch.h
+++ b/smatch.h
@@ -483,7 +483,7 @@ enum info_type {
 };
 
 void add_definition_db_callback(void (*callback)(const char *name, struct symbol *sym, char *key, char *value), int type);
-void add_member_info_callback(int owner, void (*callback)(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state));
+void add_member_info_callback(int owner, void (*callback)(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state));
 void add_returned_state_callback(void (*fn)(int return_id, char *return_ranges, struct expression *returned_expr, struct state_list *slist));
 void add_returned_member_callback(int owner, void (*callback)(int return_id, char *return_ranges, char *printed_name, struct smatch_state *state));
 void add_db_fn_call_callback(int type, void (*callback)(struct expression *arg, char *value));
index 1a3657a..beda9a3 100644 (file)
@@ -623,11 +623,11 @@ static void match_call(struct expression *expr)
        free_string(name);
 }
 
-static void struct_member_callback(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state)
+static void struct_member_callback(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state)
 {
        if (state == &merged)
                return;
-       sm_msg("info: passes_buffer '%s' %d '%s' %s %s", fn, param, printed_name, state->name, global_static);
+       sm_msg("info: passes_buffer '%s' %d '%s' %s %s", fn, param, printed_name, state->name, static_flag ? "static" : "global");
 }
 
 static void match_func_end(struct symbol *sym)
index 26eab9c..83f79c2 100644 (file)
@@ -159,11 +159,11 @@ static void match_caller_info(struct expression *expr)
        free_string(func);
 }
 
-static void struct_member_callback(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state)
+static void struct_member_callback(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state)
 {
        if (state != &capped)
                return;
-       sm_msg("info: passes capped_data '%s' %d '%s' %s", fn, param, printed_name, global_static);
+       sm_msg("info: passes capped_data '%s' %d '%s' %s", fn, param, printed_name, static_flag ? "static" : "global");
 }
 
 void register_capped(int id)
index 5deaecb..dbd1f86 100644 (file)
@@ -35,7 +35,7 @@ static struct callback_list *callbacks;
 
 struct member_info_callback {
        int owner;
-       void (*callback)(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state);
+       void (*callback)(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state);
 };
 ALLOCATOR(member_info_callback, "caller_info callbacks");
 DECLARE_PTR_LIST(member_info_cb_list, struct member_info_callback);
@@ -124,7 +124,7 @@ void add_definition_db_callback(void (*callback)(const char *name, struct symbol
  * member information.  For example foo->bar could have a state in
  * smatch_extra.c and also check_user.c.
  */
-void add_member_info_callback(int owner, void (*callback)(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state))
+void add_member_info_callback(int owner, void (*callback)(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state))
 {
        struct member_info_callback *member_callback = __alloc_member_info_callback(0);
 
@@ -218,8 +218,8 @@ static void match_call_hack(struct expression *expr)
        free_string(name);
 }
 
-static void print_struct_members(char *fn, char *global_static, struct expression *expr, int param, struct state_list *slist,
-       void (*callback)(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state))
+static void print_struct_members(char *fn, int static_flag, struct expression *expr, int param, struct state_list *slist,
+       void (*callback)(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state))
 {
        struct sm_state *sm;
        char *name;
@@ -248,7 +248,7 @@ static void print_struct_members(char *fn, char *global_static, struct expressio
                        snprintf(printed_name, sizeof(printed_name), "$$->%s", sm->name + len + 1);
                else
                        snprintf(printed_name, sizeof(printed_name), "$$%s", sm->name + len);
-               callback(fn, global_static, param, printed_name, sm->state);
+               callback(fn, static_flag, param, printed_name, sm->state);
        } END_FOR_EACH_PTR(sm);
 free:
        free_string(name);
@@ -261,22 +261,16 @@ static void match_call_info(struct expression *expr)
        struct state_list *slist;
        char *name;
        int i;
-       char *gs;
 
        name = get_fnptr_name(expr->fn);
        if (!name)
                return;
 
-       if (is_static(expr->fn))
-               gs = (char *)"static";
-       else
-               gs = (char *)"global";
-
        FOR_EACH_PTR(member_callbacks, cb) {
                slist = get_all_states(cb->owner);
                i = 0;
                FOR_EACH_PTR(expr->args, arg) {
-                       print_struct_members(name, gs, arg, i, slist, cb->callback);
+                       print_struct_members(name, is_static(expr->fn), arg, i, slist, cb->callback);
                        i++;
                } END_FOR_EACH_PTR(arg);
                free_slist(&slist);
index 0c405de..995e494 100644 (file)
@@ -988,11 +988,11 @@ int implied_not_equal(struct expression *expr, long long val)
        return !possibly_false(expr, SPECIAL_NOTEQUAL, value_expr(val));
 }
 
-static void struct_member_callback(char *fn, char *global_static, int param, char *printed_name, struct smatch_state *state)
+static void struct_member_callback(char *fn, int static_flag, int param, char *printed_name, struct smatch_state *state)
 {
        if (estate_is_whole(state))
                return;
-       sm_msg("info: passes param_value '%s' %d '%s' %s %s", fn, param, printed_name, state->name, global_static);
+       sm_msg("info: passes param_value '%s' %d '%s' %s %s", fn, param, printed_name, state->name, static_flag ? "static" : "global");
 }
 
 static void db_limited_before(void)