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@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 ;) Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org