Print this page
smatch: check libld_* allocation functions


  23 {
  24         struct expression *arg_expr;
  25         char *name;
  26         sval_t sval;
  27 
  28         arg_expr = get_argument_from_call_expr(expr->args, 0);
  29         if (!get_implied_value(arg_expr, &sval))
  30                 return;
  31         if (sval.value != 0)
  32                 return;
  33         name = expr_to_var(arg_expr);
  34         sm_warning("calling %s() when '%s' is always NULL.", fn, name);
  35         free_string(name);
  36 }
  37 
  38 void check_freeing_null(int id)
  39 {
  40         my_id = id;
  41         if (!option_spammy)
  42                 return;
  43         if (option_project == PROJ_KERNEL)
  44                 add_function_hook("kfree", &match_free, NULL);
  45         else
  46                 add_function_hook("free", &match_free, NULL);




  47 }


  23 {
  24         struct expression *arg_expr;
  25         char *name;
  26         sval_t sval;
  27 
  28         arg_expr = get_argument_from_call_expr(expr->args, 0);
  29         if (!get_implied_value(arg_expr, &sval))
  30                 return;
  31         if (sval.value != 0)
  32                 return;
  33         name = expr_to_var(arg_expr);
  34         sm_warning("calling %s() when '%s' is always NULL.", fn, name);
  35         free_string(name);
  36 }
  37 
  38 void check_freeing_null(int id)
  39 {
  40         my_id = id;
  41         if (!option_spammy)
  42                 return;
  43         if (option_project == PROJ_KERNEL) {
  44                 add_function_hook("kfree", &match_free, NULL);
  45         } else {
  46                 add_function_hook("free", &match_free, NULL);
  47         }
  48 
  49         if (option_project == PROJ_ILLUMOS_USER)
  50                 add_function_hook("libld_free", &match_free, NULL);
  51 }