1    	#include "clusterautoconfig.h"
2    	
3    	#include <stdint.h>
4    	#include <unistd.h>
5    	#include <libintl.h>
6    	#include <string.h>
7    	
8    	#include <logging.h>
9    	#include "libgfs2.h"
10   	#include "osi_list.h"
11   	#include "inode_hash.h"
12   	#include "fsck.h"
13   	#define _(String) gettext(String)
14   	
15   	struct inode_info *inodetree_find(struct fsck_cx *cx, uint64_t block)
16   	{
17   		struct osi_node *node = cx->inodetree.osi_node;
18   	
(66) Event example_checked: Example 4: "cx->inodetree.osi_node" has its value checked in "node".
Also see events: [null_field][example_checked][example_checked][example_checked][example_checked][dereference]
19   		while (node) {
20   			struct inode_info *data = (struct inode_info *)node;
21   	
22   			if (block < data->num.in_addr)
23   				node = node->osi_left;
24   			else if (block > data->num.in_addr)
25   				node = node->osi_right;
26   			else
27   				return data;
28   		}
29   		return NULL;
30   	}
31   	
32   	struct inode_info *inodetree_insert(struct fsck_cx *cx, struct lgfs2_inum no)
33   	{
34   		struct osi_node **newn = &cx->inodetree.osi_node, *parent = NULL;
35   		struct inode_info *data;
36   	
37   		/* Figure out where to put new node */
38   		while (*newn) {
39   			struct inode_info *cur = (struct inode_info *)*newn;
40   	
41   			parent = *newn;
42   			if (no.in_addr < cur->num.in_addr)
43   				newn = &((*newn)->osi_left);
44   			else if (no.in_addr > cur->num.in_addr)
45   				newn = &((*newn)->osi_right);
46   			else
47   				return cur;
48   		}
49   	
50   		data = calloc(1, sizeof(struct inode_info));
51   		if (!data) {
52   			log_crit( _("Unable to allocate inode_info structure\n"));
53   			return NULL;
54   		}
55   		/* Add new node and rebalance tree. */
56   		data->num = no;
57   		osi_link_node(&data->node, parent, newn);
58   		osi_insert_color(&data->node, &cx->inodetree);
59   	
60   		return data;
61   	}
62   	
63   	void inodetree_delete(struct fsck_cx *cx, struct inode_info *b)
64   	{
65   		osi_erase(&b->node, &cx->inodetree);
66   		free(b);
67   	}
68