2 * sparse/check_err_ptr.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 * Functions should never return both NULL and ERR_PTR().
15 #include "smatch_slist.h"
19 static struct symbol
*this_func
;
20 static int err_ptr
= 0;
21 static int returns_null
= 0;
23 static void match_function_def(struct symbol
*sym
)
28 static void match_err_ptr(const char *fn
, struct expression
*expr
, void *info
)
31 smatch_msg("info: returns_err_ptr");
35 static void match_return(struct statement
*stmt
)
37 if (get_implied_value(stmt
->ret_value
) != 0)
40 smatch_msg("info: returns_null");
44 static void match_end_func(struct symbol
*sym
)
50 void check_err_ptr(int id
)
53 add_hook(&match_function_def
, FUNC_DEF_HOOK
);
54 add_function_hook("ERR_PTR", &match_err_ptr
, NULL
);
55 add_hook(&match_return
, RETURN_HOOK
);
56 add_hook(&match_end_func
, END_FUNC_HOOK
);