1*6236dae4SAndroid Build Coastguard Worker<testcase> 2*6236dae4SAndroid Build Coastguard Worker<info> 3*6236dae4SAndroid Build Coastguard Worker<keywords> 4*6236dae4SAndroid Build Coastguard Workerchecksrc 5*6236dae4SAndroid Build Coastguard Worker</keywords> 6*6236dae4SAndroid Build Coastguard Worker</info> 7*6236dae4SAndroid Build Coastguard Worker 8*6236dae4SAndroid Build Coastguard Worker# 9*6236dae4SAndroid Build Coastguard Worker# Client-side 10*6236dae4SAndroid Build Coastguard Worker<client> 11*6236dae4SAndroid Build Coastguard Worker<server> 12*6236dae4SAndroid Build Coastguard Workernone 13*6236dae4SAndroid Build Coastguard Worker</server> 14*6236dae4SAndroid Build Coastguard Worker<name> 15*6236dae4SAndroid Build Coastguard Workerchecksrc 16*6236dae4SAndroid Build Coastguard Worker</name> 17*6236dae4SAndroid Build Coastguard Worker 18*6236dae4SAndroid Build Coastguard Worker<command type="perl"> 19*6236dae4SAndroid Build Coastguard Worker%SRCDIR/../scripts/checksrc.pl %LOGDIR/code%TESTNUMBER.c 20*6236dae4SAndroid Build Coastguard Worker</command> 21*6236dae4SAndroid Build Coastguard Worker<file name="%LOGDIR/code%TESTNUMBER.c"> 22*6236dae4SAndroid Build Coastguard Worker/* test source code 23*6236dae4SAndroid Build Coastguard Worker * Violate each rule at least once. 24*6236dae4SAndroid Build Coastguard Worker **/ 25*6236dae4SAndroid Build Coastguard Workerint hello; /*------------------------------------------------------------------*/ 26*6236dae4SAndroid Build Coastguard Workerint tab; 27*6236dae4SAndroid Build Coastguard Workerint trailing_space; 28*6236dae4SAndroid Build Coastguard Workerint a = func (); 29*6236dae4SAndroid Build Coastguard Workerint b = func( b); 30*6236dae4SAndroid Build Coastguard Workerint b = func(b ); 31*6236dae4SAndroid Build Coastguard Workerfunc(a, b , c); 32*6236dae4SAndroid Build Coastguard Worker 33*6236dae4SAndroid Build Coastguard Workerint hello() 34*6236dae4SAndroid Build Coastguard Worker{ 35*6236dae4SAndroid Build Coastguard Worker return(2); 36*6236dae4SAndroid Build Coastguard Worker} 37*6236dae4SAndroid Build Coastguard Workerfunc(a, b,c); 38*6236dae4SAndroid Build Coastguard Worker 39*6236dae4SAndroid Build Coastguard Workerif(a == 2) { 40*6236dae4SAndroid Build Coastguard Worker ; 41*6236dae4SAndroid Build Coastguard Worker} else { 42*6236dae4SAndroid Build Coastguard Worker moo = 2; 43*6236dae4SAndroid Build Coastguard Worker} 44*6236dae4SAndroid Build Coastguard Worker 45*6236dae4SAndroid Build Coastguard Workerif(a == 2){ /* followed by comment */ 46*6236dae4SAndroid Build Coastguard Worker ; 47*6236dae4SAndroid Build Coastguard Worker} 48*6236dae4SAndroid Build Coastguard Worker 49*6236dae4SAndroid Build Coastguard Workerfunc() ; 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard Workera = sprintf(buffer, "%s", moo); 52*6236dae4SAndroid Build Coastguard Worker 53*6236dae4SAndroid Build Coastguard WorkerFILE *f = fopen("filename", "r"); 54*6236dae4SAndroid Build Coastguard Worker 55*6236dae4SAndroid Build Coastguard Workervoid startfunc(int a, int b) { 56*6236dae4SAndroid Build Coastguard Worker func(); 57*6236dae4SAndroid Build Coastguard Worker} 58*6236dae4SAndroid Build Coastguard Worker 59*6236dae4SAndroid Build Coastguard Worker for(;;) { 60*6236dae4SAndroid Build Coastguard Worker func(1); 61*6236dae4SAndroid Build Coastguard Worker } while(1); 62*6236dae4SAndroid Build Coastguard Worker 63*6236dae4SAndroid Build Coastguard Worker char * name = "hello"; 64*6236dae4SAndroid Build Coastguard Worker char* name = "hello"; 65*6236dae4SAndroid Build Coastguard Worker 66*6236dae4SAndroid Build Coastguard Worker int foo=bar; 67*6236dae4SAndroid Build Coastguard Worker int foo= bar; 68*6236dae4SAndroid Build Coastguard Worker int foo = bar; 69*6236dae4SAndroid Build Coastguard Worker int foo = bar;foo++; 70*6236dae4SAndroid Build Coastguard Worker for(;;) { 71*6236dae4SAndroid Build Coastguard Worker } 72*6236dae4SAndroid Build Coastguard Worker 73*6236dae4SAndroid Build Coastguard Worker int a = sizeof int; 74*6236dae4SAndroid Build Coastguard Worker int a = snprintf(buffer, sizeof(buffer), "%d", 99); 75*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 76*6236dae4SAndroid Build Coastguard Worker int moo2 = wrong2:(a)>(b); 77*6236dae4SAndroid Build Coastguard Worker 78*6236dae4SAndroid Build Coastguard Worker if(a) b++; 79*6236dae4SAndroid Build Coastguard Worker 80*6236dae4SAndroid Build Coastguard Worker // CPP comment ? 81*6236dae4SAndroid Build Coastguard Worker 82*6236dae4SAndroid Build Coastguard Worker /* comment doesn't end 83*6236dae4SAndroid Build Coastguard Worker 84*6236dae4SAndroid Build Coastguard Worker</file> 85*6236dae4SAndroid Build Coastguard Worker</client> 86*6236dae4SAndroid Build Coastguard Worker 87*6236dae4SAndroid Build Coastguard Worker# 88*6236dae4SAndroid Build Coastguard Worker# Verify data after the test has been "shot" 89*6236dae4SAndroid Build Coastguard Worker<verify> 90*6236dae4SAndroid Build Coastguard Worker<stdout> 91*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:4:82: warning: Longer than 79 columns (LONGLINE) 92*6236dae4SAndroid Build Coastguard Worker int hello; /*------------------------------------------------------------------*/ 93*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:5:4: error: Contains TAB character (TABS) 94*6236dae4SAndroid Build Coastguard Worker int tab; 95*6236dae4SAndroid Build Coastguard Worker ^ 96*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:7:13: warning: func with space (SPACEBEFOREPAREN) 97*6236dae4SAndroid Build Coastguard Worker int a = func (); 98*6236dae4SAndroid Build Coastguard Worker ^ 99*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:8:14: warning: space after open parenthesis (SPACEAFTERPAREN) 100*6236dae4SAndroid Build Coastguard Worker int b = func( b); 101*6236dae4SAndroid Build Coastguard Worker ^ 102*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:9:16: warning: space before close parenthesis (SPACEBEFORECLOSE) 103*6236dae4SAndroid Build Coastguard Worker int b = func(b ); 104*6236dae4SAndroid Build Coastguard Worker ^ 105*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:10:11: warning: space before comma (SPACEBEFORECOMMA) 106*6236dae4SAndroid Build Coastguard Worker func(a, b , c); 107*6236dae4SAndroid Build Coastguard Worker ^ 108*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:14:9: warning: return without space before paren (RETURNNOSPACE) 109*6236dae4SAndroid Build Coastguard Worker return(2); 110*6236dae4SAndroid Build Coastguard Worker ^ 111*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:16:11: warning: comma without following space (COMMANOSPACE) 112*6236dae4SAndroid Build Coastguard Worker func(a, b,c); 113*6236dae4SAndroid Build Coastguard Worker ^ 114*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:18:12: warning: wrongly placed open brace (BRACEPOS) 115*6236dae4SAndroid Build Coastguard Worker if(a == 2) { 116*6236dae4SAndroid Build Coastguard Worker ^ 117*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:20:1: warning: else after closing brace on same line (BRACEELSE) 118*6236dae4SAndroid Build Coastguard Worker } else { 119*6236dae4SAndroid Build Coastguard Worker ^ 120*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:24:11: warning: missing space after close paren (PARENBRACE) 121*6236dae4SAndroid Build Coastguard Worker if(a == 2){ 122*6236dae4SAndroid Build Coastguard Worker ^ 123*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:28:7: warning: no space before semicolon (SPACESEMICOLON) 124*6236dae4SAndroid Build Coastguard Worker func() ; 125*6236dae4SAndroid Build Coastguard Worker ^ 126*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC) 127*6236dae4SAndroid Build Coastguard Worker a = sprintf(buffer, "%s", moo); 128*6236dae4SAndroid Build Coastguard Worker ^ 129*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:32:11: warning: use of non-binary fopen without FOPEN_* macro: r (FOPENMODE) 130*6236dae4SAndroid Build Coastguard Worker FILE *f = fopen("filename", "r"); 131*6236dae4SAndroid Build Coastguard Worker ^ 132*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:34:30: warning: wrongly placed open brace (BRACEPOS) 133*6236dae4SAndroid Build Coastguard Worker void startfunc(int a, int b) { 134*6236dae4SAndroid Build Coastguard Worker ^ 135*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:39:6: warning: not indented 2 steps (uses 4) (INDENTATION) 136*6236dae4SAndroid Build Coastguard Worker func(1); 137*6236dae4SAndroid Build Coastguard Worker ^ 138*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:42:8: warning: space after declarative asterisk (ASTERISKSPACE) 139*6236dae4SAndroid Build Coastguard Worker char * name = "hello"; 140*6236dae4SAndroid Build Coastguard Worker ^ 141*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:43:7: warning: space after declarative asterisk (ASTERISKSPACE) 142*6236dae4SAndroid Build Coastguard Worker char* name = "hello"; 143*6236dae4SAndroid Build Coastguard Worker ^ 144*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:43:6: warning: no space before asterisk (ASTERISKNOSPACE) 145*6236dae4SAndroid Build Coastguard Worker char* name = "hello"; 146*6236dae4SAndroid Build Coastguard Worker ^ 147*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:45:10: warning: no space after equals sign (EQUALSNOSPACE) 148*6236dae4SAndroid Build Coastguard Worker int foo=bar; 149*6236dae4SAndroid Build Coastguard Worker ^ 150*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:46:9: warning: no space before equals sign (NOSPACEEQUALS) 151*6236dae4SAndroid Build Coastguard Worker int foo= bar; 152*6236dae4SAndroid Build Coastguard Worker ^ 153*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:48:16: warning: no space after semicolon (SEMINOSPACE) 154*6236dae4SAndroid Build Coastguard Worker int foo = bar;foo++; 155*6236dae4SAndroid Build Coastguard Worker ^ 156*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:49:10: warning: multiple spaces (MULTISPACE) 157*6236dae4SAndroid Build Coastguard Worker for(;;) { 158*6236dae4SAndroid Build Coastguard Worker ^ 159*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:50:2: warning: not indented 2 steps (uses 0) (INDENTATION) 160*6236dae4SAndroid Build Coastguard Worker } 161*6236dae4SAndroid Build Coastguard Worker ^ 162*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:52:16: warning: sizeof without parenthesis (SIZEOFNOPAREN) 163*6236dae4SAndroid Build Coastguard Worker int a = sizeof int; 164*6236dae4SAndroid Build Coastguard Worker ^ 165*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:53:10: warning: use of snprintf is banned (SNPRINTF) 166*6236dae4SAndroid Build Coastguard Worker int a = snprintf(buffer, sizeof(buffer), "%d", 99); 167*6236dae4SAndroid Build Coastguard Worker ^ 168*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:21: warning: missing space before colon (NOSPACEC) 169*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 170*6236dae4SAndroid Build Coastguard Worker ^ 171*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:22: warning: missing space after colon (NOSPACEC) 172*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 173*6236dae4SAndroid Build Coastguard Worker ^ 174*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:15: warning: missing space before question mark (NOSPACEQ) 175*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 176*6236dae4SAndroid Build Coastguard Worker ^ 177*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:16: warning: missing space after question mark (NOSPACEQ) 178*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 179*6236dae4SAndroid Build Coastguard Worker ^ 180*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:23: warning: missing space before less or greater than (NOSPACETHAN) 181*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 182*6236dae4SAndroid Build Coastguard Worker ^ 183*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:54:23: warning: missing space after less or greater than (NOSPACETHAN) 184*6236dae4SAndroid Build Coastguard Worker int moo = hej?wrong:a>b; 185*6236dae4SAndroid Build Coastguard Worker ^ 186*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:55:23: warning: missing space before less or greater than (NOSPACETHAN) 187*6236dae4SAndroid Build Coastguard Worker int moo2 = wrong2:(a)>(b); 188*6236dae4SAndroid Build Coastguard Worker ^ 189*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:55:23: warning: missing space after less or greater than (NOSPACETHAN) 190*6236dae4SAndroid Build Coastguard Worker int moo2 = wrong2:(a)>(b); 191*6236dae4SAndroid Build Coastguard Worker ^ 192*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:57:7: warning: conditional block on the same line (ONELINECONDITION) 193*6236dae4SAndroid Build Coastguard Worker if(a) b++; 194*6236dae4SAndroid Build Coastguard Worker ^ 195*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:59:2: warning: // comment (CPPCOMMENTS) 196*6236dae4SAndroid Build Coastguard Worker // CPP comment ? 197*6236dae4SAndroid Build Coastguard Worker ^ 198*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT) 199*6236dae4SAndroid Build Coastguard Worker 200*6236dae4SAndroid Build Coastguard Worker ^ 201*6236dae4SAndroid Build Coastguard Worker./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT) 202*6236dae4SAndroid Build Coastguard Worker 203*6236dae4SAndroid Build Coastguard Worker ^ 204*6236dae4SAndroid Build Coastguard Workerchecksrc: 0 errors and 38 warnings 205*6236dae4SAndroid Build Coastguard Worker</stdout> 206*6236dae4SAndroid Build Coastguard Worker<errorcode> 207*6236dae4SAndroid Build Coastguard Worker5 208*6236dae4SAndroid Build Coastguard Worker</errorcode> 209*6236dae4SAndroid Build Coastguard Worker</verify> 210*6236dae4SAndroid Build Coastguard Worker</testcase> 211