Line data Source code
1 : /*
2 : * Copyright (c) 2014-2016 ISPRAS (http://www.ispras.ru)
3 : * Institute for System Programming of the Russian Academy of Sciences
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * ee the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #include <linux/ldv/common.h>
19 : #include <verifier/common.h>
20 :
21 : static int ldv_filter_positive_int(int val)
22 : {
23 14 : ldv_assume(val <= 0);
24 7 : return val;
25 : }
26 :
27 : /*
28 : * Implicitly filter positive integers for all undefined functions. See more
29 : * details at https://forge.ispras.ru/issues/7140.
30 : */
31 : int ldv_post_init(int init_ret_val)
32 : {
33 4 : return ldv_filter_positive_int(init_ret_val);
34 : }
35 :
36 : /* Like ldv_post_init(). */
37 : int ldv_post_probe(int probe_ret_val)
38 : {
39 4 : return ldv_filter_positive_int(probe_ret_val);
40 : }
41 :
42 : /* Like ldv_post_init(). */
43 : int ldv_filter_err_code(int ret_val)
44 : {
45 20 : return ldv_filter_positive_int(ret_val);
46 : }
|