LCOV - code coverage report
Current view: top level - include/linux - delayed_call.h (source / functions) Hit Total Coverage
Test: combined.info Lines: 9 9 100.0 %
Date: 2022-03-28 16:04:14 Functions: 0 0 -
Branches: 5 14 35.7 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0 */
       2                 :            : #ifndef _DELAYED_CALL_H
       3                 :            : #define _DELAYED_CALL_H
       4                 :            : 
       5                 :            : /*
       6                 :            :  * Poor man's closures; I wish we could've done them sanely polymorphic,
       7                 :            :  * but...
       8                 :            :  */
       9                 :            : 
      10                 :            : struct delayed_call {
      11                 :            :         void (*fn)(void *);
      12                 :            :         void *arg;
      13                 :            : };
      14                 :            : 
      15                 :            : #define DEFINE_DELAYED_CALL(name) struct delayed_call name = {NULL, NULL}
      16                 :            : 
      17                 :            : /* I really wish we had closures with sane typechecking... */
      18                 :      19466 : static inline void set_delayed_call(struct delayed_call *call,
      19                 :            :                 void (*fn)(void *), void *arg)
      20                 :            : {
      21                 :      19466 :         call->fn = fn;
      22         [ #  # ]:      19466 :         call->arg = arg;
      23                 :            : }
      24                 :            : 
      25                 :     156643 : static inline void do_delayed_call(struct delayed_call *call)
      26                 :            : {
      27   [ -  -  +  +  :     156643 :         if (call->fn)
          -  -  +  +  -  
                -  -  + ]
      28                 :      19466 :                 call->fn(call->arg);
      29                 :            : }
      30                 :            : 
      31                 :     137316 : static inline void clear_delayed_call(struct delayed_call *call)
      32                 :            : {
      33                 :     137290 :         call->fn = NULL;
      34                 :         26 : }
      35                 :            : #endif

Generated by: LCOV version 1.14