struct_assignment: add a comment explaining what the file does
[smatch.git] / check_memset.c
blobcc59b2ed35f5c9f69f13ec6a7691df0239b109e3
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(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);