LCOV - code coverage report
Current view: top level - home/alexey/klever/native-scheduler-work-dir/native-scheduler-work-dir/scheduler/jobs/032ed983781f2acce615a4df71b22f31/verifier - memory.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 17 41 41.5 %
Date: 2017-01-25 Functions: 5 10 50.0 %

          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/types.h>
      19             : #include <linux/ldv/err.h>
      20             : #include <verifier/common.h>
      21             : #include <verifier/nondet.h>
      22             : #include <verifier/memory.h>
      23             : 
      24             : /* ISO/IEC 9899:1999 specification. p. 313, ยง 7.20.3 "Memory management functions". */
      25             : extern void *malloc(size_t size);
      26             : extern void *calloc(size_t nmemb, size_t size);
      27             : extern void free(void *);
      28             : extern void *memset(void *s, int c, size_t n);
      29             : 
      30             : void *ldv_malloc(size_t size)
      31             : {
      32           0 :         if (ldv_undef_int()) {
      33           0 :                 void *res = malloc(size);
      34           0 :                 ldv_assume(res != NULL);
      35           0 :                 ldv_assume(!ldv_is_err(res));
      36           0 :                 return res;
      37             :         }
      38             :         else {
      39           0 :                 return NULL;
      40             :         }
      41             : }
      42             : 
      43             : void *ldv_calloc(size_t nmemb, size_t size)
      44             : {
      45          40 :         if (ldv_undef_int()) {
      46          24 :                 void *res = calloc(nmemb, size);
      47          24 :                 ldv_assume(res != NULL);
      48          40 :                 ldv_assume(!ldv_is_err(res));
      49           8 :                 return res;
      50             :         }
      51             :         else {
      52           8 :                 return NULL;
      53             :         }
      54             : }
      55             : 
      56             : void *ldv_zalloc(size_t size)
      57             : {
      58          40 :         return ldv_calloc(1, size);
      59             : }
      60             : 
      61             : void ldv_free(void *s)
      62             : {
      63           8 :         free(s);
      64           8 : }
      65             : 
      66             : void *ldv_xmalloc(size_t size)
      67             : {
      68           6 :     void *res = malloc(size);
      69           6 :     ldv_assume(res != NULL);
      70          10 :     ldv_assume(!ldv_is_err(res));
      71           2 :     return res;
      72             : }
      73             : 
      74             : void *ldv_xzalloc(size_t size)
      75             : {
      76           0 :         void *res = calloc(1, size);
      77           0 :         ldv_assume(res != NULL);
      78           0 :         ldv_assume(!ldv_is_err(res));
      79           0 :         return res;
      80             : }
      81             : 
      82             : void *ldv_malloc_unknown_size(void)
      83             : {
      84           0 :         if (ldv_undef_int()) {
      85           0 :                 void *res = external_allocated_data();
      86           0 :                 ldv_assume(res != NULL);
      87           0 :                 ldv_assume(!ldv_is_err(res));
      88           0 :                 return res;
      89             :         }
      90             :         else {
      91           0 :                 return NULL;
      92             :         }
      93             : }
      94             : 
      95             : void *ldv_calloc_unknown_size(void)
      96             : {
      97           0 :         if (ldv_undef_int()) {
      98           0 :                 void *res = external_allocated_data();
      99           0 :                 memset(res, 0, sizeof(res));
     100           0 :                 ldv_assume(res != NULL);
     101           0 :                 ldv_assume(!ldv_is_err(res));
     102           0 :                 return res;
     103             :         }
     104             :         else {
     105           0 :                 return NULL;
     106             :         }
     107             : }
     108             : 
     109             : void *ldv_zalloc_unknown_size(void)
     110             : {
     111           0 :         return ldv_calloc_unknown_size();
     112             : }
     113             : 
     114             : void *ldv_xmalloc_unknown_size(size_t size)
     115             : {
     116          21 :         void *res = external_allocated_data();
     117          21 :         ldv_assume(res != NULL);
     118          35 :         ldv_assume(!ldv_is_err(res));
     119           7 :         return res;
     120             : }

Generated by: LCOV version 1.10