|
|
4a2fec |
From a04141c5a3565ac437ff7093f36ddf0fb60acdd5 Mon Sep 17 00:00:00 2001
|
|
|
4a2fec |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
4a2fec |
Date: Mon, 5 Feb 2018 11:10:10 +0100
|
|
|
4a2fec |
Subject: [PATCH 16/20] ui: mix misleading comments & return types of VNC I/O
|
|
|
4a2fec |
helper methods
|
|
|
4a2fec |
MIME-Version: 1.0
|
|
|
4a2fec |
Content-Type: text/plain; charset=UTF-8
|
|
|
4a2fec |
Content-Transfer-Encoding: 8bit
|
|
|
4a2fec |
|
|
|
4a2fec |
RH-Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
4a2fec |
Message-id: <20180205111012.6210-16-berrange@redhat.com>
|
|
|
4a2fec |
Patchwork-id: 78892
|
|
|
4a2fec |
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 15/17] ui: mix misleading comments & return types of VNC I/O helper methods
|
|
|
4a2fec |
Bugzilla: 1527404
|
|
|
4a2fec |
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
While the QIOChannel APIs for reading/writing data return ssize_t, with negative
|
|
|
4a2fec |
value indicating an error, the VNC code passes this return value through the
|
|
|
4a2fec |
vnc_client_io_error() method. This detects the error condition, disconnects the
|
|
|
4a2fec |
client and returns 0 to indicate error. Thus all the VNC helper methods should
|
|
|
4a2fec |
return size_t (unsigned), and misleading comments which refer to the possibility
|
|
|
4a2fec |
of negative return values need fixing.
|
|
|
4a2fec |
|
|
|
4a2fec |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
4a2fec |
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
|
|
|
4a2fec |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
4a2fec |
Message-id: 20171218191228.31018-14-berrange@redhat.com
|
|
|
4a2fec |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
4a2fec |
(cherry picked from commit 30b80fd5269257f55203b7072c505b4ebaab5115)
|
|
|
4a2fec |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
4a2fec |
---
|
|
|
4a2fec |
ui/vnc-auth-sasl.c | 8 ++++----
|
|
|
4a2fec |
ui/vnc-auth-sasl.h | 4 ++--
|
|
|
4a2fec |
ui/vnc.c | 29 +++++++++++++++--------------
|
|
|
4a2fec |
ui/vnc.h | 6 +++---
|
|
|
4a2fec |
4 files changed, 24 insertions(+), 23 deletions(-)
|
|
|
4a2fec |
|
|
|
4a2fec |
diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
|
|
|
4a2fec |
index 8c1cdde..74a5f51 100644
|
|
|
4a2fec |
--- a/ui/vnc-auth-sasl.c
|
|
|
4a2fec |
+++ b/ui/vnc-auth-sasl.c
|
|
|
4a2fec |
@@ -48,9 +48,9 @@ void vnc_sasl_client_cleanup(VncState *vs)
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
|
|
|
4a2fec |
-long vnc_client_write_sasl(VncState *vs)
|
|
|
4a2fec |
+size_t vnc_client_write_sasl(VncState *vs)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
- long ret;
|
|
|
4a2fec |
+ size_t ret;
|
|
|
4a2fec |
|
|
|
4a2fec |
VNC_DEBUG("Write SASL: Pending output %p size %zd offset %zd "
|
|
|
4a2fec |
"Encoded: %p size %d offset %d\n",
|
|
|
4a2fec |
@@ -106,9 +106,9 @@ long vnc_client_write_sasl(VncState *vs)
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
|
|
|
4a2fec |
-long vnc_client_read_sasl(VncState *vs)
|
|
|
4a2fec |
+size_t vnc_client_read_sasl(VncState *vs)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
- long ret;
|
|
|
4a2fec |
+ size_t ret;
|
|
|
4a2fec |
uint8_t encoded[4096];
|
|
|
4a2fec |
const char *decoded;
|
|
|
4a2fec |
unsigned int decodedLen;
|
|
|
4a2fec |
diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h
|
|
|
4a2fec |
index b9d8de1..2ae224e 100644
|
|
|
4a2fec |
--- a/ui/vnc-auth-sasl.h
|
|
|
4a2fec |
+++ b/ui/vnc-auth-sasl.h
|
|
|
4a2fec |
@@ -65,8 +65,8 @@ struct VncDisplaySASL {
|
|
|
4a2fec |
|
|
|
4a2fec |
void vnc_sasl_client_cleanup(VncState *vs);
|
|
|
4a2fec |
|
|
|
4a2fec |
-long vnc_client_read_sasl(VncState *vs);
|
|
|
4a2fec |
-long vnc_client_write_sasl(VncState *vs);
|
|
|
4a2fec |
+size_t vnc_client_read_sasl(VncState *vs);
|
|
|
4a2fec |
+size_t vnc_client_write_sasl(VncState *vs);
|
|
|
4a2fec |
|
|
|
4a2fec |
void start_auth_sasl(VncState *vs);
|
|
|
4a2fec |
|
|
|
4a2fec |
diff --git a/ui/vnc.c b/ui/vnc.c
|
|
|
4a2fec |
index 26f58bc..b303930 100644
|
|
|
4a2fec |
--- a/ui/vnc.c
|
|
|
4a2fec |
+++ b/ui/vnc.c
|
|
|
4a2fec |
@@ -1272,7 +1272,7 @@ void vnc_disconnect_finish(VncState *vs)
|
|
|
4a2fec |
g_free(vs);
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
-ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
|
|
|
4a2fec |
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
if (ret <= 0) {
|
|
|
4a2fec |
if (ret == 0) {
|
|
|
4a2fec |
@@ -1315,9 +1315,9 @@ void vnc_client_error(VncState *vs)
|
|
|
4a2fec |
*
|
|
|
4a2fec |
* Returns the number of bytes written, which may be less than
|
|
|
4a2fec |
* the requested 'datalen' if the socket would block. Returns
|
|
|
4a2fec |
- * -1 on error, and disconnects the client socket.
|
|
|
4a2fec |
+ * 0 on I/O error, and disconnects the client socket.
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
-ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
|
|
|
4a2fec |
+size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
Error *err = NULL;
|
|
|
4a2fec |
ssize_t ret;
|
|
|
4a2fec |
@@ -1335,13 +1335,13 @@ ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
|
|
|
4a2fec |
* will switch the FD poll() handler back to read monitoring.
|
|
|
4a2fec |
*
|
|
|
4a2fec |
* Returns the number of bytes written, which may be less than
|
|
|
4a2fec |
- * the buffered output data if the socket would block. Returns
|
|
|
4a2fec |
- * -1 on error, and disconnects the client socket.
|
|
|
4a2fec |
+ * the buffered output data if the socket would block. Returns
|
|
|
4a2fec |
+ * 0 on I/O error, and disconnects the client socket.
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
-static ssize_t vnc_client_write_plain(VncState *vs)
|
|
|
4a2fec |
+static size_t vnc_client_write_plain(VncState *vs)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
size_t offset;
|
|
|
4a2fec |
- ssize_t ret;
|
|
|
4a2fec |
+ size_t ret;
|
|
|
4a2fec |
|
|
|
4a2fec |
#ifdef CONFIG_VNC_SASL
|
|
|
4a2fec |
VNC_DEBUG("Write Plain: Pending output %p size %zd offset %zd. Wait SSF %d\n",
|
|
|
4a2fec |
@@ -1442,9 +1442,9 @@ void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
|
|
|
4a2fec |
*
|
|
|
4a2fec |
* Returns the number of bytes read, which may be less than
|
|
|
4a2fec |
* the requested 'datalen' if the socket would block. Returns
|
|
|
4a2fec |
- * -1 on error, and disconnects the client socket.
|
|
|
4a2fec |
+ * 0 on I/O error or EOF, and disconnects the client socket.
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
-ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
|
|
|
4a2fec |
+size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
ssize_t ret;
|
|
|
4a2fec |
Error *err = NULL;
|
|
|
4a2fec |
@@ -1460,12 +1460,13 @@ ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
|
|
|
4a2fec |
* when not using any SASL SSF encryption layers. Will read as much
|
|
|
4a2fec |
* data as possible without blocking.
|
|
|
4a2fec |
*
|
|
|
4a2fec |
- * Returns the number of bytes read. Returns -1 on error, and
|
|
|
4a2fec |
- * disconnects the client socket.
|
|
|
4a2fec |
+ * Returns the number of bytes read, which may be less than
|
|
|
4a2fec |
+ * the requested 'datalen' if the socket would block. Returns
|
|
|
4a2fec |
+ * 0 on I/O error or EOF, and disconnects the client socket.
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
-static ssize_t vnc_client_read_plain(VncState *vs)
|
|
|
4a2fec |
+static size_t vnc_client_read_plain(VncState *vs)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
- ssize_t ret;
|
|
|
4a2fec |
+ size_t ret;
|
|
|
4a2fec |
VNC_DEBUG("Read plain %p size %zd offset %zd\n",
|
|
|
4a2fec |
vs->input.buffer, vs->input.capacity, vs->input.offset);
|
|
|
4a2fec |
buffer_reserve(&vs->input, 4096);
|
|
|
4a2fec |
@@ -1491,7 +1492,7 @@ static void vnc_jobs_bh(void *opaque)
|
|
|
4a2fec |
*/
|
|
|
4a2fec |
static int vnc_client_read(VncState *vs)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
- ssize_t ret;
|
|
|
4a2fec |
+ size_t ret;
|
|
|
4a2fec |
|
|
|
4a2fec |
#ifdef CONFIG_VNC_SASL
|
|
|
4a2fec |
if (vs->sasl.conn && vs->sasl.runSSF)
|
|
|
4a2fec |
diff --git a/ui/vnc.h b/ui/vnc.h
|
|
|
4a2fec |
index 3f4cd4d..0c33a5f 100644
|
|
|
4a2fec |
--- a/ui/vnc.h
|
|
|
4a2fec |
+++ b/ui/vnc.h
|
|
|
4a2fec |
@@ -524,8 +524,8 @@ gboolean vnc_client_io(QIOChannel *ioc,
|
|
|
4a2fec |
GIOCondition condition,
|
|
|
4a2fec |
void *opaque);
|
|
|
4a2fec |
|
|
|
4a2fec |
-ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
|
|
|
4a2fec |
-ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen);
|
|
|
4a2fec |
+size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen);
|
|
|
4a2fec |
+size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen);
|
|
|
4a2fec |
|
|
|
4a2fec |
/* Protocol I/O functions */
|
|
|
4a2fec |
void vnc_write(VncState *vs, const void *data, size_t len);
|
|
|
4a2fec |
@@ -544,7 +544,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
|
|
|
4a2fec |
|
|
|
4a2fec |
/* Protocol stage functions */
|
|
|
4a2fec |
void vnc_client_error(VncState *vs);
|
|
|
4a2fec |
-ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
|
|
|
4a2fec |
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
|
|
|
4a2fec |
|
|
|
4a2fec |
void start_client_init(VncState *vs);
|
|
|
4a2fec |
void start_auth_vnc(VncState *vs);
|
|
|
4a2fec |
--
|
|
|
4a2fec |
1.8.3.1
|
|
|
4a2fec |
|