pseudo_cppcheck.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main(int argc, char* argv[])
  5. {
  6. int i;
  7. int result = 0;
  8. for (i = 1; i < argc; ++i) {
  9. if (strcmp(argv[i], "-bad") == 0) {
  10. fprintf(stdout, "stdout from bad command line arg '-bad'\n");
  11. fprintf(stderr, "stderr from bad command line arg '-bad'\n");
  12. return 1;
  13. } else if (strcmp(argv[i], "-error") == 0) {
  14. // The real cppcheck allows to set the exitcode with --error-exitcode
  15. result = 5;
  16. }
  17. }
  18. fprintf(stderr,
  19. "[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12,"
  20. " which is out of bounds.\n");
  21. fprintf(stderr,
  22. "[/foo/bar.c:2]: (warning) Member variable 'foo::bar' is "
  23. "not initialized in the constructor.\n");
  24. fprintf(stderr, "[/foo/bar.c:2]: (style) C-style pointer casting.\n");
  25. fprintf(stderr,
  26. "[/foo/bar.c:2]: (performance) Variable 'm_message' is "
  27. "assigned in constructor body. Consider performing "
  28. "initialization in initialization list.\n");
  29. fprintf(stderr,
  30. "[/foo/bar.c:2]: (portability) scanf without field width "
  31. "limits can crash with huge input data on some versions of "
  32. "libc\n");
  33. fprintf(stderr,
  34. "[/foo/bar.c:2]: (information) cannot find all the include "
  35. "files (use --check-config for details)\n");
  36. return result;
  37. }