db, extra, user_data: handle: *x = 1; return x;"
[smatch.git] / smatch_annotate.c
blob1b1888308b81d7918f9dfd3eeae8591d275e81b5
1 /*
2 * smatch/smatch_annotate.c
4 * Copyright (C) 2013 Oracle.
6 * Licensed under the Open Software License version 1.1
8 */
11 * A place to add function annotations for common functions.
15 #include "smatch.h"
16 #include "smatch_extra.h"
18 static int param_caps_return(struct expression *call, void *_arg, struct range_list **res)
20 int arg = PTR_INT(_arg);
21 struct expression *expr;
22 struct range_list *rl;
24 expr = get_argument_from_call_expr(call->args, arg);
25 if (get_implied_rl(expr, &rl) && rl_max(rl).value != 0)
26 *res = alloc_rl(sval_type_val(rl_type(rl), 0), rl_max(rl));
27 return 1;
30 void register_annotate(int id)
33 * Technically snprintf() returns the number of bytes which *would* have
34 * been printed. I do try caclulating that in check_snprintf(). But
35 * it probably works better to assume the limitter is accurate.
37 add_implied_return_hook("snprintf", &param_caps_return, INT_PTR(1));