[Libguestfs] [libnbd PATCH v4 2/3] lib/utils: add async-signal-safe assert()

Laszlo Ersek lersek at redhat.com
Thu Mar 16 09:31:22 UTC 2023


On 3/15/23 18:18, Eric Blake wrote:
> On Wed, Mar 15, 2023 at 12:01:56PM +0100, Laszlo Ersek wrote:
>> Add an assert() variant that we may call between fork() and exec*().
>>
>> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
>> ---
>>
> 
>> +void
>> +nbd_internal_fork_safe_assert (int result, const char *file, long line,
>> +                               const char *func, const char *assertion)
>> +{
>> +  const char *line_out;
>> +  char line_buf[32];
>> +
>> +  if (result)
>> +    return;
>> +
>> +  line_out = nbd_internal_fork_safe_itoa (line, line_buf, sizeof line_buf);
>> +  xwritel (STDERR_FILENO, file, ":", line_out, ": ", func, ": Assertion `",
>> +           assertion, "' failed.\n", (char *)NULL);
> 
> xwritel() makes this so much shorter ;)

I know, right? :)

> 
> Reviewed-by: Eric Blake <eblake at redhat.com>
> 

Thanks!



More information about the Libguestfs mailing list