OpenCoverage

force-link.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/force-link.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static char const simple_pattern[] = "CuXXXXXX";-
10enum { x_suffix_len = sizeof "XXXXXX" - 1 };-
11-
12-
13-
14-
15enum { smallsize = 256 };-
16-
17-
18-
19-
20-
21static char *-
22samedir_template (char const *dstname, char buf[smallsize])-
23{-
24 ptrdiff_t dstdirlen = last_component (dstname) - dstname;-
25 size_t dsttmpsize = dstdirlen + sizeof simple_pattern;-
26 char *dsttmp;-
27 if (dsttmpsize <= smallsize
dsttmpsize <= smallsizeDescription
TRUEevaluated 30 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
FALSEnever evaluated
)
0-30
28 dsttmp = buf;
executed 30 times by 3 tests: dsttmp = buf;
Executed by:
  • cp
  • ln
  • mv
30
29 else-
30 {-
31 dsttmp = malloc (dsttmpsize);-
32 if (!dsttmp
!dsttmpDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
33 return
never executed: return dsttmp;
dsttmp;
never executed: return dsttmp;
0
34 }
never executed: end of block
0
35 strcpy (mempcpy (dsttmp, dstname, dstdirlen), simple_pattern);-
36 return
executed 30 times by 3 tests: return dsttmp;
Executed by:
  • cp
  • ln
  • mv
dsttmp;
executed 30 times by 3 tests: return dsttmp;
Executed by:
  • cp
  • ln
  • mv
30
37}-
38-
39-
40-
41-
42struct link_arg-
43{-
44 int srcdir;-
45 char const *srcname;-
46 int dstdir;-
47 int flags;-
48};-
49-
50static int-
51try_link (char *dest, void *arg)-
52{-
53 struct link_arg *a = arg;-
54 return
executed 19 times by 3 tests: return linkat (a->srcdir, a->srcname, a->dstdir, dest, a->flags);
Executed by:
  • cp
  • ln
  • mv
linkat (a->srcdir, a->srcname, a->dstdir, dest, a->flags);
executed 19 times by 3 tests: return linkat (a->srcdir, a->srcname, a->dstdir, dest, a->flags);
Executed by:
  • cp
  • ln
  • mv
19
55}-
56-
57-
58-
59-
60-
61-
62-
63extern int-
64force_linkat (int srcdir, char const *srcname,-
65 int dstdir, char const *dstname, int flags, -
66 _Bool -
67 force)-
68{-
69 int r = linkat (srcdir, srcname, dstdir, dstname, flags);-
70 if (!force
!forceDescription
TRUEevaluated 30103 times by 2 tests
Evaluated by:
  • cp
  • ln
FALSEevaluated 37 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
|| r == 0
r == 0Description
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
||
18-30103
71 (*
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
__errno_location ())
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
0-19
72 !=
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
0-19
73 17
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
0-19
74 )-
75 return
executed 30121 times by 3 tests: return r;
Executed by:
  • cp
  • ln
  • mv
r;
executed 30121 times by 3 tests: return r;
Executed by:
  • cp
  • ln
  • mv
30121
76-
77 char buf[smallsize];-
78 char *dsttmp = samedir_template (dstname, buf);-
79 if (! dsttmp
! dsttmpDescription
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
)
0-19
80 return
never executed: return -1;
-1;
never executed: return -1;
0
81 struct link_arg arg = { srcdir, srcname, dstdir, flags };-
82 int err;-
83-
84 if (try_tempname_len (dsttmp, 0, &arg, try_link, x_suffix_len) != 0
try_tempname_l...ffix_len) != 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • cp
FALSEevaluated 18 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
)
1-18
85 err =
executed 1 time by 1 test: err = (*__errno_location ()) ;
Executed by:
  • cp
1
86 (*__errno_location ())
executed 1 time by 1 test: err = (*__errno_location ()) ;
Executed by:
  • cp
1
87 ;
executed 1 time by 1 test: err = (*__errno_location ()) ;
Executed by:
  • cp
1
88 else-
89 {-
90 err = renameat (dstdir, dsttmp, dstdir, dstname) == 0
renameat (dstd... dstname) == 0Description
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
FALSEnever evaluated
? 0 :
0-18
91 (*__errno_location ())-
92 ;-
93-
94-
95-
96 unlinkat (dstdir, dsttmp, 0);-
97 }
executed 18 times by 3 tests: end of block
Executed by:
  • cp
  • ln
  • mv
18
98-
99 if (dsttmp != buf
dsttmp != bufDescription
TRUEnever evaluated
FALSEevaluated 19 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
)
0-19
100 free (dsttmp);
never executed: free (dsttmp);
0
101 if (!err
!errDescription
TRUEevaluated 18 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
FALSEevaluated 1 time by 1 test
Evaluated by:
  • cp
)
1-18
102 return
executed 18 times by 3 tests: return 1;
Executed by:
  • cp
  • ln
  • mv
1;
executed 18 times by 3 tests: return 1;
Executed by:
  • cp
  • ln
  • mv
18
103 -
104 (*__errno_location ()) -
105 = err;-
106 return
executed 1 time by 1 test: return -1;
Executed by:
  • cp
-1;
executed 1 time by 1 test: return -1;
Executed by:
  • cp
1
107}-
108-
109-
110-
111-
112struct symlink_arg-
113{-
114 char const *srcname;-
115 int dstdir;-
116};-
117-
118static int-
119try_symlink (char *dest, void *arg)-
120{-
121 struct symlink_arg *a = arg;-
122 return
executed 11 times by 2 tests: return symlinkat (a->srcname, a->dstdir, dest);
Executed by:
  • cp
  • ln
symlinkat (a->srcname, a->dstdir, dest);
executed 11 times by 2 tests: return symlinkat (a->srcname, a->dstdir, dest);
Executed by:
  • cp
  • ln
11
123}-
124-
125-
126-
127-
128-
129-
130extern int-
131force_symlinkat (char const *srcname, int dstdir, char const *dstname,-
132 -
133 _Bool -
134 force)-
135{-
136 int r = symlinkat (srcname, dstdir, dstname);-
137 if (!force
!forceDescription
TRUEevaluated 651 times by 3 tests
Evaluated by:
  • cp
  • ln
  • mv
FALSEevaluated 57 times by 2 tests
Evaluated by:
  • cp
  • ln
|| r == 0
r == 0Description
TRUEevaluated 46 times by 2 tests
Evaluated by:
  • cp
  • ln
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
||
11-651
138 (*
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
__errno_location ())
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
0-11
139 !=
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
0-11
140 17
(*__errno_location ()) != 17Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
0-11
141 )-
142 return
executed 697 times by 3 tests: return r;
Executed by:
  • cp
  • ln
  • mv
r;
executed 697 times by 3 tests: return r;
Executed by:
  • cp
  • ln
  • mv
697
143-
144 char buf[smallsize];-
145 char *dsttmp = samedir_template (dstname, buf);-
146 if (!dsttmp
!dsttmpDescription
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
)
0-11
147 return
never executed: return -1;
-1;
never executed: return -1;
0
148 struct symlink_arg arg = { srcname, dstdir };-
149 int err;-
150-
151 if (try_tempname_len (dsttmp, 0, &arg, try_symlink, x_suffix_len) != 0
try_tempname_l...ffix_len) != 0Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
)
0-11
152 err =
never executed: err = (*__errno_location ()) ;
0
153 (*__errno_location ())
never executed: err = (*__errno_location ()) ;
0
154 ;
never executed: err = (*__errno_location ()) ;
0
155 else if (renameat (dstdir, dsttmp, dstdir, dstname) != 0
renameat (dstd... dstname) != 0Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
)
0-11
156 {-
157 err = -
158 (*__errno_location ())-
159 ;-
160 unlinkat (dstdir, dsttmp, 0);-
161 }
never executed: end of block
0
162 else-
163 {-
164-
165-
166 err = 0;-
167 }
executed 11 times by 2 tests: end of block
Executed by:
  • cp
  • ln
11
168-
169 if (dsttmp != buf
dsttmp != bufDescription
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
)
0-11
170 free (dsttmp);
never executed: free (dsttmp);
0
171 if (!err
!errDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • cp
  • ln
FALSEnever evaluated
)
0-11
172 return
executed 11 times by 2 tests: return 1;
Executed by:
  • cp
  • ln
1;
executed 11 times by 2 tests: return 1;
Executed by:
  • cp
  • ln
11
173 -
174 (*__errno_location ()) -
175 = err;-
176 return
never executed: return -1;
-1;
never executed: return -1;
0
177}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2