aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-10 10:53:09 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-10 10:53:09 +0200
commit5367faefd2490e09abed41f655c3db55d36752ad (patch)
tree1f9ed54dde8d31d72442bd1f2459156fafb071cc
parentc17de5d4c2699c6c5b4759f009ce8cb6560d2f13 (diff)
Cleanup: mark arguments const where possible
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/sqfs/dir.h9
-rw-r--r--include/sqfs/id_table.h3
-rw-r--r--include/sqfs/io.h2
-rw-r--r--include/sqfs/meta_reader.h5
-rw-r--r--include/sqfs/meta_writer.h2
-rw-r--r--include/sqfs/super.h2
-rw-r--r--lib/sqfs/dir_writer.c8
-rw-r--r--lib/sqfs/id_table.c2
-rw-r--r--lib/sqfs/io.c4
-rw-r--r--lib/sqfs/meta_reader.c4
-rw-r--r--lib/sqfs/read_inode.c3
-rw-r--r--lib/sqfs/super.c2
-rw-r--r--lib/sqfs/write_inode.c5
13 files changed, 28 insertions, 23 deletions
diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h
index 19c1289..ff53ce5 100644
--- a/include/sqfs/dir.h
+++ b/include/sqfs/dir.h
@@ -254,7 +254,7 @@ SQFS_API int sqfs_dir_writer_end(sqfs_dir_writer_t *writer);
*
* @return The size of the entire, uncompressed listing in bytes.
*/
-SQFS_API size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer);
+SQFS_API size_t sqfs_dir_writer_get_size(const sqfs_dir_writer_t *writer);
/**
* @brief Get the location of the last written directory.
@@ -269,7 +269,8 @@ SQFS_API size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer);
* @return A meta data reference, i.e. bits 16 to 48 contain the block start
* and the lower 16 bit an offset into the uncompressed block.
*/
-SQFS_API uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer);
+SQFS_API uint64_t
+sqfs_dir_writer_get_dir_reference(const sqfs_dir_writer_t *writer);
/**
* @brief Get the size of the index of the last written directory.
@@ -283,7 +284,7 @@ SQFS_API uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer);
*
* @return The number of index entries.
*/
-SQFS_API size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer);
+SQFS_API size_t sqfs_dir_writer_get_index_size(const sqfs_dir_writer_t *writer);
/**
* @brief Write the index of the index of the last written directory to
@@ -296,7 +297,7 @@ SQFS_API size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer);
*
* @return Zero on success, a @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer,
+SQFS_API int sqfs_dir_writer_write_index(const sqfs_dir_writer_t *writer,
sqfs_meta_writer_t *im);
#ifdef __cplusplus
diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h
index 6c39cf2..c9e6b9b 100644
--- a/include/sqfs/id_table.h
+++ b/include/sqfs/id_table.h
@@ -107,7 +107,8 @@ SQFS_API int sqfs_id_table_write(sqfs_id_table_t *tbl, sqfs_file_t *file,
* @return Zero on success, an @ref E_SQFS_ERROR on failure.
*/
SQFS_API int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
- sqfs_super_t *super, sqfs_compressor_t *cmp);
+ const sqfs_super_t *super,
+ sqfs_compressor_t *cmp);
/**
* @brief Resolve a 16 bit index to a 32 bit ID.
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index 9288010..0f980d6 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -105,7 +105,7 @@ struct sqfs_file_t {
*
* @param file A pointer to the file object.
*/
- uint64_t (*get_size)(sqfs_file_t *file);
+ uint64_t (*get_size)(const sqfs_file_t *file);
/**
* @brief Extend or shrink a file to a specified size.
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index 989e857..c03c0f6 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -104,7 +104,7 @@ SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
* @param block_start Absolute position where the current block is.
* @param offset A byte offset into the uncompressed block.
*/
-SQFS_API void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m,
+SQFS_API void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
uint64_t *block_start,
size_t *offset);
@@ -179,7 +179,8 @@ SQFS_API int sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m,
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
SQFS_API
-int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir, sqfs_super_t *super,
+int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
+ const sqfs_super_t *super,
uint64_t block_start, size_t offset,
sqfs_inode_generic_t **out);
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index c0d5716..c1b2383 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -176,7 +176,7 @@ SQFS_API int sqfs_meta_write_write_to_file(sqfs_meta_writer_t *m);
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
SQFS_API int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *iw,
- sqfs_inode_generic_t *n);
+ const sqfs_inode_generic_t *n);
#ifdef __cplusplus
}
diff --git a/include/sqfs/super.h b/include/sqfs/super.h
index 5e6c00a..aea2394 100644
--- a/include/sqfs/super.h
+++ b/include/sqfs/super.h
@@ -301,7 +301,7 @@ SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size,
* @return Zero on success, an @ref E_SQFS_ERROR value if one of the
* fields does not hold a valid value.
*/
-SQFS_API int sqfs_super_write(sqfs_super_t *super, sqfs_file_t *file);
+SQFS_API int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file);
/**
* @brief Read a SquashFS super block from disk, decode it and check the fields
diff --git a/lib/sqfs/dir_writer.c b/lib/sqfs/dir_writer.c
index 70c035e..d7bb590 100644
--- a/lib/sqfs/dir_writer.c
+++ b/lib/sqfs/dir_writer.c
@@ -260,22 +260,22 @@ int sqfs_dir_writer_end(sqfs_dir_writer_t *writer)
return 0;
}
-size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer)
+size_t sqfs_dir_writer_get_size(const sqfs_dir_writer_t *writer)
{
return writer->dir_size;
}
-uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer)
+uint64_t sqfs_dir_writer_get_dir_reference(const sqfs_dir_writer_t *writer)
{
return writer->dir_ref;
}
-size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer)
+size_t sqfs_dir_writer_get_index_size(const sqfs_dir_writer_t *writer)
{
return writer->idx_size;
}
-int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer,
+int sqfs_dir_writer_write_index(const sqfs_dir_writer_t *writer,
sqfs_meta_writer_t *im)
{
sqfs_dir_index_t ent;
diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c
index 55477dc..a365a5f 100644
--- a/lib/sqfs/id_table.c
+++ b/lib/sqfs/id_table.c
@@ -74,7 +74,7 @@ int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index,
}
int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
- sqfs_super_t *super, sqfs_compressor_t *cmp)
+ const sqfs_super_t *super, sqfs_compressor_t *cmp)
{
uint64_t upper_limit, lower_limit;
void *raw_ids;
diff --git a/lib/sqfs/io.c b/lib/sqfs/io.c
index d0b2558..f8773d0 100644
--- a/lib/sqfs/io.c
+++ b/lib/sqfs/io.c
@@ -87,9 +87,9 @@ static int stdio_write_at(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static uint64_t stdio_get_size(sqfs_file_t *base)
+static uint64_t stdio_get_size(const sqfs_file_t *base)
{
- sqfs_file_stdio_t *file = (sqfs_file_stdio_t *)base;
+ const sqfs_file_stdio_t *file = (const sqfs_file_stdio_t *)base;
return file->size;
}
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index 72d8db1..08ac28d 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -126,8 +126,8 @@ int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
return 0;
}
-void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m, uint64_t *block_start,
- size_t *offset)
+void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
+ uint64_t *block_start, size_t *offset)
{
*block_start = m->block_offset;
*offset = m->offset;
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c
index 3efb1d8..5a87a45 100644
--- a/lib/sqfs/read_inode.c
+++ b/lib/sqfs/read_inode.c
@@ -223,7 +223,8 @@ static int read_inode_slink_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
return 0;
}
-int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir, sqfs_super_t *super,
+int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
+ const sqfs_super_t *super,
uint64_t block_start, size_t offset,
sqfs_inode_generic_t **result)
{
diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c
index 10d911b..ad42c9f 100644
--- a/lib/sqfs/super.c
+++ b/lib/sqfs/super.c
@@ -49,7 +49,7 @@ int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
return 0;
}
-int sqfs_super_write(sqfs_super_t *super, sqfs_file_t *file)
+int sqfs_super_write(const sqfs_super_t *super, sqfs_file_t *file)
{
sqfs_super_t copy;
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index 6e36544..e64e6a6 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -11,7 +11,8 @@
#include "sqfs/error.h"
#include "sqfs/inode.h"
-static int write_block_sizes(sqfs_meta_writer_t *ir, sqfs_inode_generic_t *n)
+static int write_block_sizes(sqfs_meta_writer_t *ir,
+ const sqfs_inode_generic_t *n)
{
uint32_t sizes[n->num_file_blocks];
size_t i;
@@ -24,7 +25,7 @@ static int write_block_sizes(sqfs_meta_writer_t *ir, sqfs_inode_generic_t *n)
}
int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
- sqfs_inode_generic_t *n)
+ const sqfs_inode_generic_t *n)
{
sqfs_inode_t base;
int ret;