[PATCH] check_native: Get rid of alloca
Andreas Schwab
schwab@suse.de
Thu Jun 1 08:28:32 GMT 2023
On Jun 01 2023, Florian Weimer wrote:
> * Andreas Schwab:
>
>> On Jun 01 2023, Florian Weimer via Libc-alpha wrote:
>>
>>> * Adhemerval Zanella Netto via Libc-alpha:
>>>
>>>> +static void
>>>> +iclose (int *fd)
>>>> +{
>>>> + if (*fd >= 0)
>>>> + __close_nocancel_nostatus (*fd);
>>>> +}
>>>> +
>>>> void
>>>> __check_native (uint32_t a1_index, int *a1_native,
>>>> uint32_t a2_index, int *a2_native)
>>>> {
>>>> - int fd = __socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
>>>> + int __attribute__ ((__cleanup__ (iclose))) fd
>>>> + = __socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
>>>> + if (fd < 0)
>>>> + return;
>>>
>>> I think introducing attribute cleanup where equivalent functionality can
>>> be implemented otherwise requires a discussion first.
>>
>> The cleanup attribute requires compiling the function and all callees
>> with -fasynchronous-unwind-tables.
>
> I think GCC will still call the destructor on normal scope exit (if no
> exception is thrown), even with -fno-exceptions. That should be
> sufficient here?
The cancellation could be asynchronous.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list