aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfshelper
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:15:40 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:15:40 +0200
commit40232f4bd4d7e8e001f7d1e8f120606f59b2c147 (patch)
tree5d763f4f22a487fd2e669efe0970615096f1f5fd /lib/sqfshelper
parentf6904a98bffe0bce5fc6aac408c141a25c0e05ab (diff)
Cleanup: replace fixed with data types with typedefs
This is a fully automated search and replace, i.e. I ran this: git grep -l uint8_t | xargs sed -i 's/uint8_t/sqfs_u8/g' git grep -l uint16_t | xargs sed -i 's/uint16_t/sqfs_u16/g' git grep -l uint32_t | xargs sed -i 's/uint32_t/sqfs_u32/g' git grep -l uint64_t | xargs sed -i 's/uint64_t/sqfs_u64/g' git grep -l int8_t | xargs sed -i 's/int8_t/sqfs_s8/g' git grep -l int16_t | xargs sed -i 's/int16_t/sqfs_s16/g' git grep -l int32_t | xargs sed -i 's/int32_t/sqfs_s32/g' git grep -l int64_t | xargs sed -i 's/int64_t/sqfs_s64/g' and than added the appropriate definitions to sqfs/predef.h The whole point being better compatibillity with platforms that may not have an stdint.h with the propper definitions. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r--lib/sqfshelper/comp_opt.c4
-rw-r--r--lib/sqfshelper/data_reader_dump.c2
-rw-r--r--lib/sqfshelper/data_writer.c4
-rw-r--r--lib/sqfshelper/io_stdin.c24
-rw-r--r--lib/sqfshelper/serialize_fstree.c6
-rw-r--r--lib/sqfshelper/statistics.c2
-rw-r--r--lib/sqfshelper/tree_node_to_inode.c4
-rw-r--r--lib/sqfshelper/write_export_table.c6
-rw-r--r--lib/sqfshelper/write_xattr.c30
9 files changed, 41 insertions, 41 deletions
diff --git a/lib/sqfshelper/comp_opt.c b/lib/sqfshelper/comp_opt.c
index c942d23..fa4157b 100644
--- a/lib/sqfshelper/comp_opt.c
+++ b/lib/sqfshelper/comp_opt.c
@@ -15,7 +15,7 @@
typedef struct {
const char *name;
- uint16_t flag;
+ sqfs_u16 flag;
} flag_t;
static const flag_t gzip_flags[] = {
@@ -76,7 +76,7 @@ static int find_lzo_alg(sqfs_compressor_config_t *cfg, const char *name)
return -1;
}
-static int get_size_value(const char *value, uint32_t *out, uint32_t block_size)
+static int get_size_value(const char *value, sqfs_u32 *out, sqfs_u32 block_size)
{
int i;
diff --git a/lib/sqfshelper/data_reader_dump.c b/lib/sqfshelper/data_reader_dump.c
index 5675469..160f7f0 100644
--- a/lib/sqfshelper/data_reader_dump.c
+++ b/lib/sqfshelper/data_reader_dump.c
@@ -21,7 +21,7 @@ int sqfs_data_reader_dump(sqfs_data_reader_t *data,
int outfd, size_t block_size, bool allow_sparse)
{
sqfs_block_t *blk;
- uint64_t filesz;
+ sqfs_u64 filesz;
size_t i, diff;
int err;
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c
index d9e11a6..aa51b26 100644
--- a/lib/sqfshelper/data_writer.c
+++ b/lib/sqfshelper/data_writer.c
@@ -9,12 +9,12 @@
#include "highlevel.h"
#include "util.h"
-static uint8_t buffer[4096];
+static sqfs_u8 buffer[4096];
int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode,
sqfs_file_t *file, int flags)
{
- uint64_t filesz, offset;
+ sqfs_u64 filesz, offset;
size_t diff;
int ret;
diff --git a/lib/sqfshelper/io_stdin.c b/lib/sqfshelper/io_stdin.c
index 8568f5e..fec8db7 100644
--- a/lib/sqfshelper/io_stdin.c
+++ b/lib/sqfshelper/io_stdin.c
@@ -19,8 +19,8 @@ typedef struct {
sqfs_file_t base;
const sparse_map_t *map;
- uint64_t offset;
- uint64_t size;
+ sqfs_u64 offset;
+ sqfs_u64 size;
} sqfs_file_stdin_t;
@@ -29,13 +29,13 @@ static void stdin_destroy(sqfs_file_t *base)
free(base);
}
-static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
+static int stdin_read_at(sqfs_file_t *base, sqfs_u64 offset,
void *buffer, size_t size)
{
sqfs_file_stdin_t *file = (sqfs_file_stdin_t *)base;
size_t temp_size = 0;
- uint8_t *temp = NULL;
- uint64_t diff;
+ sqfs_u8 *temp = NULL;
+ sqfs_u64 diff;
ssize_t ret;
if (offset < file->offset)
@@ -52,7 +52,7 @@ static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
while (size > 0) {
if (offset > file->offset) {
diff = file->offset - offset;
- diff = diff > (uint64_t)temp_size ? temp_size : diff;
+ diff = diff > (sqfs_u64)temp_size ? temp_size : diff;
ret = read(STDIN_FILENO, temp, diff);
} else {
@@ -80,11 +80,11 @@ static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static int stdin_read_condensed(sqfs_file_t *base, uint64_t offset,
+static int stdin_read_condensed(sqfs_file_t *base, sqfs_u64 offset,
void *buffer, size_t size)
{
sqfs_file_stdin_t *file = (sqfs_file_stdin_t *)base;
- uint64_t poffset = 0, src_start;
+ sqfs_u64 poffset = 0, src_start;
size_t dst_start, diff, count;
const sparse_map_t *it;
int err;
@@ -134,25 +134,25 @@ static int stdin_read_condensed(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static int stdin_write_at(sqfs_file_t *base, uint64_t offset,
+static int stdin_write_at(sqfs_file_t *base, sqfs_u64 offset,
const void *buffer, size_t size)
{
(void)base; (void)offset; (void)buffer; (void)size;
return SQFS_ERROR_IO;
}
-static uint64_t stdin_get_size(const sqfs_file_t *base)
+static sqfs_u64 stdin_get_size(const sqfs_file_t *base)
{
return ((const sqfs_file_stdin_t *)base)->size;
}
-static int stdin_truncate(sqfs_file_t *base, uint64_t size)
+static int stdin_truncate(sqfs_file_t *base, sqfs_u64 size)
{
(void)base; (void)size;
return SQFS_ERROR_IO;
}
-sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, uint64_t size)
+sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, sqfs_u64 size)
{
sqfs_file_stdin_t *file = calloc(1, sizeof(*file));
sqfs_file_t *base = (sqfs_file_t *)file;
diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c
index 296f123..2ec7daa 100644
--- a/lib/sqfshelper/serialize_fstree.c
+++ b/lib/sqfshelper/serialize_fstree.c
@@ -18,7 +18,7 @@ static sqfs_inode_generic_t *write_dir_entries(sqfs_dir_writer_t *dirw,
tree_node_t *node,
sqfs_id_table_t *idtbl)
{
- uint32_t xattr, parent_inode;
+ sqfs_u32 xattr, parent_inode;
sqfs_inode_generic_t *inode;
tree_node_t *it;
int ret;
@@ -67,8 +67,8 @@ int sqfs_serialize_fstree(sqfs_file_t *file, sqfs_super_t *super, fstree_t *fs,
sqfs_inode_generic_t *inode;
sqfs_meta_writer_t *im, *dm;
sqfs_dir_writer_t *dirwr;
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
int ret = -1;
size_t i;
diff --git a/lib/sqfshelper/statistics.c b/lib/sqfshelper/statistics.c
index 26c121f..3f9f595 100644
--- a/lib/sqfshelper/statistics.c
+++ b/lib/sqfshelper/statistics.c
@@ -37,7 +37,7 @@ static void pre_fragment_store(void *user, sqfs_block_t *block)
stats->frag_count += 1;
}
-static void notify_blocks_erased(void *user, size_t count, uint64_t bytes)
+static void notify_blocks_erased(void *user, size_t count, sqfs_u64 bytes)
{
data_writer_stats_t *stats = user;
diff --git a/lib/sqfshelper/tree_node_to_inode.c b/lib/sqfshelper/tree_node_to_inode.c
index edcdee3..62a804d 100644
--- a/lib/sqfshelper/tree_node_to_inode.c
+++ b/lib/sqfshelper/tree_node_to_inode.c
@@ -47,8 +47,8 @@ sqfs_inode_generic_t *tree_node_to_inode(sqfs_id_table_t *idtbl,
tree_node_t *node)
{
sqfs_inode_generic_t *inode;
- uint16_t uid_idx, gid_idx;
- uint32_t xattr = 0xFFFFFFFF;
+ sqfs_u16 uid_idx, gid_idx;
+ sqfs_u32 xattr = 0xFFFFFFFF;
size_t extra = 0;
if (S_ISREG(node->mode)) {
diff --git a/lib/sqfshelper/write_export_table.c b/lib/sqfshelper/write_export_table.c
index b320381..566c509 100644
--- a/lib/sqfshelper/write_export_table.c
+++ b/lib/sqfshelper/write_export_table.c
@@ -15,14 +15,14 @@
int write_export_table(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
sqfs_compressor_t *cmp)
{
- uint64_t *table, start;
+ sqfs_u64 *table, start;
size_t i, size;
int ret;
if (fs->inode_tbl_size < 1)
return 0;
- table = alloc_array(sizeof(uint64_t), (fs->inode_tbl_size - 1));
+ table = alloc_array(sizeof(sqfs_u64), (fs->inode_tbl_size - 1));
if (table == NULL) {
perror("Allocating NFS export table");
@@ -37,7 +37,7 @@ int write_export_table(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
}
}
- size = sizeof(uint64_t) * (fs->inode_tbl_size - 1);
+ size = sizeof(sqfs_u64) * (fs->inode_tbl_size - 1);
ret = sqfs_write_table(file, cmp, table, size, &start);
super->export_table_start = start;
diff --git a/lib/sqfshelper/write_xattr.c b/lib/sqfshelper/write_xattr.c
index 8faa9ff..a3f5170 100644
--- a/lib/sqfshelper/write_xattr.c
+++ b/lib/sqfshelper/write_xattr.c
@@ -48,11 +48,11 @@ static int write_key(sqfs_meta_writer_t *mw, const char *key,
}
static int write_value(sqfs_meta_writer_t *mw, const char *value,
- tree_xattr_t *xattr, uint64_t *value_ref_out)
+ tree_xattr_t *xattr, sqfs_u64 *value_ref_out)
{
sqfs_xattr_value_t vent;
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
sqfs_meta_writer_get_position(mw, &block, &offset);
*value_ref_out = (block << 16) | (offset & 0xFFFF);
@@ -69,11 +69,11 @@ static int write_value(sqfs_meta_writer_t *mw, const char *value,
return 0;
}
-static int write_value_ool(sqfs_meta_writer_t *mw, uint64_t location,
+static int write_value_ool(sqfs_meta_writer_t *mw, sqfs_u64 location,
tree_xattr_t *xattr)
{
sqfs_xattr_value_t vent;
- uint64_t ref;
+ sqfs_u64 ref;
vent.size = htole32(sizeof(location));
if (sqfs_meta_writer_append(mw, &vent, sizeof(vent)))
@@ -109,15 +109,15 @@ static bool should_store_ool(fstree_t *fs, const char *value, size_t index)
Note that this only holds iff refcount - 1 != 0, i.e. refcount > 1,
otherwise we would be dividing by 0 in the 3rd step.
*/
- return strlen(value) > sizeof(uint64_t);
+ return strlen(value) > sizeof(sqfs_u64);
}
static int write_kv_pairs(fstree_t *fs, sqfs_meta_writer_t *mw,
- tree_xattr_t *xattr, uint64_t *ool_locations)
+ tree_xattr_t *xattr, sqfs_u64 *ool_locations)
{
- uint32_t key_idx, val_idx;
+ sqfs_u32 key_idx, val_idx;
const char *key, *value;
- uint64_t ref;
+ sqfs_u64 ref;
size_t i;
for (i = 0; i < xattr->num_attr; ++i) {
@@ -148,12 +148,12 @@ static int write_kv_pairs(fstree_t *fs, sqfs_meta_writer_t *mw,
return 0;
}
-static uint64_t *create_ool_locations_table(fstree_t *fs)
+static sqfs_u64 *create_ool_locations_table(fstree_t *fs)
{
- uint64_t *table;
+ sqfs_u64 *table;
size_t i;
- table = alloc_array(sizeof(uint64_t), fs->xattr_values.num_strings);
+ table = alloc_array(sizeof(sqfs_u64), fs->xattr_values.num_strings);
if (table == NULL) {
perror("allocating Xattr OOL locations table");
@@ -170,13 +170,13 @@ static uint64_t *create_ool_locations_table(fstree_t *fs)
int write_xattr(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
sqfs_compressor_t *cmp)
{
- uint64_t kv_start, id_start, block, off, *tbl, *ool_locations;
+ sqfs_u64 kv_start, id_start, block, off, *tbl, *ool_locations;
size_t i = 0, count = 0, blocks;
sqfs_xattr_id_table_t idtbl;
sqfs_xattr_id_t id_ent;
sqfs_meta_writer_t *mw;
tree_xattr_t *it;
- uint32_t offset;
+ sqfs_u32 offset;
if (fs->xattr == NULL)
return 0;
@@ -213,7 +213,7 @@ int write_xattr(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
if ((count * sizeof(id_ent)) % SQFS_META_BLOCK_SIZE)
++blocks;
- tbl = alloc_array(sizeof(uint64_t), blocks);
+ tbl = alloc_array(sizeof(sqfs_u64), blocks);
if (tbl == NULL) {
perror("generating xattr ID table");