license_depends_compat.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <tools/ccanlint/ccanlint.h>
  2. #include <ccan/foreach/foreach.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <limits.h>
  8. #include <errno.h>
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <err.h>
  12. static void check_license_depends_compat(struct manifest *m,
  13. unsigned int *timeleft UNNEEDED,
  14. struct score *score)
  15. {
  16. struct manifest *i;
  17. score->pass = true;
  18. /* If our license is unknown, we can't know the answer. */
  19. if (m->license == LICENSE_UNKNOWN) {
  20. score->score = score->total = 0;
  21. return;
  22. }
  23. list_for_each(&m->deps, i, list) {
  24. struct doc_section *d = find_license_tag(i);
  25. i->license = which_license(d);
  26. if (i->license != LICENSE_UNKNOWN
  27. && !license_compatible[m->license][i->license]) {
  28. score_file_error(score, i->info_file, 0,
  29. "Dependency ccan/%s has"
  30. " incompatible license '%s'",
  31. i->modname,
  32. licenses[i->license].name);
  33. score->pass = false;
  34. }
  35. }
  36. if (score->pass)
  37. score->score = score->total;
  38. }
  39. struct ccanlint license_depends_compat = {
  40. .key = "license_depends_compat",
  41. .name = "CCAN dependencies don't contain incompatible licenses",
  42. .check = check_license_depends_compat,
  43. .needs = "license_exists depends_exist"
  44. };
  45. REGISTER_TEST(license_depends_compat);