From bcb94f966e4aeca2a9619b87dfe96d546fde16c6 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 10 Jul 2018 21:27:43 +0100 Subject: [PATCH] Make compression functions return void. The return value wasn't used to indicate failure; it only indicated whether any compression was being done at all or whether the compression method was ssh_comp_none, and we can tell the latter just as well by the fact that its init function returns a null context pointer. --- ssh.c | 10 +++++++--- ssh.h | 8 ++++---- ssh2bpp.c | 20 +++++++++----------- sshzlib.c | 6 ++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ssh.c b/ssh.c index dd564c92..369fbf35 100644 --- a/ssh.c +++ b/ssh.c @@ -341,8 +341,12 @@ static void *ssh_comp_none_init(void) static void ssh_comp_none_cleanup(void *handle) { } -static int ssh_comp_none_block(void *handle, unsigned char *block, int len, - unsigned char **outblock, int *outlen) +static void ssh_comp_none_block(void *handle, unsigned char *block, int len, + unsigned char **outblock, int *outlen) +{ +} +static int ssh_decomp_none_block(void *handle, unsigned char *block, int len, + unsigned char **outblock, int *outlen) { return 0; } @@ -353,7 +357,7 @@ static int ssh_comp_none_disable(void *handle) const static struct ssh_compress ssh_comp_none = { "none", NULL, ssh_comp_none_init, ssh_comp_none_cleanup, ssh_comp_none_block, - ssh_comp_none_init, ssh_comp_none_cleanup, ssh_comp_none_block, + ssh_comp_none_init, ssh_comp_none_cleanup, ssh_decomp_none_block, ssh_comp_none_disable, NULL }; extern const struct ssh_compress ssh_zlib; diff --git a/ssh.h b/ssh.h index f00c7e99..5620af02 100644 --- a/ssh.h +++ b/ssh.h @@ -560,8 +560,8 @@ struct ssh_compress { const char *delayed_name; void *(*compress_init) (void); void (*compress_cleanup) (void *); - int (*compress) (void *, unsigned char *block, int len, - unsigned char **outblock, int *outlen); + void (*compress) (void *, unsigned char *block, int len, + unsigned char **outblock, int *outlen); void *(*decompress_init) (void); void (*decompress_cleanup) (void *); int (*decompress) (void *, unsigned char *block, int len, @@ -981,8 +981,8 @@ void *zlib_compress_init(void); void zlib_compress_cleanup(void *); void *zlib_decompress_init(void); void zlib_decompress_cleanup(void *); -int zlib_compress_block(void *, unsigned char *block, int len, - unsigned char **outblock, int *outlen); +void zlib_compress_block(void *, unsigned char *block, int len, + unsigned char **outblock, int *outlen); int zlib_decompress_block(void *, unsigned char *block, int len, unsigned char **outblock, int *outlen); diff --git a/ssh2bpp.c b/ssh2bpp.c index ef007024..e6e9975f 100644 --- a/ssh2bpp.c +++ b/ssh2bpp.c @@ -537,19 +537,17 @@ static void ssh2_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt) pkt->downstream_id, pkt->additional_log_text); } - /* - * Compress packet payload. - */ - { + if (s->out.comp && s->out.comp_ctx) { unsigned char *newpayload; int newlen; - if (s->out.comp && s->out.comp->compress( - s->out.comp_ctx, pkt->data + 5, pkt->length - 5, - &newpayload, &newlen)) { - pkt->length = 5; - put_data(pkt, newpayload, newlen); - sfree(newpayload); - } + /* + * Compress packet payload. + */ + s->out.comp->compress(s->out.comp_ctx, pkt->data + 5, pkt->length - 5, + &newpayload, &newlen); + pkt->length = 5; + put_data(pkt, newpayload, newlen); + sfree(newpayload); } /* diff --git a/sshzlib.c b/sshzlib.c index 855ddd86..290e6fe4 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -679,8 +679,8 @@ static int zlib_disable_compression(void *handle) return n; } -int zlib_compress_block(void *handle, unsigned char *block, int len, - unsigned char **outblock, int *outlen) +void zlib_compress_block(void *handle, unsigned char *block, int len, + unsigned char **outblock, int *outlen) { struct LZ77Context *ectx = (struct LZ77Context *)handle; struct Outbuf *out = (struct Outbuf *) ectx->userdata; @@ -796,8 +796,6 @@ int zlib_compress_block(void *handle, unsigned char *block, int len, *outblock = out->outbuf; *outlen = out->outlen; - - return 1; } /* ----------------------------------------------------------------------