Skip to content

Commit

Permalink
lz4: fix compression/decompression signedness mismatch
Browse files Browse the repository at this point in the history
LZ4 compression and decompression functions require different in
signedness input/output parameters: unsigned char for compression and
signed char for decompression.

Change decompression API to require "(const) unsigned char *".

Signed-off-by: Sergey Senozhatsky <[email protected]>
Cc: Kyungsik Lee <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Yann Collet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sergey-senozhatsky authored and torvalds committed Sep 11, 2013
1 parent 20b8875 commit b34081f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions include/linux/lz4.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ int lz4hc_compress(const unsigned char *src, size_t src_len,
* note : Destination buffer must be already allocated.
* slightly faster than lz4_decompress_unknownoutputsize()
*/
int lz4_decompress(const char *src, size_t *src_len, char *dest,
size_t actual_dest_len);
int lz4_decompress(const unsigned char *src, size_t *src_len,
unsigned char *dest, size_t actual_dest_len);

/*
* lz4_decompress_unknownoutputsize()
Expand All @@ -82,6 +82,6 @@ int lz4_decompress(const char *src, size_t *src_len, char *dest,
* Error if return (< 0)
* note : Destination buffer must be already allocated.
*/
int lz4_decompress_unknownoutputsize(const char *src, size_t src_len,
char *dest, size_t *dest_len);
int lz4_decompress_unknownoutputsize(const unsigned char *src, size_t src_len,
unsigned char *dest, size_t *dest_len);
#endif
8 changes: 4 additions & 4 deletions lib/lz4/lz4_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
return (int) (-(((char *) ip) - source));
}

int lz4_decompress(const char *src, size_t *src_len, char *dest,
size_t actual_dest_len)
int lz4_decompress(const unsigned char *src, size_t *src_len,
unsigned char *dest, size_t actual_dest_len)
{
int ret = -1;
int input_len = 0;
Expand All @@ -302,8 +302,8 @@ int lz4_decompress(const char *src, size_t *src_len, char *dest,
EXPORT_SYMBOL(lz4_decompress);
#endif

int lz4_decompress_unknownoutputsize(const char *src, size_t src_len,
char *dest, size_t *dest_len)
int lz4_decompress_unknownoutputsize(const unsigned char *src, size_t src_len,
unsigned char *dest, size_t *dest_len)
{
int ret = -1;
int out_len = 0;
Expand Down

0 comments on commit b34081f

Please sign in to comment.