[PATCH t/op/taint.t] remove possible false positive
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / pp_sys
CommitLineData
599cee73 1 pp_sys.c AOK
2
767a6a26 3 untie attempted while %d inner references still exist [pp_untie]
599cee73 4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
c289d2f7 6 fileno() on unopened filehandle abc [pp_fileno]
7 $a = "abc"; fileno($a)
8
9 binmode() on unopened filehandle abc [pp_binmode]
10 $a = "abc"; fileno($a)
11
12 printf() on unopened filehandle abc [pp_prtf]
13 $a = "abc"; printf $a "fred"
14
767a6a26 15 Filehandle %s opened only for input [pp_leavewrite]
599cee73 16 format STDIN =
17 .
18 write STDIN;
19
9a7dcd9c 20 write() on closed filehandle %s [pp_leavewrite]
599cee73 21 format STDIN =
22 .
23 close STDIN;
24 write STDIN ;
25
767a6a26 26 page overflow [pp_leavewrite]
599cee73 27
2dd78f96 28 printf() on unopened filehandle abc [pp_prtf]
599cee73 29 $a = "abc"; printf $a "fred"
30
767a6a26 31 Filehandle %s opened only for input [pp_prtf]
599cee73 32 $a = "abc";
33 printf $a "fred"
34
9a7dcd9c 35 printf() on closed filehandle %s [pp_prtf]
599cee73 36 close STDIN ;
37 printf STDIN "fred"
38
69282e91 39 syswrite() on closed filehandle %s [pp_send]
599cee73 40 close STDIN;
41 syswrite STDIN, "fred", 1;
42
69282e91 43 send() on closed socket %s [pp_send]
599cee73 44 close STDIN;
45 send STDIN, "fred", 1
46
69282e91 47 bind() on closed socket %s [pp_bind]
599cee73 48 close STDIN;
49 bind STDIN, "fred" ;
50
51
69282e91 52 connect() on closed socket %s [pp_connect]
599cee73 53 close STDIN;
54 connect STDIN, "fred" ;
55
69282e91 56 listen() on closed socket %s [pp_listen]
599cee73 57 close STDIN;
58 listen STDIN, 2;
59
69282e91 60 accept() on closed socket %s [pp_accept]
599cee73 61 close STDIN;
69282e91 62 accept "fred", STDIN ;
599cee73 63
69282e91 64 shutdown() on closed socket %s [pp_shutdown]
599cee73 65 close STDIN;
66 shutdown STDIN, 0;
67
69282e91 68 setsockopt() on closed socket %s [pp_ssockopt]
69 getsockopt() on closed socket %s [pp_ssockopt]
599cee73 70 close STDIN;
71 setsockopt STDIN, 1,2,3;
72 getsockopt STDIN, 1,2;
73
69282e91 74 getsockname() on closed socket %s [pp_getpeername]
75 getpeername() on closed socket %s [pp_getpeername]
599cee73 76 close STDIN;
77 getsockname STDIN;
78 getpeername STDIN;
79
69282e91 80 flock() on closed socket %s [pp_flock]
bc37a18f 81 flock() on closed socket [pp_flock]
69282e91 82 close STDIN;
83 flock STDIN, 8;
bc37a18f 84 flock $a, 8;
69282e91 85
767a6a26 86 warn(warn_nl, "stat"); [pp_stat]
599cee73 87
2dd78f96 88 -T on closed filehandle %s
89 stat() on closed filehandle %s
90 close STDIN ; -T STDIN ; stat(STDIN) ;
599cee73 91
767a6a26 92 warn(warn_nl, "open"); [pp_fttext]
599cee73 93 -T "abc\ndef" ;
94
767a6a26 95 Filehandle %s opened only for output [pp_sysread]
96 my $file = "./xcv" ;
97 open(F, ">$file") ;
98 my $a = sysread(F, $a,10) ;
99
599cee73 100
101
102__END__
767a6a26 103# pp_sys.c [pp_untie]
4438c4b7 104use warnings 'untie' ;
599cee73 105sub TIESCALAR { bless [] } ;
106$b = tie $a, 'main';
107untie $a ;
4438c4b7 108no warnings 'untie' ;
0453d815 109$c = tie $d, 'main';
110untie $d ;
599cee73 111EXPECT
112untie attempted while 1 inner references still exist at - line 5.
113########
767a6a26 114# pp_sys.c [pp_leavewrite]
4438c4b7 115use warnings 'io' ;
599cee73 116format STDIN =
117.
118write STDIN;
4438c4b7 119no warnings 'io' ;
0453d815 120write STDIN;
599cee73 121EXPECT
43693395 122Filehandle STDIN opened only for input at - line 5.
599cee73 123########
767a6a26 124# pp_sys.c [pp_leavewrite]
4438c4b7 125use warnings 'closed' ;
599cee73 126format STDIN =
127.
128close STDIN;
129write STDIN;
69282e91 130opendir STDIN, ".";
131write STDIN;
132closedir STDIN;
4438c4b7 133no warnings 'closed' ;
0453d815 134write STDIN;
69282e91 135opendir STDIN, ".";
136write STDIN;
599cee73 137EXPECT
43693395 138write() on closed filehandle STDIN at - line 6.
139write() on closed filehandle STDIN at - line 8.
140 (Are you trying to call write() on dirhandle STDIN?)
599cee73 141########
767a6a26 142# pp_sys.c [pp_leavewrite]
4438c4b7 143use warnings 'io' ;
599cee73 144format STDOUT_TOP =
145abc
146.
147format STDOUT =
148def
149ghi
150.
151$= = 1 ;
152$- =1 ;
3eeba6fb 153open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 154write ;
4438c4b7 155no warnings 'io' ;
0453d815 156write ;
599cee73 157EXPECT
158page overflow at - line 13.
159########
767a6a26 160# pp_sys.c [pp_prtf]
4438c4b7 161use warnings 'unopened' ;
599cee73 162$a = "abc";
0453d815 163printf $a "fred";
4438c4b7 164no warnings 'unopened' ;
0453d815 165printf $a "fred";
599cee73 166EXPECT
2dd78f96 167printf() on unopened filehandle abc at - line 4.
599cee73 168########
767a6a26 169# pp_sys.c [pp_prtf]
4438c4b7 170use warnings 'closed' ;
599cee73 171close STDIN ;
0453d815 172printf STDIN "fred";
69282e91 173opendir STDIN, ".";
174printf STDIN "fred";
175closedir STDIN;
4438c4b7 176no warnings 'closed' ;
0453d815 177printf STDIN "fred";
69282e91 178opendir STDIN, ".";
179printf STDIN "fred";
599cee73 180EXPECT
43693395 181printf() on closed filehandle STDIN at - line 4.
182printf() on closed filehandle STDIN at - line 6.
183 (Are you trying to call printf() on dirhandle STDIN?)
599cee73 184########
767a6a26 185# pp_sys.c [pp_prtf]
4438c4b7 186use warnings 'io' ;
0453d815 187printf STDIN "fred";
4438c4b7 188no warnings 'io' ;
0453d815 189printf STDIN "fred";
599cee73 190EXPECT
43693395 191Filehandle STDIN opened only for input at - line 3.
599cee73 192########
767a6a26 193# pp_sys.c [pp_send]
4438c4b7 194use warnings 'closed' ;
599cee73 195close STDIN;
196syswrite STDIN, "fred", 1;
69282e91 197opendir STDIN, ".";
198syswrite STDIN, "fred", 1;
199closedir STDIN;
4438c4b7 200no warnings 'closed' ;
0453d815 201syswrite STDIN, "fred", 1;
69282e91 202opendir STDIN, ".";
203syswrite STDIN, "fred", 1;
599cee73 204EXPECT
43693395 205syswrite() on closed filehandle STDIN at - line 4.
206syswrite() on closed filehandle STDIN at - line 6.
207 (Are you trying to call syswrite() on dirhandle STDIN?)
69282e91 208########
209# pp_sys.c [pp_flock]
f0963acb 210use Config;
211BEGIN {
9bdf8ebc 212 if ( !$Config{d_flock} &&
213 !$Config{d_fcntl_can_lock} &&
214 !$Config{d_lockf} ) {
f0963acb 215 print <<EOM ;
216SKIPPED
217# flock not present
218EOM
219 exit ;
220 }
221}
bc37a18f 222use warnings qw(unopened closed);
69282e91 223close STDIN;
224flock STDIN, 8;
225opendir STDIN, ".";
226flock STDIN, 8;
bc37a18f 227flock FOO, 8;
228flock $a, 8;
229no warnings qw(unopened closed);
69282e91 230flock STDIN, 8;
231opendir STDIN, ".";
232flock STDIN, 8;
bc37a18f 233flock FOO, 8;
234flock $a, 8;
69282e91 235EXPECT
43693395 236flock() on closed filehandle STDIN at - line 16.
c934501c 237flock() on closed filehandle STDIN at - line 18.
43693395 238 (Are you trying to call flock() on dirhandle STDIN?)
c934501c 239flock() on unopened filehandle FOO at - line 19.
240flock() on unopened filehandle at - line 20.
599cee73 241########
767a6a26 242# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
4438c4b7 243use warnings 'io' ;
599cee73 244use Config;
245BEGIN {
246 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
247 print <<EOM ;
248SKIPPED
249# send not present
250# bind not present
251# connect not present
252# accept not present
253# shutdown not present
254# setsockopt not present
255# getsockopt not present
256# getsockname not present
257# getpeername not present
258EOM
259 exit ;
260 }
261}
262close STDIN;
263send STDIN, "fred", 1;
264bind STDIN, "fred" ;
265connect STDIN, "fred" ;
266listen STDIN, 2;
69282e91 267accept "fred", STDIN;
268shutdown STDIN, 0;
269setsockopt STDIN, 1,2,3;
270getsockopt STDIN, 1,2;
271getsockname STDIN;
272getpeername STDIN;
273opendir STDIN, ".";
274send STDIN, "fred", 1;
275bind STDIN, "fred" ;
276connect STDIN, "fred" ;
277listen STDIN, 2;
278accept "fred", STDIN;
599cee73 279shutdown STDIN, 0;
280setsockopt STDIN, 1,2,3;
281getsockopt STDIN, 1,2;
282getsockname STDIN;
283getpeername STDIN;
69282e91 284closedir STDIN;
4438c4b7 285no warnings 'io' ;
0453d815 286send STDIN, "fred", 1;
287bind STDIN, "fred" ;
288connect STDIN, "fred" ;
289listen STDIN, 2;
290accept STDIN, "fred" ;
291shutdown STDIN, 0;
292setsockopt STDIN, 1,2,3;
293getsockopt STDIN, 1,2;
294getsockname STDIN;
295getpeername STDIN;
69282e91 296opendir STDIN, ".";
297send STDIN, "fred", 1;
298bind STDIN, "fred" ;
299connect STDIN, "fred" ;
300listen STDIN, 2;
301accept "fred", STDIN;
302shutdown STDIN, 0;
303setsockopt STDIN, 1,2,3;
304getsockopt STDIN, 1,2;
305getsockname STDIN;
306getpeername STDIN;
599cee73 307EXPECT
43693395 308send() on closed socket STDIN at - line 22.
309bind() on closed socket STDIN at - line 23.
310connect() on closed socket STDIN at - line 24.
311listen() on closed socket STDIN at - line 25.
312accept() on closed socket STDIN at - line 26.
313shutdown() on closed socket STDIN at - line 27.
314setsockopt() on closed socket STDIN at - line 28.
315getsockopt() on closed socket STDIN at - line 29.
316getsockname() on closed socket STDIN at - line 30.
317getpeername() on closed socket STDIN at - line 31.
318send() on closed socket STDIN at - line 33.
319 (Are you trying to call send() on dirhandle STDIN?)
320bind() on closed socket STDIN at - line 34.
321 (Are you trying to call bind() on dirhandle STDIN?)
322connect() on closed socket STDIN at - line 35.
323 (Are you trying to call connect() on dirhandle STDIN?)
324listen() on closed socket STDIN at - line 36.
325 (Are you trying to call listen() on dirhandle STDIN?)
326accept() on closed socket STDIN at - line 37.
327 (Are you trying to call accept() on dirhandle STDIN?)
328shutdown() on closed socket STDIN at - line 38.
329 (Are you trying to call shutdown() on dirhandle STDIN?)
330setsockopt() on closed socket STDIN at - line 39.
331 (Are you trying to call setsockopt() on dirhandle STDIN?)
332getsockopt() on closed socket STDIN at - line 40.
333 (Are you trying to call getsockopt() on dirhandle STDIN?)
334getsockname() on closed socket STDIN at - line 41.
335 (Are you trying to call getsockname() on dirhandle STDIN?)
336getpeername() on closed socket STDIN at - line 42.
337 (Are you trying to call getpeername() on dirhandle STDIN?)
599cee73 338########
767a6a26 339# pp_sys.c [pp_stat]
4438c4b7 340use warnings 'newline' ;
599cee73 341stat "abc\ndef";
4438c4b7 342no warnings 'newline' ;
0453d815 343stat "abc\ndef";
599cee73 344EXPECT
345Unsuccessful stat on filename containing newline at - line 3.
346########
767a6a26 347# pp_sys.c [pp_fttext]
2dd78f96 348use warnings qw(unopened closed) ;
599cee73 349close STDIN ;
350-T STDIN ;
9ddeeac9 351stat(STDIN) ;
2dd78f96 352-T HOCUS;
353stat(POCUS);
354no warnings qw(unopened closed) ;
0453d815 355-T STDIN ;
9ddeeac9 356stat(STDIN);
2dd78f96 357-T HOCUS;
358stat(POCUS);
599cee73 359EXPECT
2dd78f96 360-T on closed filehandle STDIN at - line 4.
361stat() on closed filehandle STDIN at - line 5.
362-T on unopened filehandle HOCUS at - line 6.
363stat() on unopened filehandle POCUS at - line 7.
599cee73 364########
767a6a26 365# pp_sys.c [pp_fttext]
4438c4b7 366use warnings 'newline' ;
599cee73 367-T "abc\ndef" ;
4438c4b7 368no warnings 'newline' ;
0453d815 369-T "abc\ndef" ;
599cee73 370EXPECT
371Unsuccessful open on filename containing newline at - line 3.
767a6a26 372########
373# pp_sys.c [pp_sysread]
374use warnings 'io' ;
6bbf1b34 375if ($^O eq 'dos') {
376 print <<EOM ;
377SKIPPED
378# skipped on dos
379EOM
380 exit ;
381}
767a6a26 382my $file = "./xcv" ;
383open(F, ">$file") ;
384my $a = sysread(F, $a,10) ;
385no warnings 'io' ;
386my $a = sysread(F, $a,10) ;
387close F ;
388unlink $file ;
389EXPECT
c6f2523f 390Filehandle F opened only for output at - line 12.
c289d2f7 391########
392# pp_sys.c [pp_binmode]
393use warnings 'unopened' ;
394binmode(BLARG);
395$a = "BLERG";binmode($a);
396EXPECT
397binmode() on unopened filehandle BLARG at - line 3.
398binmode() on unopened filehandle at - line 4.