aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-06-24 16:07:45 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-06-25 17:48:49 +0200
commita32b5a9c793e4f4a4577837b73e783386842db02 (patch)
tree314f42e3302a33a7d3da80689862bc6e1bce179c
parent3f887a1acc6129210d1ad4a484842bd411a85c7a (diff)
Remove casual un-const casting in various places
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/sqfs/predef.h6
-rw-r--r--lib/common/comp_lzo.c2
-rw-r--r--lib/common/hardlink.c2
-rw-r--r--lib/sqfs/comp/gzip.c4
-rw-r--r--lib/sqfs/comp/lz4.c6
-rw-r--r--lib/sqfs/inode.c4
-rw-r--r--lib/tar/number.c2
-rw-r--r--tests/rbtree.c2
8 files changed, 15 insertions, 13 deletions
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index 8a456d8..6296b4b 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -152,8 +152,10 @@ static SQFS_INLINE void sqfs_destroy(void *obj)
*/
static SQFS_INLINE void *sqfs_copy(const void *obj)
{
- if (((sqfs_object_t *)obj)->copy != NULL)
- return ((sqfs_object_t *)obj)->copy((sqfs_object_t *)obj);
+ if (((const sqfs_object_t *)obj)->copy != NULL) {
+ return ((const sqfs_object_t *)obj)->
+ copy((const sqfs_object_t *)obj);
+ }
return NULL;
}
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index b6496b2..e327d06 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -206,7 +206,7 @@ static void lzo_get_configuration(const sqfs_compressor_t *base,
static sqfs_object_t *lzo_create_copy(const sqfs_object_t *cmp)
{
- lzo_compressor_t *other = (lzo_compressor_t *)cmp;
+ const lzo_compressor_t *other = (const lzo_compressor_t *)cmp;
lzo_compressor_t *lzo;
lzo = calloc(1, sizeof(*lzo) + other->buf_size);
diff --git a/lib/common/hardlink.c b/lib/common/hardlink.c
index 63621a4..a3ba4f7 100644
--- a/lib/common/hardlink.c
+++ b/lib/common/hardlink.c
@@ -73,7 +73,7 @@ fail_insert:
static int compare_inum(const void *lhs, const void *rhs)
{
- sqfs_u32 l = *((sqfs_u32 *)lhs), r = *((sqfs_u32 *)rhs);
+ sqfs_u32 l = *((const sqfs_u32 *)lhs), r = *((const sqfs_u32 *)rhs);
return l < r ? -1 : (l > r ? 1 : 0);
}
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 9be84db..91cd87e 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -138,7 +138,7 @@ static int find_strategy(gzip_compressor_t *gzip, const sqfs_u8 *in,
strategy = flag_to_zlib_strategy(i);
- gzip->strm.next_in = (void *)in;
+ gzip->strm.next_in = (z_const Bytef *)in;
gzip->strm.avail_in = size;
gzip->strm.next_out = out;
gzip->strm.avail_out = outsize;
@@ -189,7 +189,7 @@ static sqfs_s32 gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
if (ret != Z_OK)
return SQFS_ERROR_COMPRESSOR;
- gzip->strm.next_in = (void *)in;
+ gzip->strm.next_in = (const void *)in;
gzip->strm.avail_in = size;
gzip->strm.next_out = out;
gzip->strm.avail_out = outsize;
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index f326870..152ae75 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -75,10 +75,10 @@ static sqfs_s32 lz4_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return SQFS_ERROR_ARG_INVALID;
if (lz4->high_compression) {
- ret = LZ4_compress_HC((void *)in, (void *)out,
+ ret = LZ4_compress_HC((const void *)in, (void *)out,
size, outsize, LZ4HC_CLEVEL_MAX);
} else {
- ret = LZ4_compress_default((void *)in, (void *)out,
+ ret = LZ4_compress_default((const void *)in, (void *)out,
size, outsize);
}
@@ -97,7 +97,7 @@ static sqfs_s32 lz4_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
if (outsize >= 0x7FFFFFFF)
return SQFS_ERROR_ARG_INVALID;
- ret = LZ4_decompress_safe((void *)in, (void *)out, size, outsize);
+ ret = LZ4_decompress_safe((const void *)in, (void *)out, size, outsize);
if (ret < 0)
return SQFS_ERROR_COMPRESSOR;
diff --git a/lib/sqfs/inode.c b/lib/sqfs/inode.c
index 02d23e2..01e5ebe 100644
--- a/lib/sqfs/inode.c
+++ b/lib/sqfs/inode.c
@@ -349,8 +349,8 @@ int sqfs_inode_unpack_dir_index_entry(const sqfs_inode_generic_t *inode,
size_t index)
{
sqfs_dir_index_t ent;
+ const char *ptr;
size_t offset;
- char *ptr;
if (inode->base.type != SQFS_INODE_EXT_DIR) {
if (inode->base.type == SQFS_INODE_DIR)
@@ -360,7 +360,7 @@ int sqfs_inode_unpack_dir_index_entry(const sqfs_inode_generic_t *inode,
}
offset = 0;
- ptr = (char *)inode->extra;
+ ptr = (const char *)inode->extra;
for (;;) {
if (offset >= inode->payload_bytes_used)
diff --git a/lib/tar/number.c b/lib/tar/number.c
index 06d5317..50cb658 100644
--- a/lib/tar/number.c
+++ b/lib/tar/number.c
@@ -69,7 +69,7 @@ fail_ov:
int read_number(const char *str, int digits, sqfs_u64 *out)
{
- if (*((unsigned char *)str) & 0x80)
+ if (*((const unsigned char *)str) & 0x80)
return read_binary(str, digits, out);
return read_octal(str, digits, out);
diff --git a/tests/rbtree.c b/tests/rbtree.c
index fc607a5..26f3ac1 100644
--- a/tests/rbtree.c
+++ b/tests/rbtree.c
@@ -11,7 +11,7 @@
static int key_compare(const void *a, const void *b)
{
- return *((sqfs_s32 *)a) - *((sqfs_s32 *)b);
+ return *((const sqfs_s32 *)a) - *((const sqfs_s32 *)b);
}
static size_t count_nodes_dfs(rbtree_node_t *n)