From 7453bc8f4472cd41e90cf72cfdbbce3d5fa10140 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 2 Apr 2018 15:04:03 -0400 Subject: [PATCH] GUACAMOLE-269: Clean up logging and comments, and simplify code. --- src/protocols/ssh/ssh.c | 4 ++-- src/protocols/ssh/ttymode.c | 5 +---- src/protocols/ssh/ttymode.h | 8 ++++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index dca62084..1a7e6ef1 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -303,8 +303,8 @@ void* ssh_client_thread(void* data) { int ttymodeBytes = guac_ssh_ttymodes_init(ssh_ttymodes, GUAC_SSH_TTY_OP_VERASE, settings->backspace, GUAC_SSH_TTY_OP_END); if (ttymodeBytes < 1) - guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Error storing TTY mode encoding \ - opcodes and values in array."); + guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to set TTY modes." + " Backspace may not work as expected."); /* Request PTY */ if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1, diff --git a/src/protocols/ssh/ttymode.c b/src/protocols/ssh/ttymode.c index 686cbbd3..e6731b4a 100644 --- a/src/protocols/ssh/ttymode.c +++ b/src/protocols/ssh/ttymode.c @@ -33,7 +33,6 @@ int guac_ssh_ttymodes_init(char opcode_array[], ...) { /* Initialize array pointer and byte counter. */ char *current = opcode_array; - int bytes = 0; /* Loop through variable argument list. */ while (true) { @@ -41,7 +40,6 @@ int guac_ssh_ttymodes_init(char opcode_array[], ...) { /* Next argument should be an opcode. */ char opcode = (char)va_arg(args, int); *(current++) = opcode; - bytes += sizeof(char); /* If it's the end opcode, we're done. */ if (opcode == GUAC_SSH_TTY_OP_END) @@ -53,12 +51,11 @@ int guac_ssh_ttymodes_init(char opcode_array[], ...) { *(current++) = (value >> 16) & 0xFF; *(current++) = (value >> 8) & 0xFF; *(current++) = value & 0xFF; - bytes += sizeof(uint32_t); } /* We're done processing arguments. */ va_end(args); - return bytes; + return current - opcode_array; } diff --git a/src/protocols/ssh/ttymode.h b/src/protocols/ssh/ttymode.h index 648d13e4..92e081b3 100644 --- a/src/protocols/ssh/ttymode.h +++ b/src/protocols/ssh/ttymode.h @@ -50,6 +50,14 @@ * to pass a given number of opcodes, which calculates * the size of the number of opcodes plus the single byte * end opcode. + * + * @param num_opcodes + * The number of opcodes for which a size in bytes + * should be calculated. + * + * @returns + * The number of bytes that the given number of + * opcodes will require. */ #define GUAC_SSH_TTYMODES_SIZE(num_opcodes) ((GUAC_SSH_TTY_OPCODE_SIZE * num_opcodes) + 1)