0003-remove-assert-fail.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Remove __assert_fail()
  2. The netplug code uses the assert() macro in various places. In glibc
  3. internally, assert() uses a function called __assert_fail() to print a
  4. message and abort. Relying on internal glibc details, netplug
  5. re-defines __assert_fail() in the hope that it will get called instead
  6. of glibc internal version.
  7. This attempt:
  8. * Doesn't work with uClibc, which doesn't use any __assert_fail()
  9. function at all. It doesn't fail to build, but it is entirely
  10. useless.
  11. * Fails to build with musl, which also defines __assert_fail(), but
  12. with a different prototype.
  13. We simply remove the __assert_fail() implementation, so that the C
  14. library implementation of assert() just does its normal work. The only
  15. functionality lost is that the message is displayed on the standard
  16. output rather than in netplug's logs (and this was only working with
  17. glibc anyway).
  18. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  19. Index: b/lib.c
  20. ===================================================================
  21. --- a/lib.c
  22. +++ b/lib.c
  23. @@ -199,21 +199,6 @@
  24. return x;
  25. }
  26. -
  27. -void
  28. -__assert_fail(const char *assertion, const char *file,
  29. - unsigned int line, const char *function)
  30. -{
  31. - do_log(LOG_CRIT, "%s:%u: %s%sAssertion `%s' failed",
  32. - file, line,
  33. - function ? function : "",
  34. - function ? ": " : "",
  35. - assertion);
  36. -
  37. - abort();
  38. -}
  39. -
  40. -
  41. /*
  42. * Local variables:
  43. * c-file-style: "stroustrup"