bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH hurd 2/2] libshouldbeinlibc: add safe port handling macros


From: Ludovic Courtès
Subject: Re: [PATCH hurd 2/2] libshouldbeinlibc: add safe port handling macros
Date: Sun, 05 Jun 2016 21:53:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Justus Winter <justus@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.

Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]