tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

dubious.c (1085B)


      1 // The { coming up should be on its own line.
      2 int
      3 foo(void) {
      4  // There should be a space before (1)
      5  if(1) x += 1;
      6 
      7  // The following empty line is unnecessary.
      8 
      9 }
     10 
     11 
     12 // There should be a newline between void and bar.
     13 void bar(void)
     14 {
     15  // too wide:
     16  testing("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
     17 }
     18 
     19 long
     20 bad_spacing()
     21 {
     22  // here comes a tab
     23 return 2;
     24  // here comes a label without space:
     25 foo:
     26  ;
     27 }
     28 
     29 // Here comes a CR:
     30 
     31 // Trailing space:         
     32 
     33 int
     34 non_k_and_r(void)
     35 {
     36  // non-k&r
     37  if (foo)
     38    {
     39      // double-semi
     40      return 1;;
     41    }
     42  else
     43    {
     44      return 2;
     45    }
     46 }
     47 
     48 // #else #if causes a warning.
     49 #if 1
     50 #else
     51 #if 2
     52 #else
     53 #endif
     54 #endif
     55 
     56 // always space before a brace.
     57 foo{
     58 }
     59 
     60 void
     61 unexpected_space(void)
     62 {
     63  // This space gives a warning.
     64  foobar (77);
     65 }
     66 
     67 void
     68 bad_function_calls(long)
     69 {
     70  // These are forbidden:
     71  assert(1);
     72  memcmp("a","b",1);
     73  strcat(foo,x);
     74  strcpy(foo,y);
     75  sprintf(foo,"x");
     76  malloc(7);
     77  free(p);
     78  realloc(p);
     79  strdup(s);
     80  strndup(s,10);
     81  calloc(a,b);
     82 }