aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-24 16:36:20 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-24 16:47:49 +0100
commit162142b7930248d83a77e8d8f4eba5896d5b267a (patch)
treef65796333f80b4f710a19f5fcb6770d6aedbafe6 /lib/sqfs
parentdea3b64dd11a3a3391bd9d8f8c26f20392e7eb3c (diff)
Cleanup libsquashfs invalid argument error codes
- Add an explicit "you're holding it wrong" error code. - Consistently return error codes and not have some special places where -1 is returned. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/comp/compressor.c2
-rw-r--r--lib/sqfs/comp/gzip.c2
-rw-r--r--lib/sqfs/comp/lz4.c4
-rw-r--r--lib/sqfs/comp/lzma.c4
-rw-r--r--lib/sqfs/comp/xz.c4
-rw-r--r--lib/sqfs/comp/zstd.c4
-rw-r--r--lib/sqfs/dir_writer.c2
-rw-r--r--lib/sqfs/xattr.c3
8 files changed, 13 insertions, 12 deletions
diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c
index c835f3f..0b8b5e9 100644
--- a/lib/sqfs/comp/compressor.c
+++ b/lib/sqfs/comp/compressor.c
@@ -141,7 +141,7 @@ int sqfs_compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out)
}
}
- return -1;
+ return SQFS_ERROR_UNSUPPORTED;
}
int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg,
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 3886e60..7183e5a 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -156,7 +156,7 @@ static sqfs_s32 gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
size_t written;
if (size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
if (gzip->compress && gzip->opt.strategies != 0) {
strategy = find_strategy(gzip, in, size, out, outsize);
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index dcee7d8..dd9b6ac 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -66,7 +66,7 @@ static sqfs_s32 lz4_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
int ret;
if (size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
if (lz4->high_compression) {
ret = LZ4_compress_HC((void *)in, (void *)out,
@@ -89,7 +89,7 @@ static sqfs_s32 lz4_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
(void)base;
if (outsize >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
ret = LZ4_decompress_safe((void *)in, (void *)out, size, outsize);
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 002376f..f7ab428 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -48,7 +48,7 @@ static sqfs_s32 lzma_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
int ret;
if (outsize < LZMA_HEADER_SIZE || size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
lzma_lzma_preset(&opt, LZMA_DEFAULT_LEVEL);
opt.dict_size = lzma->block_size;
@@ -93,7 +93,7 @@ static sqfs_s32 lzma_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
(void)base;
if (size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
if (size < sizeof(lzma_header))
return SQFS_ERROR_CORRUPTED;
diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c
index fd0f70b..91d48da 100644
--- a/lib/sqfs/comp/xz.c
+++ b/lib/sqfs/comp/xz.c
@@ -144,7 +144,7 @@ static sqfs_s32 xz_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
size_t i;
if (size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
ret = compress(xz, LZMA_VLI_UNKNOWN, in, size, out, outsize);
if (ret < 0 || xz->flags == 0)
@@ -184,7 +184,7 @@ static sqfs_s32 xz_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
(void)base;
if (outsize >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
ret = lzma_stream_buffer_decode(&memlimit, 0, NULL,
in, &src_pos, size,
diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c
index b2e5d8b..3fac85f 100644
--- a/lib/sqfs/comp/zstd.c
+++ b/lib/sqfs/comp/zstd.c
@@ -58,7 +58,7 @@ static sqfs_s32 zstd_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
size_t ret;
if (size >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
ret = ZSTD_compressCCtx(zstd->zctx, out, outsize, in, size,
zstd->level);
@@ -76,7 +76,7 @@ static sqfs_s32 zstd_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
(void)base;
if (outsize >= 0x7FFFFFFF)
- return 0;
+ return SQFS_ERROR_ARG_INVALID;
ret = ZSTD_decompress(out, outsize, in, size);
diff --git a/lib/sqfs/dir_writer.c b/lib/sqfs/dir_writer.c
index 8703b77..673c103 100644
--- a/lib/sqfs/dir_writer.c
+++ b/lib/sqfs/dir_writer.c
@@ -130,7 +130,7 @@ int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer, const char *name,
return type;
if (name[0] == '\0')
- return SQFS_ERROR_CORRUPTED;
+ return SQFS_ERROR_ARG_INVALID;
ent = alloc_flex(sizeof(*ent), 1, strlen(name));
if (ent == NULL)
diff --git a/lib/sqfs/xattr.c b/lib/sqfs/xattr.c
index 6ce6b9a..909a9a5 100644
--- a/lib/sqfs/xattr.c
+++ b/lib/sqfs/xattr.c
@@ -7,6 +7,7 @@
#define SQFS_BUILDING_DLL
#include "config.h"
#include "sqfs/xattr.h"
+#include "sqfs/error.h"
#include <string.h>
@@ -32,7 +33,7 @@ int sqfs_get_xattr_prefix_id(const char *key)
}
}
- return -1;
+ return SQFS_ERROR_UNSUPPORTED;
}
const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id)