sval: update smatch_math.c to use range_list_sval
[smatch.git] / check_memset.c
blob1e17940a0f15c59836459c5c6120a5a333603b1e
1 /*
2 * sparse/check_memset.c
4 * Copyright (C) 2011 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
12 static int my_id;
14 static void match_memset(const char *fn, struct expression *expr, void *data)
16 struct expression *arg_expr;
17 sval_t sval;
19 arg_expr = get_argument_from_call_expr(expr->args, 2);
21 if (arg_expr->type != EXPR_VALUE)
22 return;
23 if (!get_value_sval(arg_expr, &sval))
24 return;
25 if (sval.value != 0)
26 return;
27 sm_msg("error: calling memset(x, y, 0);");
30 void check_memset(int id)
32 my_id = id;
33 add_function_hook("memset", &match_memset, NULL);
34 add_function_hook("__builtin_memset", &match_memset, NULL);