Print this page
new smatch
*** 37,46 ****
--- 37,59 ----
tmp = malloc(strlen(str) + 1);
strcpy(tmp, str);
return tmp;
}
+ char *alloc_string_newline(const char *str)
+ {
+ char *tmp;
+ int len;
+
+ if (!str)
+ return NULL;
+ len = strlen(str);
+ tmp = malloc(len + 2);
+ snprintf(tmp, len + 2, "%s\n", str);
+ return tmp;
+ }
+
void free_string(char *str)
{
free(str);
}
*** 274,287 ****
if (array_expr)
append(buf, "]", len);
return;
}
case EXPR_VALUE: {
char tmp[25];
*complicated = 1;
! snprintf(tmp, 25, "%lld", expr->value);
append(buf, tmp, len);
return;
}
case EXPR_STRING:
append(buf, "\"", len);
--- 287,303 ----
if (array_expr)
append(buf, "]", len);
return;
}
case EXPR_VALUE: {
+ sval_t sval = {};
char tmp[25];
*complicated = 1;
! if (!get_value(expr, &sval))
! return;
! snprintf(tmp, 25, "%s", sval_to_numstr(sval));
append(buf, tmp, len);
return;
}
case EXPR_STRING:
append(buf, "\"", len);
*** 587,597 ****
if (!strcmp(expr->symbol_name->name, name))
return 1;
return 0;
}
! int is_zero(struct expression *expr)
{
sval_t sval;
if (get_value(expr, &sval) && sval.value == 0)
return 1;
--- 603,613 ----
if (!strcmp(expr->symbol_name->name, name))
return 1;
return 0;
}
! int expr_is_zero(struct expression *expr)
{
sval_t sval;
if (get_value(expr, &sval) && sval.value == 0)
return 1;
*** 816,843 ****
if (cur_func->type == SYM_PTR && sval.value == 0)
return 1;
return 0;
}
! int getting_address(void)
{
! struct expression *tmp;
! int i = 0;
! int dot_ops = 0;
! FOR_EACH_PTR_REVERSE(big_expression_stack, tmp) {
! if (!i++)
! continue;
! if (tmp->type == EXPR_PREOP && tmp->op == '(')
! continue;
! if (tmp->op == '.' && !dot_ops++)
! continue;
! if (tmp->op == '&')
! return 1;
! return 0;
! } END_FOR_EACH_PTR_REVERSE(tmp);
! return 0;
}
int get_struct_and_member(struct expression *expr, const char **type, const char **member)
{
struct symbol *sym;
--- 832,856 ----
if (cur_func->type == SYM_PTR && sval.value == 0)
return 1;
return 0;
}
! int getting_address(struct expression *expr)
{
! int deref_count = 0;
! while ((expr = expr_get_parent_expr(expr))) {
! if (expr->type == EXPR_PREOP && expr->op == '*') {
! /* &foo->bar->baz dereferences "foo->bar" */
! if (deref_count == 0)
! deref_count++;
! return false;
! }
! if (expr->type == EXPR_PREOP && expr->op == '&')
! return true;
! }
! return false;
}
int get_struct_and_member(struct expression *expr, const char **type, const char **member)
{
struct symbol *sym;