OpenCoverage

cp-hash.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/cp-hash.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9struct Src_to_dest-
10{-
11 ino_t st_ino;-
12 dev_t st_dev;-
13-
14-
15-
16 char *name;-
17};-
18-
19-
20-
21static Hash_table *src_to_dest;-
22-
23-
24-
25-
26static size_t-
27src_to_dest_hash (void const *x, size_t table_size)-
28{-
29 struct Src_to_dest const *p = x;-
30-
31-
32-
33-
34 return
executed 60272 times by 2 tests: return (uintmax_t) p->st_ino % table_size;
Executed by:
  • cp
  • mv
(uintmax_t) p->st_ino % table_size;
executed 60272 times by 2 tests: return (uintmax_t) p->st_ino % table_size;
Executed by:
  • cp
  • mv
60272
35}-
36-
37-
38-
39static -
40 _Bool-
41-
42src_to_dest_compare (void const *x, void const *y)-
43{-
44 struct Src_to_dest const *a = x;-
45 struct Src_to_dest const *b = y;-
46 return
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ?
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
11704
47 1
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
11704
48 :
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
11704
49 0
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
11704
50 ;
executed 11704 times by 2 tests: return ((*a).st_ino == (*b).st_ino && (*a).st_dev == (*b).st_dev) ? 1 : 0 ;
Executed by:
  • cp
  • mv
11704
51}-
52-
53static void-
54src_to_dest_free (void *x)-
55{-
56 struct Src_to_dest *a = x;-
57 free (a->name);-
58 free (x);-
59}
executed 27 times by 2 tests: end of block
Executed by:
  • cp
  • mv
27
60-
61-
62-
63extern void-
64forget_created (ino_t ino, dev_t dev)-
65{-
66 struct Src_to_dest probe;-
67 struct Src_to_dest *ent;-
68-
69 probe.st_ino = ino;-
70 probe.st_dev = dev;-
71 probe.name = -
72 ((void *)0)-
73 ;-
74-
75 ent = hash_delete (src_to_dest, &probe);-
76 if (ent
entDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • mv
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • cp
  • mv
)
4-9
77 src_to_dest_free (ent);
executed 4 times by 1 test: src_to_dest_free (ent);
Executed by:
  • mv
4
78}
executed 13 times by 2 tests: end of block
Executed by:
  • cp
  • mv
13
79-
80-
81-
82-
83extern char *-
84src_to_dest_lookup (ino_t ino, dev_t dev)-
85{-
86 struct Src_to_dest ent;-
87 struct Src_to_dest const *e;-
88 ent.st_ino = ino;-
89 ent.st_dev = dev;-
90 e = hash_lookup (src_to_dest, &ent);-
91 return
executed 34481 times by 2 tests: return e ? e->name : ((void *)0) ;
Executed by:
  • cp
  • mv
e ? e->name :
executed 34481 times by 2 tests: return e ? e->name : ((void *)0) ;
Executed by:
  • cp
  • mv
34481
92 ((void *)0)
executed 34481 times by 2 tests: return e ? e->name : ((void *)0) ;
Executed by:
  • cp
  • mv
34481
93 ;
executed 34481 times by 2 tests: return e ? e->name : ((void *)0) ;
Executed by:
  • cp
  • mv
34481
94}-
95-
96-
97-
98-
99-
100extern char *-
101remember_copied (const char *name, ino_t ino, dev_t dev)-
102{-
103 struct Src_to_dest *ent;-
104 struct Src_to_dest *ent_from_table;-
105-
106 ent = xmalloc (sizeof *ent);-
107 ent->name = xstrdup (name);-
108 ent->st_ino = ino;-
109 ent->st_dev = dev;-
110-
111 ent_from_table = hash_insert (src_to_dest, ent);-
112 if (ent_from_table ==
ent_from_table == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7959 times by 2 tests
Evaluated by:
  • cp
  • mv
0-7959
113 ((void *)0)
ent_from_table == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7959 times by 2 tests
Evaluated by:
  • cp
  • mv
0-7959
114 )-
115 {-
116-
117 xalloc_die ();-
118 }
never executed: end of block
0
119-
120-
121-
122-
123 if (ent_from_table != ent
ent_from_table != entDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • cp
  • mv
FALSEevaluated 7936 times by 2 tests
Evaluated by:
  • cp
  • mv
)
23-7936
124 {-
125 src_to_dest_free (ent);-
126 return
executed 23 times by 2 tests: return (char *) ent_from_table->name;
Executed by:
  • cp
  • mv
(char *) ent_from_table->name;
executed 23 times by 2 tests: return (char *) ent_from_table->name;
Executed by:
  • cp
  • mv
23
127 }-
128-
129-
130 return
executed 7936 times by 2 tests: return ((void *)0) ;
Executed by:
  • cp
  • mv
executed 7936 times by 2 tests: return ((void *)0) ;
Executed by:
  • cp
  • mv
7936
131 ((void *)0)
executed 7936 times by 2 tests: return ((void *)0) ;
Executed by:
  • cp
  • mv
7936
132 ;
executed 7936 times by 2 tests: return ((void *)0) ;
Executed by:
  • cp
  • mv
7936
133}-
134-
135-
136extern void-
137hash_init (void)-
138{-
139 src_to_dest = hash_initialize (103, -
140 ((void *)0)-
141 ,-
142 src_to_dest_hash,-
143 src_to_dest_compare,-
144 src_to_dest_free);-
145 if (src_to_dest ==
src_to_dest == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1336 times by 3 tests
Evaluated by:
  • cp
  • ginstall
  • mv
0-1336
146 ((void *)0)
src_to_dest == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1336 times by 3 tests
Evaluated by:
  • cp
  • ginstall
  • mv
0-1336
147 )-
148 xalloc_die ();
never executed: xalloc_die ();
0
149}
executed 1336 times by 3 tests: end of block
Executed by:
  • cp
  • ginstall
  • mv
1336
150-
151-
152-
153-
154extern void-
155forget_all (void)-
156{-
157 hash_free (src_to_dest);-
158}
never executed: end of block
0
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2