blob: 3b78131d07d2f8c0a774c3fb9ba52a1d159f393f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* Tests an uninitialised variable bug.
t is not initialised in all paths in the do loop, causing the while
conditional to fail unpredictably.
Doesn't actually test, is really an example.
*/
#include <testfwk.h>
typedef unsigned char UBYTE;
UBYTE
randish(void)
{
static int count;
if ((++count)&3) {
return 1;
}
else {
return 0;
}
}
void
spoil(UBYTE ignored)
{
UNUSED(ignored);
}
UBYTE accu[2];
#if !defined(PORT_HOST)
# pragma disable_warning 84
#endif
void
testLoopInit(void)
{
UBYTE t, r;
do {
r = randish();
if(r != 1) {
t = ++accu[r];
spoil(t);
}
}
while(t != 3);
}
|