GUACAMOLE-269: Clean up logging and comments, and simplify code.

This commit is contained in:
Nick Couchman 2018-04-02 15:04:03 -04:00
parent b441181c18
commit 7453bc8f44
3 changed files with 11 additions and 6 deletions

View File

@ -303,8 +303,8 @@ void* ssh_client_thread(void* data) {
int ttymodeBytes = guac_ssh_ttymodes_init(ssh_ttymodes, int ttymodeBytes = guac_ssh_ttymodes_init(ssh_ttymodes,
GUAC_SSH_TTY_OP_VERASE, settings->backspace, GUAC_SSH_TTY_OP_END); GUAC_SSH_TTY_OP_VERASE, settings->backspace, GUAC_SSH_TTY_OP_END);
if (ttymodeBytes < 1) if (ttymodeBytes < 1)
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Error storing TTY mode encoding \ guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to set TTY modes."
opcodes and values in array."); " Backspace may not work as expected.");
/* Request PTY */ /* Request PTY */
if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1, if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1,

View File

@ -33,7 +33,6 @@ int guac_ssh_ttymodes_init(char opcode_array[], ...) {
/* Initialize array pointer and byte counter. */ /* Initialize array pointer and byte counter. */
char *current = opcode_array; char *current = opcode_array;
int bytes = 0;
/* Loop through variable argument list. */ /* Loop through variable argument list. */
while (true) { while (true) {
@ -41,7 +40,6 @@ int guac_ssh_ttymodes_init(char opcode_array[], ...) {
/* Next argument should be an opcode. */ /* Next argument should be an opcode. */
char opcode = (char)va_arg(args, int); char opcode = (char)va_arg(args, int);
*(current++) = opcode; *(current++) = opcode;
bytes += sizeof(char);
/* If it's the end opcode, we're done. */ /* If it's the end opcode, we're done. */
if (opcode == GUAC_SSH_TTY_OP_END) 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 >> 16) & 0xFF;
*(current++) = (value >> 8) & 0xFF; *(current++) = (value >> 8) & 0xFF;
*(current++) = value & 0xFF; *(current++) = value & 0xFF;
bytes += sizeof(uint32_t);
} }
/* We're done processing arguments. */ /* We're done processing arguments. */
va_end(args); va_end(args);
return bytes; return current - opcode_array;
} }

View File

@ -50,6 +50,14 @@
* to pass a given number of opcodes, which calculates * to pass a given number of opcodes, which calculates
* the size of the number of opcodes plus the single byte * the size of the number of opcodes plus the single byte
* end opcode. * 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) #define GUAC_SSH_TTYMODES_SIZE(num_opcodes) ((GUAC_SSH_TTY_OPCODE_SIZE * num_opcodes) + 1)