Ludovic Courtès, on Sun 05 Jun 2016 21:53:35 +0200, wrote: > Justus Winter <jus...@gnupg.org> skribis: > > +#define Mach_port_check(NAME) \ > > + void _Mach_port_check_##NAME(char *_unused[] __attribute__ ((unused))) \ > > + { \ > > + if (MACH_PORT_VALID (NAME)) \ > > + __print_fail_backtrace (#NAME " leaked", \ > > + __FILE__, __LINE__, "Port leak detector"); \ > > + } \ > > + char _Mach_port_check_x_##NAME[0] \ > > + __attribute__ ((unused, cleanup (_Mach_port_check_##NAME))) > > I think writing a GCC plug-in that would automatically add a cleanup > handler to automatic variables of type ‘mach_port_t’ wouldn’t be > unreasonable.
I don't enough to be sure, but isn't that the typical work of LocalitySanitizer, precisely? Samuel