diff --git a/0001-lib-utils.c-Use-strerrordesc_np-as-alternative-in-as.patch b/0001-lib-utils.c-Use-strerrordesc_np-as-alternative-in-as.patch new file mode 100644 index 0000000..e895081 --- /dev/null +++ b/0001-lib-utils.c-Use-strerrordesc_np-as-alternative-in-as.patch @@ -0,0 +1,96 @@ +From 814e597c4ed49ca59b8f24a5f16a487409a4804e Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 17 Jul 2020 12:35:59 +0100 +Subject: [PATCH] lib/utils.c: Use strerrordesc_np as alternative in async-safe + perror. + +See: +https://lists.fedoraproject.org/archives/list/glibc@lists.fedoraproject.org/thread/WJHGG2OO7ABNAYICGA5WQZ2Q34Q2FEHU/ + +Thanks: Florian Weimer +--- + configure.ac | 5 +++++ + lib/utils.c | 31 +++++++++++++++++++------------ + 2 files changed, 24 insertions(+), 12 deletions(-) + +diff --git a/configure.ac b/configure.ac +index e5c29cd..a44e3b1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -79,6 +79,11 @@ AC_CHECK_HEADERS([\ + + AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include ]) + ++dnl Check for strerrordesc_np (optional, glibc only). ++dnl Prefer this over sys_errlist. ++dnl https://lists.fedoraproject.org/archives/list/glibc@lists.fedoraproject.org/thread/WJHGG2OO7ABNAYICGA5WQZ2Q34Q2FEHU/ ++AC_CHECK_FUNCS([strerrordesc_np]) ++ + dnl Check for sys_errlist (optional). + AC_MSG_CHECKING([for sys_errlist]) + AC_TRY_LINK([], [extern int sys_errlist; char *p = &sys_errlist;], [ +diff --git a/lib/utils.c b/lib/utils.c +index bc62f93..86e9849 100644 +--- a/lib/utils.c ++++ b/lib/utils.c +@@ -136,6 +136,11 @@ nbd_internal_fork_safe_itoa (long v, char *buf, size_t bufsize) + return &buf[i]; + } + ++#if defined(__GNUC__) ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wunused-result" ++#endif ++ + /* Fork-safe version of perror. ONLY use this after fork and before + * exec, the rest of the time use set_error(). + */ +@@ -143,24 +148,22 @@ void + nbd_internal_fork_safe_perror (const char *s) + { + const int err = errno; ++ const char *m = NULL; ++ char buf[32]; + +-#if defined(__GNUC__) +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Wunused-result" +-#endif + write (2, s, strlen (s)); + write (2, ": ", 2); +-#if HAVE_SYS_ERRLIST +- write (2, sys_errlist[errno], strlen (sys_errlist[errno])); ++#ifdef HAVE_STRERRORDESC_NP ++ m = strerrordesc_np (errno); + #else +- char buf[32]; +- const char *v = nbd_internal_fork_safe_itoa ((long) errno, buf, sizeof buf); +- write (2, v, strlen (v)); ++#ifdef HAVE_SYS_ERRLIST ++ m = errno >= 0 && errno < sys_nerr ? sys_errlist[errno] : NULL; + #endif ++#endif ++ if (!m) ++ m = nbd_internal_fork_safe_itoa ((long) errno, buf, sizeof buf); ++ write (2, m, strlen (m)); + write (2, "\n", 1); +-#if defined(__GNUC__) +-#pragma GCC diagnostic pop +-#endif + + /* Restore original errno in case it was disturbed by the system + * calls above. +@@ -168,6 +171,10 @@ nbd_internal_fork_safe_perror (const char *s) + errno = err; + } + ++#if defined(__GNUC__) ++#pragma GCC diagnostic pop ++#endif ++ + /* nbd_internal_printable_* functions are used by the API code to + * print debug messages when we trace calls in and out of libnbd. The + * calls should attempt to convert the parameter into something +-- +2.27.0 + diff --git a/libnbd.spec b/libnbd.spec index 1859d9c..171508e 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -2,14 +2,14 @@ %global verify_tarball_signature 1 # If there are patches which touch autotools files, set this to 1. -%global patches_touch_autotools %{nil} +%global patches_touch_autotools 1 # The source directory. %global source_directory 1.3-development Name: libnbd Version: 1.3.8 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NBD client library in userspace License: LGPLv2+ @@ -22,6 +22,8 @@ Source1: http://libguestfs.org/download/libnbd/%{source_directory}/%{name # https://pgp.key-server.io/pks/lookup?search=rjones%40redhat.com&fingerprint=on&op=vindex Source2: libguestfs.keyring +Patch1: 0001-lib-utils.c-Use-strerrordesc_np-as-alternative-in-as.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif @@ -282,9 +284,10 @@ make %{?_smp_mflags} check || { %changelog -* Fri Jul 17 2020 Richard W.M. Jones - 1.3.8-1 +* Fri Jul 17 2020 Richard W.M. Jones - 1.3.8-2 - New upstream version 1.3.8. - New tool: nbdcopy +- Add upstream patch to fix compilation with glibc from Rawhide. * Tue May 26 2020 Miro HronĨok - 1.3.7-3 - Rebuilt for Python 3.9