LCOV - code coverage report
Current view: top level - include/linux - bsearch.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 8 0.0 %
Date: 2023-07-19 18:55:55 Functions: 0 0 -

          Line data    Source code
       1             : /* SPDX-License-Identifier: GPL-2.0 */
       2             : #ifndef _LINUX_BSEARCH_H
       3             : #define _LINUX_BSEARCH_H
       4             : 
       5             : #include <linux/types.h>
       6             : 
       7             : static __always_inline
       8             : void *__inline_bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
       9             : {
      10             :         const char *pivot;
      11             :         int result;
      12             : 
      13           0 :         while (num > 0) {
      14           0 :                 pivot = base + (num >> 1) * size;
      15           0 :                 result = cmp(key, pivot);
      16             : 
      17           0 :                 if (result == 0)
      18             :                         return (void *)pivot;
      19             : 
      20           0 :                 if (result > 0) {
      21           0 :                         base = pivot + size;
      22           0 :                         num--;
      23             :                 }
      24           0 :                 num >>= 1;
      25             :         }
      26             : 
      27             :         return NULL;
      28             : }
      29             : 
      30             : extern void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp);
      31             : 
      32             : #endif /* _LINUX_BSEARCH_H */

Generated by: LCOV version 1.14