1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

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.
This commit is contained in:
Simon Tatham 2018-07-10 21:27:43 +01:00
parent 445fa12da7
commit bcb94f966e
4 changed files with 22 additions and 22 deletions

10
ssh.c
View File

@ -341,8 +341,12 @@ static void *ssh_comp_none_init(void)
static void ssh_comp_none_cleanup(void *handle) static void ssh_comp_none_cleanup(void *handle)
{ {
} }
static int ssh_comp_none_block(void *handle, unsigned char *block, int len, static void ssh_comp_none_block(void *handle, unsigned char *block, int len,
unsigned char **outblock, int *outlen) 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; return 0;
} }
@ -353,7 +357,7 @@ static int ssh_comp_none_disable(void *handle)
const static struct ssh_compress ssh_comp_none = { const static struct ssh_compress ssh_comp_none = {
"none", NULL, "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_comp_none_block, ssh_comp_none_init, ssh_comp_none_cleanup, ssh_decomp_none_block,
ssh_comp_none_disable, NULL ssh_comp_none_disable, NULL
}; };
extern const struct ssh_compress ssh_zlib; extern const struct ssh_compress ssh_zlib;

8
ssh.h
View File

@ -560,8 +560,8 @@ struct ssh_compress {
const char *delayed_name; const char *delayed_name;
void *(*compress_init) (void); void *(*compress_init) (void);
void (*compress_cleanup) (void *); void (*compress_cleanup) (void *);
int (*compress) (void *, unsigned char *block, int len, void (*compress) (void *, unsigned char *block, int len,
unsigned char **outblock, int *outlen); unsigned char **outblock, int *outlen);
void *(*decompress_init) (void); void *(*decompress_init) (void);
void (*decompress_cleanup) (void *); void (*decompress_cleanup) (void *);
int (*decompress) (void *, unsigned char *block, int len, int (*decompress) (void *, unsigned char *block, int len,
@ -981,8 +981,8 @@ void *zlib_compress_init(void);
void zlib_compress_cleanup(void *); void zlib_compress_cleanup(void *);
void *zlib_decompress_init(void); void *zlib_decompress_init(void);
void zlib_decompress_cleanup(void *); void zlib_decompress_cleanup(void *);
int zlib_compress_block(void *, unsigned char *block, int len, void zlib_compress_block(void *, unsigned char *block, int len,
unsigned char **outblock, int *outlen); unsigned char **outblock, int *outlen);
int zlib_decompress_block(void *, unsigned char *block, int len, int zlib_decompress_block(void *, unsigned char *block, int len,
unsigned char **outblock, int *outlen); unsigned char **outblock, int *outlen);

View File

@ -537,19 +537,17 @@ static void ssh2_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt)
pkt->downstream_id, pkt->additional_log_text); pkt->downstream_id, pkt->additional_log_text);
} }
/* if (s->out.comp && s->out.comp_ctx) {
* Compress packet payload.
*/
{
unsigned char *newpayload; unsigned char *newpayload;
int newlen; int newlen;
if (s->out.comp && s->out.comp->compress( /*
s->out.comp_ctx, pkt->data + 5, pkt->length - 5, * Compress packet payload.
&newpayload, &newlen)) { */
pkt->length = 5; s->out.comp->compress(s->out.comp_ctx, pkt->data + 5, pkt->length - 5,
put_data(pkt, newpayload, newlen); &newpayload, &newlen);
sfree(newpayload); pkt->length = 5;
} put_data(pkt, newpayload, newlen);
sfree(newpayload);
} }
/* /*

View File

@ -679,8 +679,8 @@ static int zlib_disable_compression(void *handle)
return n; return n;
} }
int zlib_compress_block(void *handle, unsigned char *block, int len, void zlib_compress_block(void *handle, unsigned char *block, int len,
unsigned char **outblock, int *outlen) unsigned char **outblock, int *outlen)
{ {
struct LZ77Context *ectx = (struct LZ77Context *)handle; struct LZ77Context *ectx = (struct LZ77Context *)handle;
struct Outbuf *out = (struct Outbuf *) ectx->userdata; 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; *outblock = out->outbuf;
*outlen = out->outlen; *outlen = out->outlen;
return 1;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------