OpenCoverage

nproc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/nproc.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8enum-
9{-
10 ALL_OPTION = 0x7f + 1,-
11 IGNORE_OPTION-
12};-
13-
14static struct option const longopts[] =-
15{-
16 {"all", -
17 0-
18 , -
19 ((void *)0)-
20 , ALL_OPTION},-
21 {"ignore", -
22 1-
23 , -
24 ((void *)0)-
25 , IGNORE_OPTION},-
26 {"help", -
27 0-
28 , -
29 ((void *)0)-
30 , GETOPT_HELP_CHAR},-
31 {"version", -
32 0-
33 , -
34 ((void *)0)-
35 , GETOPT_VERSION_CHAR},-
36 {-
37 ((void *)0)-
38 , 0, -
39 ((void *)0)-
40 , 0}-
41};-
42-
43void-
44usage (int status)-
45{-
46 if (status !=
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • nproc
FALSEevaluated 4 times by 1 test
Evaluated by:
  • nproc
3-4
47 0
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • nproc
FALSEevaluated 4 times by 1 test
Evaluated by:
  • nproc
3-4
48 )-
49 do { fprintf (-
50 stderr-
51 , -
52 dcgettext (((void *)0), -
53 "Try '%s --help' for more information.\n"-
54 , 5)-
55 , program_name); }
executed 3 times by 1 test: end of block
Executed by:
  • nproc
while (0);
3
56 else-
57 {-
58 printf (-
59 dcgettext (((void *)0), -
60 "Usage: %s [OPTION]...\n"-
61 , 5)-
62 , program_name);-
63 fputs_unlocked (-
64 dcgettext (((void *)0), -
65 "Print the number of processing units available to the current process,\nwhich may be less than the number of online processors\n\n"-
66 , 5)-
67 ,-
68 stdout-
69 )-
70-
71-
72-
73 ;-
74 fputs_unlocked (-
75 dcgettext (((void *)0), -
76 " --all print the number of installed processors\n --ignore=N if possible, exclude N processing units\n"-
77 , 5)-
78 ,-
79 stdout-
80 )-
81-
82-
83 ;-
84-
85 fputs_unlocked (-
86 dcgettext (((void *)0), -
87 " --help display this help and exit\n"-
88 , 5)-
89 ,-
90 stdout-
91 );-
92 fputs_unlocked (-
93 dcgettext (((void *)0), -
94 " --version output version information and exit\n"-
95 , 5)-
96 ,-
97 stdout-
98 );-
99 emit_ancillary_info ("nproc");-
100 }
executed 4 times by 1 test: end of block
Executed by:
  • nproc
4
101 exit (status);
executed 7 times by 1 test: exit (status);
Executed by:
  • nproc
7
102}-
103-
104int-
105main (int argc, char **argv)-
106{-
107 unsigned long nproc, ignore = 0;-
108 ;-
109 set_program_name (argv[0]);-
110 setlocale (-
111 6-
112 , "");-
113 bindtextdomain ("coreutils", "/usr/local/share/locale");-
114 textdomain ("coreutils");-
115-
116 atexit (close_stdout);-
117-
118 enum nproc_query mode = NPROC_CURRENT_OVERRIDABLE;-
119-
120 while (1)-
121 {-
122 int c = getopt_long (argc, argv, "", longopts, -
123 ((void *)0)-
124 );-
125 if (c == -1
c == -1Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • nproc
FALSEevaluated 23 times by 1 test
Evaluated by:
  • nproc
)
23-30
126 break;
executed 30 times by 1 test: break;
Executed by:
  • nproc
30
127 switch (c)-
128 {-
129 case
executed 4 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • nproc
GETOPT_HELP_CHAR:
executed 4 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • nproc
usage (
4
130 0-
131 ); break;
never executed: break;
;
0
132-
133 case
executed 6 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • nproc
GETOPT_VERSION_CHAR:
executed 6 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • nproc
version_etc (
6
134 stdout-
135 , "nproc", "GNU coreutils", Version, ("Giuseppe Scrivano"), (char *) -
136 ((void *)0)-
137 ); exit (
executed 6 times by 1 test: exit ( 0 );
Executed by:
  • nproc
6
138 0
executed 6 times by 1 test: exit ( 0 );
Executed by:
  • nproc
6
139 );
executed 6 times by 1 test: exit ( 0 );
Executed by:
  • nproc
break;
never executed: break;
;
0-6
140-
141 case
executed 3 times by 1 test: case ALL_OPTION:
Executed by:
  • nproc
ALL_OPTION:
executed 3 times by 1 test: case ALL_OPTION:
Executed by:
  • nproc
3
142 mode = NPROC_ALL;-
143 break;
executed 3 times by 1 test: break;
Executed by:
  • nproc
3
144-
145 case
executed 7 times by 1 test: case IGNORE_OPTION:
Executed by:
  • nproc
IGNORE_OPTION:
executed 7 times by 1 test: case IGNORE_OPTION:
Executed by:
  • nproc
7
146 ignore = xdectoumax (optarg, 0, -
147 (0x7fffffffffffffffL * 2UL + 1UL)-
148 , "", -
149 dcgettext (((void *)0), -
150 "invalid number"-
151 , 5)-
152 ,0);-
153 break;
executed 4 times by 1 test: break;
Executed by:
  • nproc
4
154-
155 default
executed 3 times by 1 test: default:
Executed by:
  • nproc
:
executed 3 times by 1 test: default:
Executed by:
  • nproc
3
156 usage (-
157 1-
158 );-
159 }
never executed: end of block
0
160 }-
161-
162 if (argc != optind
argc != optindDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • nproc
)
0-30
163 {-
164 error (0, 0, -
165 dcgettext (((void *)0), -
166 "extra operand %s"-
167 , 5)-
168 , quote (argv[optind]));-
169 usage (-
170 1-
171 );-
172 }
never executed: end of block
0
173-
174 nproc = num_processors (mode);-
175-
176 if (ignore < nproc
ignore < nprocDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • nproc
FALSEevaluated 1 time by 1 test
Evaluated by:
  • nproc
)
1-29
177 nproc -= ignore;
executed 29 times by 1 test: nproc -= ignore;
Executed by:
  • nproc
29
178 else-
179 nproc = 1;
executed 1 time by 1 test: nproc = 1;
Executed by:
  • nproc
1
180-
181 printf ("%lu\n", nproc);-
182-
183 return
executed 30 times by 1 test: return 0 ;
Executed by:
  • nproc
executed 30 times by 1 test: return 0 ;
Executed by:
  • nproc
30
184 0
executed 30 times by 1 test: return 0 ;
Executed by:
  • nproc
30
185 ;
executed 30 times by 1 test: return 0 ;
Executed by:
  • nproc
30
186}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2