gcc 6.0 added an annoying warning:
fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK) {
^~
fdstream.c: In function 'virFDStreamRead':
fdstream.c:440:29: error: logical 'or' of equal expressions [-Werror=logical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK) {
^~
This makes it impossible to build out-of-the-box on rawhide,
and we aren't guaranteed that the gcc bug will be fixed in a
timely manner:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
So work around it by further complicating the logic to thwart the
compiler.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
This is a build-breaker fix for rawhide; but I'll wait for a day
for any reasons why I should not push it during freeze.
src/fdstream.c | 8 +++++---
src/rpc/virnetsshsession.c | 10 +++++++---
src/security/security_selinux.c | 5 +++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index a85cf9d..1c34321 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -1,7 +1,7 @@
/*
* fdstream.c: generic streams impl for file descriptors
*
- * Copyright (C) 2009-2012, 2014, 2016 Red Hat, Inc.
+ * Copyright (C) 2009-2012, 2014, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -387,7 +387,8 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t
nbytes)
retry:
ret = write(fdst->fd, bytes, nbytes);
if (ret < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (errno == EAGAIN ||
+ (EAGAIN != EWOULDBLOCK && errno == EWOULDBLOCK)) {
ret = -2;
} else if (errno == EINTR) {
goto retry;
@@ -437,7 +438,8 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t
nbytes)
retry:
ret = read(fdst->fd, bytes, nbytes);
if (ret < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (errno == EAGAIN ||
+ (EAGAIN != EWOULDBLOCK && errno == EWOULDBLOCK)) {
ret = -2;
} else if (errno == EINTR) {
goto retry;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 406a831..d7d1c1a 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -1,7 +1,7 @@
/*
* virnetsshsession.c: ssh network transport provider based on libssh2
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2013, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -546,7 +546,9 @@ virNetSSHAuthenticateAgent(virNetSSHSessionPtr sess,
return 0; /* key accepted */
if (ret != LIBSSH2_ERROR_AUTHENTICATION_FAILED &&
- ret != LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED &&
+ (LIBSSH2_ERROR_AUTHENTICATION_FAILED !=
+ LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED &&
+ ret != LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED) &&
ret != LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
libssh2_session_last_error(sess->session, &errmsg, NULL, 0);
virReportError(VIR_ERR_AUTH_FAILED,
@@ -674,7 +676,9 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
priv->filename, errmsg);
if (ret == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED ||
- ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED)
+ (LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED !=
+ LIBSSH2_ERROR_AUTHENTICATION_FAILED &&
+ ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED))
return 1;
else
return -1;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 26d95d1..25f0bdf 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2014 Red Hat, Inc.
+ * Copyright (C) 2008-2014, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -911,7 +911,8 @@ virSecuritySELinuxSetFileconHelper(const char *path, char *tcon,
* hopefully sets one of the necessary SELinux virt_use_{nfs,usb,pci}
* boolean tunables to allow it ...
*/
- if (setfilecon_errno != EOPNOTSUPP && setfilecon_errno != ENOTSUP
&&
+ if (setfilecon_errno != EOPNOTSUPP &&
+ (EOPNOTSUPP != ENOTSUP && setfilecon_errno != ENOTSUP) &&
setfilecon_errno != EROFS) {
virReportSystemError(setfilecon_errno,
_("unable to set security context '%s' on
'%s'"),
--
2.5.0