LCOV - code coverage report
Current view: top level - include - err.h (source / functions) Hit Total Coverage
Test: coverage3.info Lines: 2 2 100.0 %
Date: 2014-04-22 Functions: 0 0 -
Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Adopted from linux kernel
       3                 :            :  */
       4                 :            : #ifndef __CR_ERR_H__
       5                 :            : #define __CR_ERR_H__
       6                 :            : 
       7                 :            : #include "compiler.h"
       8                 :            : 
       9                 :            : /*
      10                 :            :  * The address of a block returned by malloc or realloc in GNU
      11                 :            :  * systems is always a multiple of eight (or sixteen on 64-bit systems).
      12                 :            :  *
      13                 :            :  * Thus we may encode error number in low bits.
      14                 :            :  */
      15                 :            : #define MAX_ERRNO       4095
      16                 :            : 
      17                 :            : #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
      18                 :            : 
      19                 :            : static inline void *ERR_PTR(long error)
      20                 :            : {
      21                 :            :         return (void *)error;
      22                 :            : }
      23                 :            : 
      24                 :            : static inline long PTR_ERR(const void *ptr)
      25                 :            : {
      26                 :            :         return (long)ptr;
      27                 :            : }
      28                 :            : 
      29                 :            : static inline long IS_ERR(const void *ptr)
      30                 :            : {
      31                 :        102 :         return IS_ERR_VALUE((unsigned long)ptr);
      32                 :            : }
      33                 :            : 
      34                 :            : static inline long IS_ERR_OR_NULL(const void *ptr)
      35                 :            : {
      36 [ +  - ][ +  - ]:        212 :         return !ptr || IS_ERR_VALUE((unsigned long)ptr);
         [ +  - ][ +  - ]
      37                 :            : }
      38                 :            : 
      39                 :            : static inline void *ERR_CAST(const void *ptr)
      40                 :            : {
      41                 :            :         /* cast away the const */
      42                 :            :         return (void *)ptr;
      43                 :            : }
      44                 :            : 
      45                 :            : static inline int PTR_RET(const void *ptr)
      46                 :            : {
      47                 :            :         if (IS_ERR(ptr))
      48                 :            :                 return PTR_ERR(ptr);
      49                 :            :         else
      50                 :            :                 return 0;
      51                 :            : }
      52                 :            : 
      53                 :            : #endif /* __CR_ERR_H__ */

Generated by: LCOV version 1.9