diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-19 20:05:13 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-19 20:05:13 +0100 |
commit | 4a091b656c0861e3f9335c38af25040cb3ff03c8 (patch) | |
tree | 263ee5a322bd263125ae07ef40ef5fed31812b29 /lib/sqfs/read_inode.c | |
parent | 001d3dc914d19b3d85aa04f2a042837cef4af0e4 (diff) |
Cleanup: remove the payload pointers from sqfs_inode_generic_t
There are 3 types of extra payload:
- Directory index
- File block sizes
- Symlink target
This commit removes the type specific pointers and modifies the code
to use the payload area directly. To simplify the file block case and
mitigate alignment issues, the type of the extra field is changed to
sqfs_u32.
For symlink target, the extra field can simply be cast to a character
pointer (it had to be cast anyway for most uses). For block sizes,
probably the most common usecase, it can be used as is. For directory
indices, there is a helper function anyway.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/read_inode.c')
-rw-r--r-- | lib/sqfs/read_inode.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c index f7bfff0..8653928 100644 --- a/lib/sqfs/read_inode.c +++ b/lib/sqfs/read_inode.c @@ -101,18 +101,16 @@ static int read_inode_file(sqfs_meta_reader_t *ir, sqfs_inode_t *base, out->base = *base; out->data.file = file; - out->block_sizes = (sqfs_u32 *)out->extra; out->num_file_blocks = count; - err = sqfs_meta_reader_read(ir, out->block_sizes, - count * sizeof(sqfs_u32)); + err = sqfs_meta_reader_read(ir, out->extra, count * sizeof(sqfs_u32)); if (err) { free(out); return err; } for (i = 0; i < count; ++i) - SWAB32(out->block_sizes[i]); + SWAB32(out->extra[i]); *result = out; return 0; @@ -149,18 +147,16 @@ static int read_inode_file_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base, out->base = *base; out->data.file_ext = file; - out->block_sizes = (sqfs_u32 *)out->extra; out->num_file_blocks = count; - err = sqfs_meta_reader_read(ir, out->block_sizes, - count * sizeof(sqfs_u32)); + err = sqfs_meta_reader_read(ir, out->extra, count * sizeof(sqfs_u32)); if (err) { free(out); return err; } for (i = 0; i < count; ++i) - SWAB32(out->block_sizes[i]); + SWAB32(out->extra[i]); *result = out; return 0; @@ -190,11 +186,10 @@ static int read_inode_slink(sqfs_meta_reader_t *ir, sqfs_inode_t *base, if (out == NULL) return SQFS_ERROR_ALLOC; - out->slink_target = (char *)out->extra; out->base = *base; out->data.slink = slink; - err = sqfs_meta_reader_read(ir, out->slink_target, slink.target_size); + err = sqfs_meta_reader_read(ir, (void *)out->extra, slink.target_size); if (err) { free(out); return err; @@ -290,10 +285,10 @@ static int read_inode_dir_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base, index_max = new_sz; } - memcpy(out->extra + index_used, &ent, sizeof(ent)); + memcpy((char *)out->extra + index_used, &ent, sizeof(ent)); index_used += sizeof(ent); - err = sqfs_meta_reader_read(ir, out->extra + index_used, + err = sqfs_meta_reader_read(ir, (char *)out->extra + index_used, ent.size + 1); if (err) { free(out); |