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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
checksrc
</keywords>
</info>
# Client-side
<client>
<name>
checksrc
</name>
<command type="perl">
%SRCDIR/../scripts/checksrc.pl -bmagicbad -balsobad %LOGDIR/code%TESTNUMBER.c
</command>
<file name="%LOGDIR/code%TESTNUMBER.c">
/* test source code
* Violate each rule at least once.
**/
int hello; /*------------------------------------------------------------------*/
int%TABtab;
int trailing_space;
int a = func ();
int b = func( b);
int b = func(b );
func(a, b , c);
int hello()
{
return(2);
}
func(a, b,c);
if(a == 2) {
;
} else {
moo = 2;
}
if(a == 2){ /* followed by comment */
;
}
func_return() ;
a = sprintf(buffer, "%s", moo);
FILE *f = curlx_fopen("filename", "r");
void startfunc(int a, int b) {
func();
}
for(;;) {
func(1);
} while(1);
char * name = "hello";
char* name = "hello";
int foo=bar;
int foo= bar;
int foo = bar;
int foo = bar;foo++;
for(;;) {
moo();
moo();
}
int a = sizeof int;
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
int moo = hej?wrong:a>b;
int moo2 = wrong2:(a)>(b);
if(a) b++;
if(sprintf(buffer, "%s", moo)) {}
*buffer_len = (ssize_t)alsobad((char *)buffer, NULL, 16);
# if defined(SINGLE_MACRO)
#if ! defined(__macro_10)
#elif !defined(TESTMACRO)
#endif
#endif
#endif
// CPP comment ?
/* comment does not end
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<stdout>
./%LOGDIR/code1185.c:4:82: warning: Longer than 79 columns (LONGLINE)
int hello; /*------------------------------------------------------------------*/
./%LOGDIR/code1185.c:5:4: error: Contains TAB character (TABS)
int%TABtab;
^
./%LOGDIR/code1185.c:7:13: warning: func with space (SPACEBEFOREPAREN)
int a = func ();
^
./%LOGDIR/code1185.c:8:14: warning: space after open parenthesis (SPACEAFTERPAREN)
int b = func( b);
^
./%LOGDIR/code1185.c:9:16: warning: space before close parenthesis (SPACEBEFORECLOSE)
int b = func(b );
^
./%LOGDIR/code1185.c:10:11: warning: space before comma (SPACEBEFORECOMMA)
func(a, b , c);
^
./%LOGDIR/code1185.c:14:9: warning: return without space before paren (RETURNNOSPACE)
return(2);
^
./%LOGDIR/code1185.c:16:11: warning: comma without following space (COMMANOSPACE)
func(a, b,c);
^
./%LOGDIR/code1185.c:18:12: warning: wrongly placed open brace (BRACEPOS)
if(a == 2) {
^
./%LOGDIR/code1185.c:20:1: warning: else after closing brace on same line (BRACEELSE)
} else {
^
./%LOGDIR/code1185.c:24:11: warning: missing space after close paren (PARENBRACE)
if(a == 2){%SP%SP
^
./%LOGDIR/code1185.c:28:14: warning: no space before semicolon (SPACESEMICOLON)
func_return() ;
^
./%LOGDIR/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC)
a = sprintf(buffer, "%s", moo);
^
./%LOGDIR/code1185.c:32:11: warning: use of non-binary fopen without FOPEN_* macro: r (FOPENMODE)
FILE *f = curlx_fopen("filename", "r");
^
./%LOGDIR/code1185.c:34:30: warning: wrongly placed open brace (BRACEPOS)
void startfunc(int a, int b) {
^
./%LOGDIR/code1185.c:39:6: warning: not indented 2 steps (uses 4) (INDENTATION)
func(1);
^
./%LOGDIR/code1185.c:42:8: warning: space after declarative asterisk (ASTERISKSPACE)
char * name = "hello";
^
./%LOGDIR/code1185.c:43:7: warning: space after declarative asterisk (ASTERISKSPACE)
char* name = "hello";
^
./%LOGDIR/code1185.c:43:6: warning: no space before asterisk (ASTERISKNOSPACE)
char* name = "hello";
^
./%LOGDIR/code1185.c:45:10: warning: no space after equals sign (EQUALSNOSPACE)
int foo=bar;
^
./%LOGDIR/code1185.c:46:9: warning: no space before equals sign (NOSPACEEQUALS)
int foo= bar;
^
./%LOGDIR/code1185.c:48:16: warning: no space after semicolon (SEMINOSPACE)
int foo = bar;foo++;
^
./%LOGDIR/code1185.c:49:10: warning: multiple spaces (MULTISPACE)
for(;;) {
^
./%LOGDIR/code1185.c:50:5: warning: not indented 2 steps (uses 3) (INDENTATION)
moo();
^
./%LOGDIR/code1185.c:52:3: warning: Suspicious close brace indentation (CLOSEBRACE)
moo();
^
./%LOGDIR/code1185.c:54:16: warning: sizeof without parenthesis (SIZEOFNOPAREN)
int a = sizeof int;
^
./%LOGDIR/code1185.c:55:10: warning: use of magicbad is banned (BANNEDFUNC)
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
^
./%LOGDIR/code1185.c:55:27: warning: use of alsobad is banned (BANNEDFUNC)
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
^
./%LOGDIR/code1185.c:56:21: warning: missing space before colon (NOSPACEC)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:22: warning: missing space after colon (NOSPACEC)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:15: warning: missing space before question mark (NOSPACEQ)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:16: warning: missing space after question mark (NOSPACEQ)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:23: warning: missing space before less or greater than (NOSPACETHAN)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:23: warning: missing space after less or greater than (NOSPACETHAN)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:57:23: warning: missing space before less or greater than (NOSPACETHAN)
int moo2 = wrong2:(a)>(b);
^
./%LOGDIR/code1185.c:57:23: warning: missing space after less or greater than (NOSPACETHAN)
int moo2 = wrong2:(a)>(b);
^
./%LOGDIR/code1185.c:59:7: warning: conditional block on the same line (ONELINECONDITION)
if(a) b++;
^
./%LOGDIR/code1185.c:61:5: warning: use of sprintf is banned (BANNEDFUNC)
if(sprintf(buffer, "%s", moo)) {}
^
./%LOGDIR/code1185.c:62:25: warning: use of alsobad is banned (BANNEDFUNC)
*buffer_len = (ssize_t)alsobad((char *)buffer, NULL, 16);
^
./%LOGDIR/code1185.c:64:1: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE)
# if defined(SINGLE_MACRO)
^
./%LOGDIR/code1185.c:65:1: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE)
#if ! defined(__macro_10)
^
./%LOGDIR/code1185.c:71:2: warning: // comment (CPPCOMMENTS)
// CPP comment ?
^
./%LOGDIR/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT)
%SP
^
./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
%SP
^
checksrc: 0 errors and 44 warnings
</stdout>
<errorcode>
5
</errorcode>
</verify>
</testcase>
|