|
|
8fa411 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8fa411 |
Date: Sun, 10 Apr 2016 18:22:20 +0200
|
|
|
8fa411 |
Subject: [PATCH] build: add GCC 6.0 -Wlogical-op workaround
|
|
|
8fa411 |
|
|
|
8fa411 |
fdstream.c: In function 'virFDStreamWrite':
|
|
|
8fa411 |
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
|
|
|
8fa411 |
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
|
8fa411 |
^~
|
|
|
8fa411 |
|
|
|
8fa411 |
Fedora rawhide now uses gcc 6.0 and there is a bug with -Wlogical-op
|
|
|
8fa411 |
producing false warnings.
|
|
|
8fa411 |
|
|
|
8fa411 |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
|
|
|
8fa411 |
|
|
|
8fa411 |
Use GCC pragma push/pop and ignore -Wlogical-op for GCC that supports
|
|
|
8fa411 |
push/pop pragma and also has this bug.
|
|
|
8fa411 |
|
|
|
8fa411 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8fa411 |
(cherry picked from commit d713a6b120904c488170e7920c482b2fade70ae1)
|
|
|
8fa411 |
---
|
|
|
8fa411 |
m4/virt-compile-warnings.m4 | 20 ++++++++++++++++++++
|
|
|
8fa411 |
src/fdstream.c | 4 ++++
|
|
|
8fa411 |
src/internal.h | 12 ++++++++++++
|
|
|
8fa411 |
src/rpc/virnetsshsession.c | 6 ++++++
|
|
|
8fa411 |
src/security/security_selinux.c | 2 ++
|
|
|
8fa411 |
5 files changed, 44 insertions(+)
|
|
|
8fa411 |
|
|
|
8fa411 |
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
|
|
|
8fa411 |
index 1b0a2cf..eb689e2 100644
|
|
|
8fa411 |
--- a/m4/virt-compile-warnings.m4
|
|
|
8fa411 |
+++ b/m4/virt-compile-warnings.m4
|
|
|
8fa411 |
@@ -117,6 +117,20 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
|
|
|
8fa411 |
[lv_cv_gcc_wlogical_op_broken=yes])
|
|
|
8fa411 |
CFLAGS="$save_CFLAGS"])
|
|
|
8fa411 |
|
|
|
8fa411 |
+ AC_CACHE_CHECK([whether gcc gives bogus warnings for -Wlogical-op],
|
|
|
8fa411 |
+ [lv_cv_gcc_wlogical_op_equal_expr_broken], [
|
|
|
8fa411 |
+ save_CFLAGS="$CFLAGS"
|
|
|
8fa411 |
+ CFLAGS="-O2 -Wlogical-op -Werror"
|
|
|
8fa411 |
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
8fa411 |
+ #define TEST1 1
|
|
|
8fa411 |
+ #define TEST2 TEST1
|
|
|
8fa411 |
+ ]], [[
|
|
|
8fa411 |
+ int test = 0;
|
|
|
8fa411 |
+ return test == TEST1 || test == TEST2;]])],
|
|
|
8fa411 |
+ [lv_cv_gcc_wlogical_op_equal_expr_broken=no],
|
|
|
8fa411 |
+ [lv_cv_gcc_wlogical_op_equal_expr_broken=yes])
|
|
|
8fa411 |
+ CFLAGS="$save_CFLAGS"])
|
|
|
8fa411 |
+
|
|
|
8fa411 |
# We might fundamentally need some of these disabled forever, but
|
|
|
8fa411 |
# ideally we'd turn many of them on
|
|
|
8fa411 |
dontwarn="$dontwarn -Wfloat-equal"
|
|
|
8fa411 |
@@ -239,4 +253,10 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
|
|
|
8fa411 |
AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP_STRCHR], 1,
|
|
|
8fa411 |
[Define to 1 if gcc -Wlogical-op reports false positives on strchr])
|
|
|
8fa411 |
fi
|
|
|
8fa411 |
+
|
|
|
8fa411 |
+ if test "$gl_cv_warn_c__Wlogical_op" = yes &&
|
|
|
8fa411 |
+ test "$lv_cv_gcc_wlogical_op_equal_expr_broken" = yes; then
|
|
|
8fa411 |
+ AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP_EQUAL_EXPR], 1,
|
|
|
8fa411 |
+ [Define to 1 if gcc -Wlogical-op reports false positive 'or' equal expr])
|
|
|
8fa411 |
+ fi
|
|
|
8fa411 |
])
|
|
|
8fa411 |
diff --git a/src/fdstream.c b/src/fdstream.c
|
|
|
8fa411 |
index a85cf9d..ef118b5 100644
|
|
|
8fa411 |
--- a/src/fdstream.c
|
|
|
8fa411 |
+++ b/src/fdstream.c
|
|
|
8fa411 |
@@ -387,7 +387,9 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
|
|
|
8fa411 |
retry:
|
|
|
8fa411 |
ret = write(fdst->fd, bytes, nbytes);
|
|
|
8fa411 |
if (ret < 0) {
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
ret = -2;
|
|
|
8fa411 |
} else if (errno == EINTR) {
|
|
|
8fa411 |
goto retry;
|
|
|
8fa411 |
@@ -437,7 +439,9 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
|
|
|
8fa411 |
retry:
|
|
|
8fa411 |
ret = read(fdst->fd, bytes, nbytes);
|
|
|
8fa411 |
if (ret < 0) {
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
ret = -2;
|
|
|
8fa411 |
} else if (errno == EINTR) {
|
|
|
8fa411 |
goto retry;
|
|
|
8fa411 |
diff --git a/src/internal.h b/src/internal.h
|
|
|
8fa411 |
index 35cc6d4..926e990 100644
|
|
|
8fa411 |
--- a/src/internal.h
|
|
|
8fa411 |
+++ b/src/internal.h
|
|
|
8fa411 |
@@ -245,11 +245,23 @@
|
|
|
8fa411 |
_Pragma ("GCC diagnostic push")
|
|
|
8fa411 |
# endif
|
|
|
8fa411 |
|
|
|
8fa411 |
+/* Workaround bogus GCC 6.0 for logical 'or' equal expression warnings.
|
|
|
8fa411 |
+ * (GCC bz 69602) */
|
|
|
8fa411 |
+# if BROKEN_GCC_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
+# define VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR \
|
|
|
8fa411 |
+ _Pragma ("GCC diagnostic push") \
|
|
|
8fa411 |
+ _Pragma ("GCC diagnostic ignored \"-Wlogical-op\"")
|
|
|
8fa411 |
+# else
|
|
|
8fa411 |
+# define VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR \
|
|
|
8fa411 |
+ _Pragma ("GCC diagnostic push")
|
|
|
8fa411 |
+# endif
|
|
|
8fa411 |
+
|
|
|
8fa411 |
# define VIR_WARNINGS_RESET \
|
|
|
8fa411 |
_Pragma ("GCC diagnostic pop")
|
|
|
8fa411 |
# else
|
|
|
8fa411 |
# define VIR_WARNINGS_NO_CAST_ALIGN
|
|
|
8fa411 |
# define VIR_WARNINGS_NO_PRINTF
|
|
|
8fa411 |
+# define VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
# define VIR_WARNINGS_RESET
|
|
|
8fa411 |
# endif
|
|
|
8fa411 |
|
|
|
8fa411 |
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
|
|
|
8fa411 |
index 406a831..e742175 100644
|
|
|
8fa411 |
--- a/src/rpc/virnetsshsession.c
|
|
|
8fa411 |
+++ b/src/rpc/virnetsshsession.c
|
|
|
8fa411 |
@@ -545,9 +545,11 @@ virNetSSHAuthenticateAgent(virNetSSHSessionPtr sess,
|
|
|
8fa411 |
agent_identity)))
|
|
|
8fa411 |
return 0; /* key accepted */
|
|
|
8fa411 |
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (ret != LIBSSH2_ERROR_AUTHENTICATION_FAILED &&
|
|
|
8fa411 |
ret != LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED &&
|
|
|
8fa411 |
ret != LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
libssh2_session_last_error(sess->session, &errmsg, NULL, 0);
|
|
|
8fa411 |
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
8fa411 |
_("failed to authenticate using SSH agent: %s"),
|
|
|
8fa411 |
@@ -605,9 +607,11 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
|
|
|
8fa411 |
priv->password)) == 0)
|
|
|
8fa411 |
return 0; /* success */
|
|
|
8fa411 |
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (priv->password ||
|
|
|
8fa411 |
ret == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED ||
|
|
|
8fa411 |
ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED) {
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
libssh2_session_last_error(sess->session, &errmsg, NULL, 0);
|
|
|
8fa411 |
virReportError(VIR_ERR_AUTH_FAILED,
|
|
|
8fa411 |
_("authentication with private key '%s' "
|
|
|
8fa411 |
@@ -673,11 +677,13 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
|
|
|
8fa411 |
"has failed: %s"),
|
|
|
8fa411 |
priv->filename, errmsg);
|
|
|
8fa411 |
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (ret == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED ||
|
|
|
8fa411 |
ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED)
|
|
|
8fa411 |
return 1;
|
|
|
8fa411 |
else
|
|
|
8fa411 |
return -1;
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
}
|
|
|
8fa411 |
|
|
|
8fa411 |
return 0;
|
|
|
8fa411 |
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
|
|
|
8fa411 |
index 26d95d1..04760a1 100644
|
|
|
8fa411 |
--- a/src/security/security_selinux.c
|
|
|
8fa411 |
+++ b/src/security/security_selinux.c
|
|
|
8fa411 |
@@ -911,8 +911,10 @@ virSecuritySELinuxSetFileconHelper(const char *path, char *tcon,
|
|
|
8fa411 |
* hopefully sets one of the necessary SELinux virt_use_{nfs,usb,pci}
|
|
|
8fa411 |
* boolean tunables to allow it ...
|
|
|
8fa411 |
*/
|
|
|
8fa411 |
+ VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
|
|
8fa411 |
if (setfilecon_errno != EOPNOTSUPP && setfilecon_errno != ENOTSUP &&
|
|
|
8fa411 |
setfilecon_errno != EROFS) {
|
|
|
8fa411 |
+ VIR_WARNINGS_RESET
|
|
|
8fa411 |
virReportSystemError(setfilecon_errno,
|
|
|
8fa411 |
_("unable to set security context '%s' on '%s'"),
|
|
|
8fa411 |
tcon, path);
|