Print this page
12166 resync smatch to 0.6.1-rc1-il-3

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_function_hooks.c
          +++ new/usr/src/tools/smatch/src/smatch_function_hooks.c
↓ open down ↓ 1070 lines elided ↑ open up ↑
1071 1071                  return 0;
1072 1072  
1073 1073          return_id = atoi(argv[0]);
1074 1074          ret_str = argv[1];
1075 1075          type = atoi(argv[2]);
1076 1076          param = atoi(argv[3]);
1077 1077          key = argv[4];
1078 1078          value = argv[5];
1079 1079  
1080 1080          if (db_info->prev_return_id != -1 && type == INTERNAL) {
     1081 +                call_ranged_return_hooks(db_info);
1081 1082                  stree = __pop_fake_cur_stree();
1082 1083                  if (!db_info->cull)
1083 1084                          merge_fake_stree(&db_info->stree, stree);
1084 1085                  free_stree(&stree);
1085 1086                  __push_fake_cur_stree();
1086 1087                  __unnullify_path();
1087 1088                  db_info->cull = 0;
1088 1089          }
1089 1090          db_info->prev_return_id = return_id;
1090 1091  
↓ open down ↓ 10 lines elided ↑ open up ↑
1101 1102                  return 0;
1102 1103          }
1103 1104  
1104 1105          if (type == PARAM_LIMIT)
1105 1106                  param_limit_implications(db_info->expr, param, key, value);
1106 1107  
1107 1108          call_results_to_rl(db_info->expr, get_type(strip_expr(db_info->expr)), ret_str, &ret_range);
1108 1109          ret_range = cast_rl(get_type(db_info->expr), ret_range);
1109 1110  
1110 1111          if (type == INTERNAL) {
     1112 +                struct smatch_state *state;
     1113 +
1111 1114                  set_state(-1, "unnull_path", NULL, &true_state);
1112 1115                  __add_return_comparison(strip_expr(db_info->expr), ret_str);
1113 1116                  __add_return_to_param_mapping(db_info->expr, ret_str);
     1117 +                /*
     1118 +                 * We want to store the return values so that we can split the strees
     1119 +                 * in smatch_db.c.  This uses set_state() directly because it's not a
     1120 +                 * real smatch_extra state.
     1121 +                 */
     1122 +                snprintf(buf, sizeof(buf), "return %p", db_info->expr);
     1123 +                state = alloc_estate_rl(ret_range);
     1124 +                set_state(SMATCH_EXTRA, buf, NULL, state);
     1125 +                store_return_state(db_info, ret_str, state);
1114 1126          }
1115 1127  
1116 1128          FOR_EACH_PTR(db_return_states_list, tmp) {
1117 1129                  if (tmp->type == type)
1118 1130                          tmp->callback(db_info->expr, param, key, value);
1119 1131          } END_FOR_EACH_PTR(tmp);
1120 1132  
1121      -        /*
1122      -         * We want to store the return values so that we can split the strees
1123      -         * in smatch_db.c.  This uses set_state() directly because it's not a
1124      -         * real smatch_extra state.
1125      -         */
1126      -        snprintf(buf, sizeof(buf), "return %p", db_info->expr);
1127      -        set_state(SMATCH_EXTRA, buf, NULL, alloc_estate_rl(ret_range));
1128 1133  
1129 1134          return 0;
1130 1135  }
1131 1136  
1132 1137  static void db_return_states(struct expression *expr)
1133 1138  {
1134 1139          struct sm_state *sm;
1135 1140          struct stree *stree;
1136 1141          struct db_callback_info db_info = {};
1137 1142  
↓ open down ↓ 3 lines elided ↑ open up ↑
1141 1146          db_info.prev_return_id = -1;
1142 1147          db_info.expr = expr;
1143 1148          db_info.stree = NULL;
1144 1149  
1145 1150          call_return_states_before_hooks();
1146 1151  
1147 1152          __push_fake_cur_stree();
1148 1153          __unnullify_path();
1149 1154          sql_select_return_states("return_id, return, type, parameter, key, value",
1150 1155                          expr, db_return_states_callback, &db_info);
     1156 +        call_ranged_return_hooks(&db_info);
1151 1157          stree = __pop_fake_cur_stree();
1152 1158          if (!db_info.cull)
1153 1159                  merge_fake_stree(&db_info.stree, stree);
1154 1160          free_stree(&stree);
1155 1161  
1156 1162          FOR_EACH_SM(db_info.stree, sm) {
1157 1163                  __set_sm(sm);
1158 1164          } END_FOR_EACH_SM(sm);
1159 1165  
1160 1166          free_stree(&db_info.stree);
↓ open down ↓ 98 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX