mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
build: use more gnulib modules for simpler code
* .gnulib: Update to latest, for sigpipe and sigaction modules. * bootstrap.conf (gnulib_modules): Add siaction, sigpipe, strerror_r. * tools/virsh.c (vshSetupSignals) [!SIGPIPE]: Delete, now that gnulib guarantees it. (SA_SIGINFO): Define for mingw fallback. * src/util/virterror.c (virStrerror): Simplify, now that gnulib guarantees the POSIX interface. * configure.ac (AC_CHECK_FUNCS_ONCE): Drop redundant check. (AM_PROG_CC_STDC): Move earlier, to keep autoconf happy.
This commit is contained in:
parent
915bc7421e
commit
c5b11b3cc4
2
.gnulib
2
.gnulib
@ -1 +1 @@
|
||||
Subproject commit 9779055889c2715b593930e39ead552759b5ddc2
|
||||
Subproject commit 45d39ca1cae74fcf58ec9911e771bc8baca63f66
|
@ -58,12 +58,15 @@ random_r
|
||||
sched
|
||||
send
|
||||
setsockopt
|
||||
sigaction
|
||||
sigpipe
|
||||
snprintf
|
||||
socket
|
||||
stpcpy
|
||||
strchrnul
|
||||
strndup
|
||||
strerror
|
||||
strerror_r-posix
|
||||
strptime
|
||||
strsep
|
||||
strtok_r
|
||||
|
13
configure.ac
13
configure.ac
@ -49,11 +49,11 @@ dnl Checks for C compiler.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_CPP
|
||||
AM_PROG_CC_STDC
|
||||
|
||||
gl_EARLY
|
||||
gl_INIT
|
||||
|
||||
AM_PROG_CC_STDC
|
||||
AC_TYPE_UID_T
|
||||
|
||||
dnl Make sure we have an ANSI compiler
|
||||
@ -93,12 +93,11 @@ fi
|
||||
AC_MSG_RESULT([$have_cpuid])
|
||||
|
||||
|
||||
dnl Availability of various common functions (non-fatal if missing).
|
||||
AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid initgroups \
|
||||
posix_fallocate mmap])
|
||||
|
||||
dnl Availability of various not common threadsafe functions
|
||||
AC_CHECK_FUNCS_ONCE([strerror_r getmntent_r getgrnam_r getpwuid_r])
|
||||
dnl Availability of various common functions (non-fatal if missing),
|
||||
dnl and various less common threadsafe functions
|
||||
AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \
|
||||
initgroups posix_fallocate mmap \
|
||||
getmntent_r getgrnam_r getpwuid_r])
|
||||
|
||||
dnl Availability of pthread functions (if missing, win32 threading is
|
||||
dnl assumed). Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
|
||||
|
@ -1250,7 +1250,7 @@ void virReportErrorHelper(virConnectPtr conn,
|
||||
* @errBuf: the buffer to save the error to
|
||||
* @errBufLen: the buffer length
|
||||
*
|
||||
* Generate an erro string for the given errno
|
||||
* Generate an error string for the given errno
|
||||
*
|
||||
* Returns a pointer to the error string, possibly indicating that the
|
||||
* error is unknown
|
||||
@ -1260,24 +1260,8 @@ const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
|
||||
int save_errno = errno;
|
||||
const char *ret;
|
||||
|
||||
#ifdef HAVE_STRERROR_R
|
||||
# ifdef __USE_GNU
|
||||
/* Annoying linux specific API contract */
|
||||
ret = strerror_r(theerrno, errBuf, errBufLen);
|
||||
# else
|
||||
strerror_r(theerrno, errBuf, errBufLen);
|
||||
ret = errBuf;
|
||||
# endif
|
||||
#else
|
||||
/* Mingw lacks strerror_r and its strerror is definitely not
|
||||
* threadsafe, so safest option is to just print the raw errno
|
||||
* value - we can at least reliably & safely look it up in the
|
||||
* header files for debug purposes
|
||||
*/
|
||||
int n = snprintf(errBuf, errBufLen, "errno=%d", theerrno);
|
||||
ret = (0 < n && n < errBufLen
|
||||
? errBuf : _("internal error: buffer too small"));
|
||||
#endif
|
||||
errno = save_errno;
|
||||
return ret;
|
||||
}
|
||||
|
@ -497,7 +497,11 @@ out:
|
||||
*/
|
||||
static int disconnected = 0; /* we may have been disconnected */
|
||||
|
||||
#ifdef SIGPIPE
|
||||
/* Gnulib doesn't guarantee SA_SIGINFO support. */
|
||||
#ifndef SA_SIGINFO
|
||||
# define SA_SIGINFO 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vshCatchDisconnect:
|
||||
*
|
||||
@ -506,7 +510,8 @@ static int disconnected = 0; /* we may have been disconnected */
|
||||
*/
|
||||
static void vshCatchDisconnect(int sig, siginfo_t *siginfo,
|
||||
void *context ATTRIBUTE_UNUSED) {
|
||||
if ((sig == SIGPIPE) || (siginfo->si_signo == SIGPIPE))
|
||||
if ((sig == SIGPIPE) ||
|
||||
(SA_SIGINFO && siginfo->si_signo == SIGPIPE))
|
||||
disconnected++;
|
||||
}
|
||||
|
||||
@ -526,10 +531,6 @@ vshSetupSignals(void) {
|
||||
|
||||
sigaction(SIGPIPE, &sig_action, NULL);
|
||||
}
|
||||
#else
|
||||
static void
|
||||
vshSetupSignals(void) {}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vshReconnect:
|
||||
|
Loading…
Reference in New Issue
Block a user