LCOV - code coverage report
Current view: top level - external/pflash/ccan/list - list.c (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 0 17 0.0 %
Date: 2024-01-02 21:04:04 Functions: 0 3 0.0 %
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                 :          0 : static void *corrupt(const char *abortstr,
       7                 :            :                      const struct list_node *head,
       8                 :            :                      const struct list_node *node,
       9                 :            :                      unsigned int count)
      10                 :            : {
      11                 :          0 :         if (abortstr) {
      12                 :          0 :                 fprintf(stderr,
      13                 :            :                         "%s: prev corrupt in node %p (%u) of %p\n",
      14                 :            :                         abortstr, node, count, head);
      15                 :          0 :                 abort();
      16                 :            :         }
      17                 :          0 :         return NULL;
      18                 :            : }
      19                 :            : 
      20                 :          0 : 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                 :          0 :         int count = 0;
      25                 :            : 
      26                 :          0 :         for (p = node, n = node->next; n != node; p = n, n = n->next) {
      27                 :          0 :                 count++;
      28                 :          0 :                 if (n->prev != p)
      29                 :          0 :                         return corrupt(abortstr, node, n, count);
      30                 :            :         }
      31                 :            :         /* Check prev on head node. */
      32                 :          0 :         if (node->prev != p)
      33                 :          0 :                 return corrupt(abortstr, node, node, 0);
      34                 :            : 
      35                 :            :         return (struct list_node *)node;
      36                 :            : }
      37                 :            : 
      38                 :          0 : struct list_head *list_check(const struct list_head *h, const char *abortstr)
      39                 :            : {
      40                 :          0 :         if (!list_check_node(&h->n, abortstr))
      41                 :          0 :                 return NULL;
      42                 :            :         return (struct list_head *)h;
      43                 :            : }

Generated by: LCOV version 1.14