OpenCoverage

libstdbuf.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/libstdbuf.c
Switch to Source codePreprocessed file
LineSourceCount
1static const char *-
2fileno_to_name (const int fd)-
3{-
4 const char *ret = -
5 ((void *)0)-
6 ;-
7-
8 switch (fd)-
9 {-
10 case
never executed: case 0:
0:
never executed: case 0:
0
11 ret = "stdin";-
12 break;
never executed: break;
0
13 case
never executed: case 1:
1:
never executed: case 1:
0
14 ret = "stdout";-
15 break;
never executed: break;
0
16 case
never executed: case 2:
2:
never executed: case 2:
0
17 ret = "stderr";-
18 break;
never executed: break;
0
19 default
never executed: default:
:
never executed: default:
0
20 ret = "unknown";-
21 break;
never executed: break;
0
22 }-
23-
24 return
never executed: return ret;
ret;
never executed: return ret;
0
25}-
26-
27static void-
28apply_mode (FILE *stream, const char *mode)-
29{-
30 char *buf = -
31 ((void *)0)-
32 ;-
33 int setvbuf_mode;-
34 size_t size = 0;-
35-
36 if (*
*mode == '0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libstdbuf.so
mode == '0'
*mode == '0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libstdbuf.so
)
4
37 setvbuf_mode =
executed 4 times by 1 test: setvbuf_mode = 2 ;
Executed by:
  • libstdbuf.so
4
38 2
executed 4 times by 1 test: setvbuf_mode = 2 ;
Executed by:
  • libstdbuf.so
4
39 ;
executed 4 times by 1 test: setvbuf_mode = 2 ;
Executed by:
  • libstdbuf.so
4
40 else if (*
*mode == 'L'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
mode == 'L'
*mode == 'L'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
)
2
41 setvbuf_mode =
executed 2 times by 1 test: setvbuf_mode = 1 ;
Executed by:
  • libstdbuf.so
2
42 1
executed 2 times by 1 test: setvbuf_mode = 1 ;
Executed by:
  • libstdbuf.so
2
43 ;
executed 2 times by 1 test: setvbuf_mode = 1 ;
Executed by:
  • libstdbuf.so
2
44 else-
45 {-
46 setvbuf_mode = -
47 0-
48 ;-
49 _Static_assert (-
50 (18446744073709551615UL) -
51 <= -
52 (0x7fffffffffffffffL * 2UL + 1UL)-
53 , "verify (" "SIZE_MAX <= ULONG_MAX" ")");-
54 size = strtoul (mode, -
55 ((void *)0)-
56 , 10);-
57 if (size > 0
size > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEnever evaluated
)
0-2
58 {-
59 if (!(buf = malloc (size))
!(buf = malloc (size))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libstdbuf.so
)
0-2
60 {-
61-
62-
63-
64 fprintf (-
65 stderr-
66 ,-
67 -
68 dcgettext (((void *)0), -
69 "failed to allocate a %" -
70 "l" "u" -
71 " byte stdio buffer\n"-
72 , 5)-
73 -
74 , (uintmax_t) size);-
75 return;
never executed: return;
0
76 }-
77 }
executed 2 times by 1 test: end of block
Executed by:
  • libstdbuf.so
2
78 else-
79 {-
80 fprintf (-
81 stderr-
82 , -
83 dcgettext (((void *)0), -
84 "invalid buffering mode %s for %s\n"-
85 , 5)-
86 ,-
87 mode, fileno_to_name (fileno (stream)));-
88 return;
never executed: return;
0
89 }-
90 }-
91-
92 if (setvbuf (stream, buf, setvbuf_mode, size) != 0
setvbuf (strea...de, size) != 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libstdbuf.so
)
0-8
93 {-
94 fprintf (-
95 stderr-
96 , -
97 dcgettext (((void *)0), -
98 "could not set buffering of %s to mode %s\n"-
99 , 5)-
100 ,-
101 fileno_to_name (fileno (stream)), mode);-
102 free (buf);-
103 }
never executed: end of block
0
104}
executed 8 times by 1 test: end of block
Executed by:
  • libstdbuf.so
8
105-
106-
107static void __attribute ((constructor))-
108stdbuf (void)-
109{-
110 char *e_mode = getenv ("_STDBUF_E");-
111 char *i_mode = getenv ("_STDBUF_I");-
112 char *o_mode = getenv ("_STDBUF_O");-
113 if (e_mode
e_modeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libstdbuf.so
)
1-5
114 apply_mode (
executed 1 time by 1 test: apply_mode ( stderr , e_mode);
Executed by:
  • libstdbuf.so
1
115 stderr
executed 1 time by 1 test: apply_mode ( stderr , e_mode);
Executed by:
  • libstdbuf.so
1
116 , e_mode);
executed 1 time by 1 test: apply_mode ( stderr , e_mode);
Executed by:
  • libstdbuf.so
1
117 if (i_mode
i_modeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libstdbuf.so
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libstdbuf.so
)
1-5
118 apply_mode (
executed 1 time by 1 test: apply_mode ( stdin , i_mode);
Executed by:
  • libstdbuf.so
1
119 stdin
executed 1 time by 1 test: apply_mode ( stdin , i_mode);
Executed by:
  • libstdbuf.so
1
120 , i_mode);
executed 1 time by 1 test: apply_mode ( stdin , i_mode);
Executed by:
  • libstdbuf.so
1
121 if (o_mode
o_modeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libstdbuf.so
FALSEnever evaluated
)
0-6
122 apply_mode (
executed 6 times by 1 test: apply_mode ( stdout , o_mode);
Executed by:
  • libstdbuf.so
6
123 stdout
executed 6 times by 1 test: apply_mode ( stdout , o_mode);
Executed by:
  • libstdbuf.so
6
124 , o_mode);
executed 6 times by 1 test: apply_mode ( stdout , o_mode);
Executed by:
  • libstdbuf.so
6
125}
executed 6 times by 1 test: end of block
Executed by:
  • libstdbuf.so
6
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2