LCOV - code coverage report
Current view: top level - ccan/list - list.c (source / functions) Coverage Total Hit
Test: skiboot.info Lines: 94.7 % 19 18
Test Date: 2025-01-24 18:40:10 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Licensed under BSD-MIT - see LICENSE file for details */
       2                 :             : #include <stdio.h>
       3                 :             : #include <stdlib.h>
       4                 :             : #include "list.h"
       5                 :             : 
       6                 :          70 : static void *corrupt(const char *abortstr,
       7                 :             :                      const struct list_node *head,
       8                 :             :                      const struct list_node *node,
       9                 :             :                      unsigned int count)
      10                 :             : {
      11                 :          70 :         if (abortstr) {
      12                 :          40 :                 fprintf(stderr,
      13                 :             :                         "%s: prev corrupt in node %p (%u) of %p\n",
      14                 :             :                         abortstr, node, count, head);
      15                 :          40 :                 abort();
      16                 :             :         }
      17                 :          30 :         return NULL;
      18                 :             : }
      19                 :             : 
      20                 :        3260 : struct list_node *list_check_node(const struct list_node *node,
      21                 :             :                                   const char *abortstr)
      22                 :             : {
      23                 :           0 :         const struct list_node *p, *n;
      24                 :        3260 :         int count = 0;
      25                 :             : 
      26                 :        8290 :         for (p = node, n = node->next; n != node; p = n, n = n->next) {
      27                 :        5050 :                 count++;
      28                 :        5050 :                 if (n->prev != p)
      29                 :          20 :                         return corrupt(abortstr, node, n, count);
      30                 :             :         }
      31                 :             :         /* Check prev on head node. */
      32                 :        3240 :         if (node->prev != p)
      33                 :          50 :                 return corrupt(abortstr, node, node, 0);
      34                 :             : 
      35                 :        3190 :         return (struct list_node *)node;
      36                 :             : }
      37                 :             : 
      38                 :        2630 : struct list_head *list_check(const struct list_head *h, const char *abortstr)
      39                 :             : {
      40                 :        2630 :         if (!list_check_node(&h->n, abortstr))
      41                 :          20 :                 return NULL;
      42                 :        2580 :         return (struct list_head *)h;
      43                 :             : }
        

Generated by: LCOV version 2.0-1