From f3ab01445d6184f7c5ffd0251667de7ef7437f9a Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 16 May 2013 20:03:11 -0500 Subject: [PATCH] Compiler stuff - Rename compiler-specific macros - Remove some double-underscore prefixed identifiers - Remove strict aliasing violation in compress.c - Remove strict aliasing violation in decompress.c - Rename structures in security.c - Make memory allocation functions real functions, and give them __attribute__((malloc)) --- include/wimlib/compiler.h | 22 ++++--- include/wimlib/compress.h | 46 +++++++------- include/wimlib/decompress.h | 9 +-- include/wimlib/error.h | 19 +++--- include/wimlib/lookup_table.h | 7 ++- include/wimlib/paths.h | 5 +- include/wimlib/security.h | 3 +- include/wimlib/types.h | 13 ++++ include/wimlib/util.h | 30 ++++++--- src/compress.c | 111 +++++++++++++++++----------------- src/decompress.c | 44 +++----------- src/dentry.c | 24 ++++---- src/lookup_table.c | 7 ++- src/lzx-compress.c | 16 ++--- src/mount_image.c | 10 +-- src/security.c | 59 +++++++++--------- src/split.c | 4 +- src/util.c | 34 ++++++++--- src/write.c | 8 ++- src/xpress-compress.c | 41 +++++++------ src/xpress-decompress.c | 20 +++--- 21 files changed, 283 insertions(+), 249 deletions(-) diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 3134b119..5ee5a433 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -7,21 +7,25 @@ # else # define WIMLIBAPI __attribute__((visibility("default"))) # endif -# define ALWAYS_INLINE inline __attribute__((always_inline)) -# define PACKED __attribute__((packed)) -# define FORMAT(type, format_str, args_start) \ +# define _always_inline_attribute inline __attribute__((always_inline)) +# define _packed_attribute __attribute__((packed)) +# define _format_attribute(type, format_str, args_start) \ /*__attribute__((format(type, format_str, args_start))) */ # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -# define COLD __attribute__((cold)) +# define _cold_attribute __attribute__((cold)) # else -# define COLD +# define _cold_attribute # endif +# define _malloc_attribute __attribute__((malloc)) +# define _warn_unused_result_attribute __attribute__((warn_unused_result)) #else # define WIMLIBAPI -# define ALWAYS_INLINE inline -# define FORMAT(type, format_str, args_start) -# define COLD -# define PACKED +# define _always_inline_attribute inline +# define _format_attribute(type, format_str, args_start) +# define _cold_attribute +# define _packed_attribute +# define _malloc_attribute +# define _warn_unused_result_attribute #endif /* __GNUC__ */ #endif /* _WIMLIB_COMPILER_H */ diff --git a/include/wimlib/compress.h b/include/wimlib/compress.h index 764eee72..60b4c0ea 100644 --- a/include/wimlib/compress.h +++ b/include/wimlib/compress.h @@ -37,8 +37,8 @@ struct output_bitstream { int num_bytes_remaining; }; -static inline int bitstream_put_byte(struct output_bitstream *ostream, - u8 n) +static inline int +bitstream_put_byte(struct output_bitstream *ostream, u8 n) { if (ostream->num_bytes_remaining < 1) return 1; @@ -48,8 +48,8 @@ static inline int bitstream_put_byte(struct output_bitstream *ostream, return 0; } -static inline int bitstream_put_two_bytes(struct output_bitstream *ostream, - u16 n) +static inline int +bitstream_put_two_bytes(struct output_bitstream *ostream, u16 n) { if (ostream->num_bytes_remaining < 2) return 1; @@ -72,28 +72,32 @@ struct lz_params { typedef unsigned (*lz_record_match_t)(unsigned, unsigned, void *, void *); typedef unsigned (*lz_record_literal_t)(u8, void *); -extern unsigned lz_analyze_block(const u8 uncompressed_data[], - unsigned uncompressed_len, - u32 match_tab[], - lz_record_match_t record_match, - lz_record_literal_t record_literal, - void *record_match_arg1, - void *record_match_arg2, - void *record_literal_arg, - const struct lz_params *params); +extern unsigned +lz_analyze_block(const u8 uncompressed_data[], + unsigned uncompressed_len, + u32 match_tab[], + lz_record_match_t record_match, + lz_record_literal_t record_literal, + void *record_match_arg1, + void *record_match_arg2, + void *record_literal_arg, + const struct lz_params *params); extern int bitstream_put_bits(struct output_bitstream *ostream, output_bitbuf_t bits, unsigned num_bits); -extern void init_output_bitstream(struct output_bitstream *ostream, - void *data, unsigned num_bytes); +extern void +init_output_bitstream(struct output_bitstream *ostream, + void *data, unsigned num_bytes); -extern int flush_output_bitstream(struct output_bitstream *ostream); +extern int +flush_output_bitstream(struct output_bitstream *ostream); -extern void make_canonical_huffman_code(unsigned num_syms, - unsigned max_codeword_len, - const freq_t freq_tab[], - u8 lens[], - u16 codewords[]); +extern void +make_canonical_huffman_code(unsigned num_syms, + unsigned max_codeword_len, + const freq_t freq_tab[], + u8 lens[], + u16 codewords[]); #endif /* _WIMLIB_COMPRESS_H */ diff --git a/include/wimlib/decompress.h b/include/wimlib/decompress.h index c020cbad..a1963811 100644 --- a/include/wimlib/decompress.h +++ b/include/wimlib/decompress.h @@ -189,7 +189,7 @@ read_huffsym_near_end_of_input(struct input_bitstream *istream, * directory in the decode_table, as the * decode_table contains 2**table_bits entries. */ -static inline int +static _always_inline_attribute int read_huffsym(struct input_bitstream *istream, const u16 decode_table[], const u8 lens[], @@ -237,8 +237,9 @@ read_huffsym(struct input_bitstream *istream, return ret; } -extern int make_huffman_decode_table(u16 decode_table[], unsigned num_syms, - unsigned num_bits, const u8 lengths[], - unsigned max_codeword_len); +extern int +make_huffman_decode_table(u16 decode_table[], unsigned num_syms, + unsigned num_bits, const u8 lengths[], + unsigned max_codeword_len); #endif /* _WIMLIB_DECOMPRESS_H */ diff --git a/include/wimlib/error.h b/include/wimlib/error.h index 7de749d3..7e0a7ced 100644 --- a/include/wimlib/error.h +++ b/include/wimlib/error.h @@ -12,30 +12,35 @@ # define wimlib_printf wprintf #else /* __WIN32__ */ extern int -wimlib_fprintf(FILE *fp, const tchar *format, ...) FORMAT(printf, 2, 3); +wimlib_fprintf(FILE *fp, const tchar *format, ...) _format_attribute(printf, 2, 3); extern int -wimlib_printf(const tchar *format, ...) FORMAT(printf, 1, 2); +wimlib_printf(const tchar *format, ...) _format_attribute(printf, 1, 2); #endif /* !__WIN32__ */ -static inline int dummy_tprintf(const tchar *format, ...) +static inline int +dummy_tprintf(const tchar *format, ...) _format_attribute(printf, 1, 2) { return 0; } #ifdef ENABLE_ERROR_MESSAGES extern void -wimlib_error(const tchar *format, ...) FORMAT(printf, 1, 2) COLD; +wimlib_error(const tchar *format, ...) + _format_attribute(printf, 1, 2) _cold_attribute; extern void -wimlib_error_with_errno(const tchar *format, ...) FORMAT(printf, 1, 2) COLD; +wimlib_error_with_errno(const tchar *format, ...) + _format_attribute(printf, 1, 2) _cold_attribute; extern void -wimlib_warning(const tchar *format, ...) FORMAT(printf, 1, 2) COLD; +wimlib_warning(const tchar *format, ...) + _format_attribute(printf, 1, 2) _cold_attribute; extern void -wimlib_warning_with_errno(const tchar *format, ...) FORMAT(printf, 1, 2) COLD; +wimlib_warning_with_errno(const tchar *format, ...) + _format_attribute(printf, 1, 2) _cold_attribute; # define ERROR(format, ...) wimlib_error(T(format), ## __VA_ARGS__) # define ERROR_WITH_ERRNO(format, ...) wimlib_error_with_errno(T(format), ## __VA_ARGS__) # define WARNING(format, ...) wimlib_warning(T(format), ## __VA_ARGS__) diff --git a/include/wimlib/lookup_table.h b/include/wimlib/lookup_table.h index a01598c2..2b2cfcd9 100644 --- a/include/wimlib/lookup_table.h +++ b/include/wimlib/lookup_table.h @@ -288,7 +288,7 @@ lte_filename_valid(const struct wim_lookup_table_entry *lte) } extern struct wim_lookup_table * -new_lookup_table(size_t capacity); +new_lookup_table(size_t capacity) _malloc_attribute; extern int read_lookup_table(WIMStruct *w); @@ -318,10 +318,11 @@ lookup_table_unlink(struct wim_lookup_table *table, struct wim_lookup_table_entr } extern struct wim_lookup_table_entry * -new_lookup_table_entry(void); +new_lookup_table_entry(void) _malloc_attribute; extern struct wim_lookup_table_entry * -clone_lookup_table_entry(const struct wim_lookup_table_entry *lte); +clone_lookup_table_entry(const struct wim_lookup_table_entry *lte) + _malloc_attribute; extern void print_lookup_table_entry(const struct wim_lookup_table_entry *entry, diff --git a/include/wimlib/paths.h b/include/wimlib/paths.h index 944fbf45..311a8a0e 100644 --- a/include/wimlib/paths.h +++ b/include/wimlib/paths.h @@ -1,6 +1,7 @@ #ifndef _WIMLIB_PATHS_H #define _WIMLIB_PATHS_H +#include "wimlib/compiler.h" #include "wimlib/types.h" const tchar * @@ -16,9 +17,9 @@ extern void zap_backslashes(tchar *s); extern tchar * -canonicalize_wim_path(const tchar *wim_path); +canonicalize_wim_path(const tchar *wim_path) _malloc_attribute; extern tchar * -canonicalize_fs_path(const tchar *fs_path); +canonicalize_fs_path(const tchar *fs_path) _malloc_attribute; #endif /* _WIMLIB_PATHS_H */ diff --git a/include/wimlib/security.h b/include/wimlib/security.h index 7fa122ee..09d602d4 100644 --- a/include/wimlib/security.h +++ b/include/wimlib/security.h @@ -57,7 +57,8 @@ extern void print_security_data(const struct wim_security_data *sd); extern u8 * -write_security_data(const struct wim_security_data *sd, u8 *p); +write_security_data(const struct wim_security_data * restrict sd, + u8 * restrict p); extern void free_security_data(struct wim_security_data *sd); diff --git a/include/wimlib/types.h b/include/wimlib/types.h index faf290c9..561268db 100644 --- a/include/wimlib/types.h +++ b/include/wimlib/types.h @@ -19,6 +19,19 @@ typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; + +/* Unsigned little endian types of exact size */ +typedef uint8_t le8; +typedef uint16_t le16; +typedef uint32_t le32; +typedef uint64_t le64; + +/* Signed little endian types of exact size (declare as unsigned to avoid sign + * extension on big-endian architectures) */ +typedef uint8_t sle8; +typedef uint16_t sle16; +typedef uint32_t sle32; +typedef uint64_t sle64; #endif /* A pointer to 'utf16lechar' indicates a UTF-16LE encoded string */ diff --git a/include/wimlib/util.h b/include/wimlib/util.h index 177e1190..e0779503 100644 --- a/include/wimlib/util.h +++ b/include/wimlib/util.h @@ -50,17 +50,29 @@ #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #ifdef ENABLE_CUSTOM_MEMORY_ALLOCATOR -extern void *(*wimlib_malloc_func)(size_t); -extern void (*wimlib_free_func)(void *); -extern void *(*wimlib_realloc_func)(void *, size_t); -extern void *wimlib_calloc(size_t nmemb, size_t size); +extern void * +wimlib_malloc(size_t) _malloc_attribute; + +extern void +wimlib_free_memory(void *p); + +extern void * +wimlib_realloc(void *, size_t) _warn_unused_result_attribute; + +extern void * +wimlib_calloc(size_t nmemb, size_t size) _malloc_attribute; + #ifdef __WIN32__ -extern wchar_t *wimlib_wcsdup(const wchar_t *str); +extern wchar_t * +wimlib_wcsdup(const wchar_t *str) _malloc_attribute; + #endif -extern char *wimlib_strdup(const char *str); -# define MALLOC wimlib_malloc_func -# define FREE wimlib_free_func -# define REALLOC wimlib_realloc_func +extern char * +wimlib_strdup(const char *str) _malloc_attribute; + +# define MALLOC wimlib_malloc +# define FREE wimlib_free_memory +# define REALLOC wimlib_realloc # define CALLOC wimlib_calloc # define STRDUP wimlib_strdup # define WSTRDUP wimlib_wcsdup diff --git a/src/compress.c b/src/compress.c index 89d1245f..e7e19914 100644 --- a/src/compress.c +++ b/src/compress.c @@ -99,50 +99,42 @@ flush_output_bitstream(struct output_bitstream *ostream) /* Initializes an output bit buffer to write its output to the memory location * pointer to by @data. */ void -init_output_bitstream(struct output_bitstream *ostream, void *data, - unsigned num_bytes) +init_output_bitstream(struct output_bitstream *ostream, + void *data, unsigned num_bytes) { wimlib_assert(num_bytes >= 4); ostream->bitbuf = 0; ostream->free_bits = 16; - ostream->bit_output = (u8*)data; - ostream->next_bit_output = (u8*)data + 2; - ostream->output = (u8*)data + 4; + ostream->bit_output = data; + ostream->next_bit_output = data + 2; + ostream->output = data + 4; ostream->num_bytes_remaining = num_bytes - 4; } -/* Intermediate (non-leaf) node in a Huffman tree. */ -typedef struct HuffmanNode { +typedef struct { u32 freq; u16 sym; union { u16 path_len; u16 height; }; - struct HuffmanNode *left_child; - struct HuffmanNode *right_child; } HuffmanNode; -/* Leaf node in a Huffman tree. The fields are in the same order as the - * HuffmanNode, so it can be cast to a HuffmanNode. There are no pointers to - * the children in the leaf node. */ -typedef struct { - u32 freq; - u16 sym; - union { - u16 path_len; - u16 height; - }; -} HuffmanLeafNode; +typedef struct HuffmanIntermediateNode { + HuffmanNode node_base; + HuffmanNode *left_child; + HuffmanNode *right_child; +} HuffmanIntermediateNode; -/* Comparator function for HuffmanLeafNodes. Sorts primarily by symbol + +/* Comparator function for HuffmanNodes. Sorts primarily by symbol * frequency and secondarily by symbol value. */ static int -cmp_leaves_by_freq(const void *__leaf1, const void *__leaf2) +cmp_nodes_by_freq(const void *_leaf1, const void *_leaf2) { - const HuffmanLeafNode *leaf1 = __leaf1; - const HuffmanLeafNode *leaf2 = __leaf2; + const HuffmanNode *leaf1 = _leaf1; + const HuffmanNode *leaf2 = _leaf2; int freq_diff = (int)leaf1->freq - (int)leaf2->freq; @@ -152,13 +144,13 @@ cmp_leaves_by_freq(const void *__leaf1, const void *__leaf2) return freq_diff; } -/* Comparator function for HuffmanLeafNodes. Sorts primarily by code length and +/* Comparator function for HuffmanNodes. Sorts primarily by code length and * secondarily by symbol value. */ static int -cmp_leaves_by_code_len(const void *__leaf1, const void *__leaf2) +cmp_nodes_by_code_len(const void *_leaf1, const void *_leaf2) { - const HuffmanLeafNode *leaf1 = __leaf1; - const HuffmanLeafNode *leaf2 = __leaf2; + const HuffmanNode *leaf1 = _leaf1; + const HuffmanNode *leaf2 = _leaf2; int code_len_diff = (int)leaf1->path_len - (int)leaf2->path_len; @@ -168,18 +160,21 @@ cmp_leaves_by_code_len(const void *__leaf1, const void *__leaf2) return code_len_diff; } +#define INVALID_SYMBOL 0xffff + /* Recursive function to calculate the depth of the leaves in a Huffman tree. * */ static void -huffman_tree_compute_path_lengths(HuffmanNode *node, u16 cur_len) +huffman_tree_compute_path_lengths(HuffmanNode *base_node, u16 cur_len) { - if (node->sym == (u16)(-1)) { + if (base_node->sym == INVALID_SYMBOL) { /* Intermediate node. */ + HuffmanIntermediateNode *node = (HuffmanIntermediateNode*)base_node; huffman_tree_compute_path_lengths(node->left_child, cur_len + 1); huffman_tree_compute_path_lengths(node->right_child, cur_len + 1); } else { /* Leaf node. */ - node->path_len = cur_len; + base_node->path_len = cur_len; } } @@ -240,9 +235,11 @@ huffman_tree_compute_path_lengths(HuffmanNode *node, u16 cur_len) * for symbol i. */ void -make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, - const freq_t freq_tab[], u8 lens[], - u16 codewords[]) +make_canonical_huffman_code(unsigned num_syms, + unsigned max_codeword_len, + const freq_t * restrict freq_tab, + u8 * restrict lens, + u16 * restrict codewords) { /* We require at least 2 possible symbols in the alphabet to produce a * valid Huffman decoding table. It is allowed that fewer than 2 symbols @@ -267,7 +264,7 @@ make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, /* Initialize the array of leaf nodes with the symbols and their * frequencies. */ - HuffmanLeafNode leaves[num_used_symbols]; + HuffmanNode leaves[num_used_symbols]; unsigned leaf_idx = 0; for (unsigned i = 0; i < num_syms; i++) { if (freq_tab[i] != 0) { @@ -329,21 +326,21 @@ make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, * format constrains codes to 16 bits or less each. However, it is * still possible for there to be more than 16 intermediate nodes, as * long as no leaf has a depth of more than 16. */ - HuffmanNode inodes[num_used_symbols - 1]; + HuffmanIntermediateNode inodes[num_used_symbols - 1]; /* Pointer to the leaf node of lowest frequency that hasn't already been * added as the child of some intermediate note. */ - HuffmanLeafNode *cur_leaf; + HuffmanNode *cur_leaf; /* Pointer past the end of the array of leaves. */ - HuffmanLeafNode *end_leaf = &leaves[num_used_symbols]; + HuffmanNode *end_leaf = &leaves[num_used_symbols]; /* Pointer to the intermediate node of lowest frequency. */ - HuffmanNode *cur_inode; + HuffmanIntermediateNode *cur_inode; /* Pointer to the next unallocated intermediate node. */ - HuffmanNode *next_inode; + HuffmanIntermediateNode *next_inode; /* Only jump back to here if the maximum length of the codewords allowed * by the LZX format (16 bits) is exceeded. */ @@ -352,7 +349,7 @@ try_building_tree_again: /* Sort the leaves from those that correspond to the least frequent * symbol, to those that correspond to the most frequent symbol. If two * leaves have the same frequency, they are sorted by symbol. */ - qsort(leaves, num_used_symbols, sizeof(leaves[0]), cmp_leaves_by_freq); + qsort(leaves, num_used_symbols, sizeof(leaves[0]), cmp_nodes_by_freq); cur_leaf = &leaves[0]; cur_inode = &inodes[0]; @@ -376,17 +373,17 @@ try_building_tree_again: * remaining leaves or from the intermediate nodes. */ if (cur_leaf != end_leaf && (cur_inode == next_inode || - cur_leaf->freq <= cur_inode->freq)) { - f1 = (HuffmanNode*)cur_leaf++; + cur_leaf->freq <= cur_inode->node_base.freq)) { + f1 = cur_leaf++; } else if (cur_inode != next_inode) { - f1 = cur_inode++; + f1 = (HuffmanNode*)cur_inode++; } if (cur_leaf != end_leaf && (cur_inode == next_inode || - cur_leaf->freq <= cur_inode->freq)) { - f2 = (HuffmanNode*)cur_leaf++; + cur_leaf->freq <= cur_inode->node_base.freq)) { + f2 = cur_leaf++; } else if (cur_inode != next_inode) { - f2 = cur_inode++; + f2 = (HuffmanNode*)cur_inode++; } else { /* All nodes used up! */ break; @@ -394,20 +391,20 @@ try_building_tree_again: /* next_inode becomes the parent of f1 and f2. */ - next_inode->freq = f1->freq + f2->freq; - next_inode->sym = (u16)(-1); /* Invalid symbol. */ - next_inode->left_child = f1; - next_inode->right_child = f2; + next_inode->node_base.freq = f1->freq + f2->freq; + next_inode->node_base.sym = INVALID_SYMBOL; + next_inode->left_child = f1; + next_inode->right_child = f2; /* We need to keep track of the height so that we can detect if * the length of a codeword has execeed max_codeword_len. The * parent node has a height one higher than the maximum height * of its children. */ - next_inode->height = max(f1->height, f2->height) + 1; + next_inode->node_base.height = max(f1->height, f2->height) + 1; /* Check to see if the code length of the leaf farthest away * from next_inode has exceeded the maximum code length. */ - if (next_inode->height > max_codeword_len) { + if (next_inode->node_base.height > max_codeword_len) { /* The code lengths can be made more uniform by making * the frequencies more uniform. Divide all the * frequencies by 2, leaving 1 as the minimum frequency. @@ -427,15 +424,15 @@ try_building_tree_again: /* The Huffman tree is now complete, and its height is no more than * max_codeword_len. */ - HuffmanNode *root = next_inode - 1; - wimlib_assert(root->height <= max_codeword_len); + HuffmanIntermediateNode *root = next_inode - 1; + wimlib_assert(root->node_base.height <= max_codeword_len); /* Compute the path lengths for the leaf nodes. */ - huffman_tree_compute_path_lengths(root, 0); + huffman_tree_compute_path_lengths(&root->node_base, 0); /* Sort the leaf nodes primarily by code length and secondarily by * symbol. */ - qsort(leaves, num_used_symbols, sizeof(leaves[0]), cmp_leaves_by_code_len); + qsort(leaves, num_used_symbols, sizeof(leaves[0]), cmp_nodes_by_code_len); u16 cur_codeword = 0; unsigned cur_codeword_len = 0; diff --git a/src/decompress.c b/src/decompress.c index c8be3197..f149b48c 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -96,8 +96,8 @@ * pointers by the fact that values less than @num_syms must be symbol values. */ int -make_huffman_decode_table(u16 decode_table[], unsigned num_syms, - unsigned table_bits, const u8 lens[], +make_huffman_decode_table(u16 * restrict decode_table, unsigned num_syms, + unsigned table_bits, const u8 * restrict lens, unsigned max_codeword_len) { unsigned len_counts[max_codeword_len + 1]; @@ -171,41 +171,13 @@ make_huffman_decode_table(u16 decode_table[], unsigned num_syms, break; unsigned num_entries = 1 << (table_bits - codeword_len); - const unsigned entries_per_long = sizeof(unsigned long) / - sizeof(decode_table[0]); - if (num_entries >= entries_per_long) { - /* Fill in the Huffman decode table entries one unsigned - * long at a time. On 32-bit systems this is 2 entries - * per store, while on 64-bit systems this is 4 entries - * per store. */ - wimlib_assert2(decode_table_pos % entries_per_long == 0); - BUILD_BUG_ON(sizeof(unsigned long) != 4 && - sizeof(unsigned long) != 8); - - unsigned long *p = (unsigned long *)&decode_table[decode_table_pos]; - unsigned n = num_entries / entries_per_long; - unsigned long v = sym; - if (sizeof(unsigned long) >= 4) - v |= v << 16; - if (sizeof(unsigned long) >= 8) { - /* This may produce a compiler warning if an - * unsigned long is 32 bits, but this won't be - * executed unless an unsigned long is at least - * 64 bits anyway. */ - v |= v << 32; - } - do { - *p++ = v; - } while (--n); - decode_table_pos += num_entries; - } else { - /* Fill in the Huffman decode table entries one 16-bit - * integer at a time. */ - do { - decode_table[decode_table_pos++] = sym; - } while (--num_entries); - } + /* Fill in the Huffman decode table entries one 16-bit + * integer at a time. */ + do { + decode_table[decode_table_pos++] = sym; + } while (--num_entries); + wimlib_assert2(decode_table_pos <= table_num_entries); if (++i == num_used_syms) { wimlib_assert2(decode_table_pos == table_num_entries); diff --git a/src/dentry.c b/src/dentry.c index d77603fe..88e27992 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -46,7 +46,7 @@ * a file name and short name that take the specified numbers of bytes. This * excludes any alternate data stream entries that may follow the dentry. */ static u64 -__dentry_correct_length_unaligned(u16 file_name_nbytes, u16 short_name_nbytes) +_dentry_correct_length_unaligned(u16 file_name_nbytes, u16 short_name_nbytes) { u64 length = WIM_DENTRY_DISK_SIZE; if (file_name_nbytes) @@ -63,7 +63,7 @@ __dentry_correct_length_unaligned(u16 file_name_nbytes, u16 short_name_nbytes) static u64 dentry_correct_length_unaligned(const struct wim_dentry *dentry) { - return __dentry_correct_length_unaligned(dentry->file_name_nbytes, + return _dentry_correct_length_unaligned(dentry->file_name_nbytes, dentry->short_name_nbytes); } @@ -155,7 +155,7 @@ ads_entry_total_length(const struct wim_ads_entry *entry) static u64 -__dentry_total_length(const struct wim_dentry *dentry, u64 length) +_dentry_total_length(const struct wim_dentry *dentry, u64 length) { const struct wim_inode *inode = dentry->d_inode; for (u16 i = 0; i < inode->i_num_ads; i++) @@ -168,7 +168,7 @@ __dentry_total_length(const struct wim_dentry *dentry, u64 length) u64 dentry_correct_total_length(const struct wim_dentry *dentry) { - return __dentry_total_length(dentry, + return _dentry_total_length(dentry, dentry_correct_length_unaligned(dentry)); } @@ -177,7 +177,7 @@ dentry_correct_total_length(const struct wim_dentry *dentry) static u64 dentry_total_length(const struct wim_dentry *dentry) { - return __dentry_total_length(dentry, dentry->length); + return _dentry_total_length(dentry, dentry->length); } int @@ -782,7 +782,7 @@ new_dentry(const tchar *name, struct wim_dentry **dentry_ret) static int -__new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret, +_new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret, bool timeless) { struct wim_dentry *dentry; @@ -809,13 +809,13 @@ __new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret, int new_dentry_with_timeless_inode(const tchar *name, struct wim_dentry **dentry_ret) { - return __new_dentry_with_inode(name, dentry_ret, true); + return _new_dentry_with_inode(name, dentry_ret, true); } int new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret) { - return __new_dentry_with_inode(name, dentry_ret, false); + return _new_dentry_with_inode(name, dentry_ret, false); } int @@ -926,9 +926,9 @@ free_dentry(struct wim_dentry *dentry) /* This function is passed as an argument to for_dentry_in_tree_depth() in order * to free a directory tree. */ static int -do_free_dentry(struct wim_dentry *dentry, void *__lookup_table) +do_free_dentry(struct wim_dentry *dentry, void *_lookup_table) { - struct wim_lookup_table *lookup_table = __lookup_table; + struct wim_lookup_table *lookup_table = _lookup_table; unsigned i; if (lookup_table) { @@ -1596,7 +1596,7 @@ read_dentry(const u8 metadata_resource[], u64 metadata_resource_len, * The calculated length here is unaligned to allow for the possibility * that the dentry->length names an unaligned length, although this * would be unexpected. */ - calculated_size = __dentry_correct_length_unaligned(file_name_nbytes, + calculated_size = _dentry_correct_length_unaligned(file_name_nbytes, short_name_nbytes); if (dentry->length < calculated_size) { @@ -1892,7 +1892,7 @@ write_dentry(const struct wim_dentry *dentry, u8 *p) } p = put_zeroes(p, (8 - (p - orig_p) % 8) % 8); } - wimlib_assert(p - orig_p == __dentry_total_length(dentry, length)); + wimlib_assert(p - orig_p == _dentry_total_length(dentry, length)); return p; } diff --git a/src/lookup_table.c b/src/lookup_table.c index 2a313060..3361d8c2 100644 --- a/src/lookup_table.c +++ b/src/lookup_table.c @@ -43,9 +43,6 @@ # include /* for unlink() */ #endif -/* Size of each lookup table entry in the WIM file. */ -#define WIM_LOOKUP_TABLE_ENTRY_DISK_SIZE 50 - struct wim_lookup_table * new_lookup_table(size_t capacity) { @@ -354,6 +351,10 @@ for_lookup_table_entry_pos_sorted(struct wim_lookup_table *table, return ret; } + +/* Size of each lookup table entry in the WIM file. */ +#define WIM_LOOKUP_TABLE_ENTRY_DISK_SIZE 50 + /* * Reads the lookup table from a WIM file. * diff --git a/src/lzx-compress.c b/src/lzx-compress.c index 49aff104..a8e03401 100644 --- a/src/lzx-compress.c +++ b/src/lzx-compress.c @@ -130,9 +130,9 @@ lzx_get_position_slot(unsigned formatted_offset) } static u32 -lzx_record_literal(u8 literal, void *__main_freq_tab) +lzx_record_literal(u8 literal, void *_main_freq_tab) { - freq_t *main_freq_tab = __main_freq_tab; + freq_t *main_freq_tab = _main_freq_tab; main_freq_tab[literal]++; return literal; } @@ -143,10 +143,10 @@ lzx_record_literal(u8 literal, void *__main_freq_tab) * intermediate representation documented below. */ static u32 lzx_record_match(unsigned match_offset, unsigned match_len, - void *__freq_tabs, void *__queue) + void *_freq_tabs, void *_queue) { - struct lzx_freq_tables *freq_tabs = __freq_tabs; - struct lru_queue *queue = __queue; + struct lzx_freq_tables *freq_tabs = _freq_tabs; + struct lru_queue *queue = _queue; unsigned position_slot; unsigned position_footer = 0; u32 match; @@ -648,7 +648,7 @@ static const struct lz_params lzx_lz_params = { /* Documented in wimlib.h */ WIMLIBAPI unsigned -wimlib_lzx_compress(const void *__uncompressed_data, unsigned uncompressed_len, +wimlib_lzx_compress(const void *_uncompressed_data, unsigned uncompressed_len, void *compressed_data) { struct output_bitstream ostream; @@ -675,7 +675,7 @@ wimlib_lzx_compress(const void *__uncompressed_data, unsigned uncompressed_len, /* The input data must be preprocessed. To avoid changing the original * input, copy it to a temporary buffer. */ - memcpy(uncompressed_data, __uncompressed_data, uncompressed_len); + memcpy(uncompressed_data, _uncompressed_data, uncompressed_len); memset(uncompressed_data + uncompressed_len, 0, 8); /* Before doing any actual compression, do the call instruction (0xe8 @@ -764,7 +764,7 @@ wimlib_lzx_compress(const void *__uncompressed_data, unsigned uncompressed_len, } for (i = 0; i < uncompressed_len; i++) { - if (buf[i] != *((u8*)__uncompressed_data + i)) { + if (buf[i] != *((u8*)_uncompressed_data + i)) { ERROR("lzx_compress(): Data we compressed didn't " "decompress to the original data (difference at " "byte %u of %u)", i + 1, uncompressed_len); diff --git a/src/mount_image.c b/src/mount_image.c index 5d967773..3f1c5906 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -1046,29 +1046,29 @@ struct unmount_msg_hdr { u32 cur_version; u32 msg_type; u32 msg_size; -} PACKED; +} _packed_attribute; struct msg_unmount_request { struct unmount_msg_hdr hdr; u32 unmount_flags; u8 want_progress_messages; -} PACKED; +} _packed_attribute; struct msg_daemon_info { struct unmount_msg_hdr hdr; pid_t daemon_pid; u32 mount_flags; -} PACKED; +} _packed_attribute; struct msg_unmount_finished { struct unmount_msg_hdr hdr; s32 status; -} PACKED; +} _packed_attribute; struct msg_write_streams_progress { struct unmount_msg_hdr hdr; union wimlib_progress_info info; -} PACKED; +} _packed_attribute; enum { MSG_TYPE_UNMOUNT_REQUEST, diff --git a/src/security.c b/src/security.c index 0d0aa91a..5b0e81b3 100644 --- a/src/security.c +++ b/src/security.c @@ -35,7 +35,7 @@ #include "wimlib/util.h" /* At the start of each type of access control entry. */ -typedef struct { +typedef struct _ACE_HEADER { /* enum ace_type, specifies what type of ACE this is. */ u8 type; @@ -43,32 +43,32 @@ typedef struct { u8 flags; /* Size of the access control entry. */ - u8 size; -} ACEHeader; + u16 size; +} _packed_attribute ACE_HEADER; /* Grants rights to a user or group */ -typedef struct { - ACEHeader hdr; +typedef struct _ACCESS_ALLOWED_ACE { + ACE_HEADER hdr; u32 mask; u32 sid_start; -} AccessAllowedACE; +} _packed_attribute ACCESS_ALLOWED_ACE; /* Denies rights to a user or group */ -typedef struct { - ACEHeader hdr; +typedef struct _ACCESS_DENIED_ACE { + ACE_HEADER hdr; u32 mask; u32 sid_start; -} AccessDeniedACE; +} _packed_attribute ACCESS_DENIED_ACE; -typedef struct { - ACEHeader hdr; +typedef struct _SYSTEM_AUDIT_ACE { + ACE_HEADER hdr; u32 mask; u32 sid_start; -} SystemAuditACE; +} _packed_attribute SYSTEM_AUDIT_ACE; /* Header of an access control list. */ -typedef struct { +typedef struct _ACL { /* ACL_REVISION or ACL_REVISION_DS */ u8 revision; @@ -84,10 +84,10 @@ typedef struct { /* padding */ u16 sbz2; -} ACL; +} _packed_attribute ACL; /* A structure used to identify users or groups. */ -typedef struct { +typedef struct _SID { /* example: 0x1 */ u8 revision; @@ -98,10 +98,10 @@ typedef struct { u8 identifier_authority[6]; u32 sub_authority[0]; -} SID; +} _packed_attribute SID; -typedef struct { +typedef struct _SECURITY_DESCRIPTOR_RELATIVE { /* Example: 0x1 */ u8 revision; /* Example: 0x0 */ @@ -126,7 +126,7 @@ typedef struct { /* Discretionary ACL. */ /* Example: 0x34 */ u32 dacl_offset; -} SecurityDescriptor; +} _packed_attribute SECURITY_DESCRIPTOR_RELATIVE; /* * This is a hack to work around a problem in libntfs-3g. libntfs-3g validates @@ -145,8 +145,8 @@ empty_sacl_fixup(u8 *descr, u64 *size_p) /* No-op if no NTFS-3g support, or if NTFS-3g is version 2013 or later * */ #if defined(WITH_NTFS_3G) && !defined(HAVE_NTFS_MNT_RDONLY) - if (*size_p >= sizeof(SecurityDescriptor)) { - SecurityDescriptor *sd = (SecurityDescriptor*)descr; + if (*size_p >= sizeof(SECURITY_DESCRIPTOR_RELATIVE)) { + SECURITY_DESCRIPTOR_RELATIVE *sd = (SECURITY_DESCRIPTOR_RELATIVE*)descr; u32 sacl_offset = le32_to_cpu(sd->sacl_offset); if (sacl_offset == *size_p - sizeof(ACL)) { sd->sacl_offset = cpu_to_le32(0); @@ -327,7 +327,8 @@ out_free_sd: * Writes security data to an in-memory buffer. */ u8 * -write_security_data(const struct wim_security_data *sd, u8 *p) +write_security_data(const struct wim_security_data * restrict sd, + u8 * restrict p) { DEBUG("Writing security data (total_length = %"PRIu32", num_entries " "= %"PRIu32")", sd->total_length, sd->num_entries); @@ -365,12 +366,12 @@ print_acl(const void *p, const tchar *type) p += sizeof(ACL); for (u16 i = 0; i < ace_count; i++) { - const ACEHeader *hdr = p; + const ACE_HEADER *hdr = p; tprintf(T(" [ACE]\n")); tprintf(T(" ACE type = %d\n"), hdr->type); tprintf(T(" ACE flags = 0x%x\n"), hdr->flags); tprintf(T(" ACE size = %u\n"), hdr->size); - const AccessAllowedACE *aaa = (const AccessAllowedACE*)hdr; + const ACCESS_ALLOWED_ACE *aaa = (const ACCESS_ALLOWED_ACE*)p; tprintf(T(" ACE mask = %x\n"), le32_to_cpu(aaa->mask)); tprintf(T(" SID start = %u\n"), le32_to_cpu(aaa->sid_start)); p += hdr->size; @@ -399,7 +400,7 @@ print_sid(const void *p, const tchar *type) static void print_security_descriptor(const void *p, u64 size) { - const SecurityDescriptor *sd = p; + const SECURITY_DESCRIPTOR_RELATIVE *sd = p; u8 revision = sd->revision; u16 control = le16_to_cpu(sd->security_descriptor_control); @@ -430,14 +431,12 @@ print_security_descriptor(const void *p, u64 size) void print_security_data(const struct wim_security_data *sd) { - wimlib_assert(sd != NULL); - tputs(T("[SECURITY DATA]")); tprintf(T("Length = %"PRIu32" bytes\n"), sd->total_length); tprintf(T("Number of Entries = %"PRIu32"\n"), sd->num_entries); for (u32 i = 0; i < sd->num_entries; i++) { - tprintf(T("[SecurityDescriptor %"PRIu32", length = %"PRIu64"]\n"), + tprintf(T("[SECURITY_DESCRIPTOR_RELATIVE %"PRIu32", length = %"PRIu64"]\n"), i, sd->sizes[i]); print_security_descriptor(sd->descriptors[i], sd->sizes[i]); tputchar(T('\n')); @@ -542,18 +541,18 @@ lookup_sd(struct wim_sd_set *set, const u8 hash[SHA1_HASH_SIZE]) * return -1. */ int -sd_set_add_sd(struct wim_sd_set *sd_set, const char descriptor[], size_t size) +sd_set_add_sd(struct wim_sd_set *sd_set, const char *descriptor, size_t size) { u8 hash[SHA1_HASH_SIZE]; int security_id; struct sd_node *new; u8 **descriptors; u64 *sizes; - u8 *descr_copy; + char *descr_copy; struct wim_security_data *sd; bool bret; - sha1_buffer((const u8*)descriptor, size, hash); + sha1_buffer(descriptor, size, hash); security_id = lookup_sd(sd_set, hash); if (security_id >= 0) /* Identical descriptor already exists */ diff --git a/src/split.c b/src/split.c index b1231b59..05a7beeb 100644 --- a/src/split.c +++ b/src/split.c @@ -70,9 +70,9 @@ finish_swm(WIMStruct *w, struct list_head *lte_list, } static int -copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *__args) +copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *_args) { - struct split_args *args = (struct split_args*)__args; + struct split_args *args = (struct split_args*)_args; WIMStruct *w = args->w; int ret; diff --git a/src/util.c b/src/util.c index df3b5c8a..f7ed251c 100644 --- a/src/util.c +++ b/src/util.c @@ -407,17 +407,35 @@ wimlib_get_error_string(enum wimlib_error_code code) #ifdef ENABLE_CUSTOM_MEMORY_ALLOCATOR -void *(*wimlib_malloc_func) (size_t) = malloc; -void (*wimlib_free_func) (void *) = free; -void *(*wimlib_realloc_func)(void *, size_t) = realloc; +static void *(*wimlib_malloc_func) (size_t) = malloc; +static void (*wimlib_free_func) (void *) = free; +static void *(*wimlib_realloc_func)(void *, size_t) = realloc; + +void * +wimlib_malloc(size_t size) +{ + return (*wimlib_malloc_func)(size); +} + +void +wimlib_free_memory(void *ptr) +{ + (*wimlib_free_func)(ptr); +} + +void * +wimlib_realloc(void *ptr, size_t size) +{ + return (*wimlib_realloc_func)(ptr, size); +} void * wimlib_calloc(size_t nmemb, size_t size) { size_t total_size = nmemb * size; - void *p = MALLOC(total_size); + void *p = (*wimlib_malloc_func)(total_size); if (p) - memset(p, 0, total_size); + p = memset(p, 0, total_size); return p; } @@ -428,7 +446,7 @@ wimlib_strdup(const char *str) char *p; size = strlen(str); - p = MALLOC(size + 1); + p = (*wimlib_malloc_func)(size + 1); if (p) memcpy(p, str, size + 1); return p; @@ -442,9 +460,9 @@ wimlib_wcsdup(const wchar_t *str) wchar_t *p; size = wcslen(str); - p = MALLOC((size + 1) * sizeof(wchar_t)); + p = (*wimlib_malloc_func)((size + 1) * sizeof(wchar_t)); if (p) - memcpy(p, str, (size + 1) * sizeof(wchar_t)); + p = wmemcpy(p, str, size + 1); return p; } #endif diff --git a/src/write.c b/src/write.c index abbe4c01..8451b391 100644 --- a/src/write.c +++ b/src/write.c @@ -87,7 +87,10 @@ struct chunk_table { u64 table_disk_size; u64 cur_offset; u64 *cur_offset_p; - u64 offsets[0]; + union { + u64 offsets[0]; + u32 u32_offsets[0]; + }; }; /* @@ -233,8 +236,7 @@ finish_wim_resource_chunk_tab(struct chunk_table *chunk_tab, array_cpu_to_le64(chunk_tab->offsets, chunk_tab->num_chunks); } else { for (u64 i = 0; i < chunk_tab->num_chunks; i++) - ((u32*)chunk_tab->offsets)[i] = - cpu_to_le32(chunk_tab->offsets[i]); + chunk_tab->u32_offsets[i] = cpu_to_le32(chunk_tab->offsets[i]); } bytes_written = full_pwrite(out_fd, (u8*)chunk_tab->offsets + chunk_tab->bytes_per_chunk_entry, diff --git a/src/xpress-compress.c b/src/xpress-compress.c index 1975fb28..0957e27b 100644 --- a/src/xpress-compress.c +++ b/src/xpress-compress.c @@ -46,8 +46,10 @@ * @codewords and @lens provide the Huffman code that is being used. */ static int -xpress_write_match(struct output_bitstream *ostream, u32 match, - const u16 codewords[], const u8 lens[]) +xpress_write_match(struct output_bitstream *restrict ostream, + u32 match, + const u16 codewords[restrict], + const u8 lens[restrict]) { u32 adjusted_match_len = match & 0xffff; u32 match_offset = match >> 16; @@ -57,17 +59,17 @@ xpress_write_match(struct output_bitstream *ostream, u32 match, int ret; ret = bitstream_put_bits(ostream, codewords[sym], lens[sym]); - if (ret != 0) + if (ret) return ret; if (adjusted_match_len >= 0xf) { u8 byte1 = min(adjusted_match_len - 0xf, 0xff); ret = bitstream_put_byte(ostream, byte1); - if (ret != 0) + if (ret) return ret; if (byte1 == 0xff) { ret = bitstream_put_two_bytes(ostream, adjusted_match_len); - if (ret != 0) + if (ret) return ret; } } @@ -77,10 +79,10 @@ xpress_write_match(struct output_bitstream *ostream, u32 match, static int xpress_write_compressed_literals(struct output_bitstream *ostream, - const u32 match_tab[], + const u32 match_tab[restrict], unsigned num_matches, - const u16 codewords[], - const u8 lens[]) + const u16 codewords[restrict], + const u8 lens[restrict]) { for (unsigned i = 0; i < num_matches; i++) { int ret; @@ -92,7 +94,7 @@ xpress_write_compressed_literals(struct output_bitstream *ostream, else /* literal byte */ ret = bitstream_put_bits(ostream, codewords[match], lens[match]); - if (ret != 0) + if (ret) return ret; } return bitstream_put_bits(ostream, codewords[XPRESS_END_OF_DATA], @@ -100,16 +102,16 @@ xpress_write_compressed_literals(struct output_bitstream *ostream, } static u32 -xpress_record_literal(u8 literal, void *__freq_tab) +xpress_record_literal(u8 literal, void *_freq_tab) { - freq_t *freq_tab = __freq_tab; + freq_t *freq_tab = _freq_tab; freq_tab[literal]++; return literal; } static u32 xpress_record_match(unsigned match_offset, unsigned match_len, - void *freq_tab, void *ignore) + void *freq_tab, void *_ignore) { wimlib_assert(match_len >= XPRESS_MIN_MATCH && match_len <= XPRESS_MAX_MATCH); @@ -150,10 +152,11 @@ static const struct lz_params xpress_lz_params = { /* Documented in wimlib.h */ WIMLIBAPI unsigned -wimlib_xpress_compress(const void *__uncompressed_data, - unsigned uncompressed_len, void *__compressed_data) +wimlib_xpress_compress(const void * restrict _uncompressed_data, + unsigned uncompressed_len, + void * restrict _compressed_data) { - u8 *compressed_data = __compressed_data; + u8 *compressed_data = _compressed_data; struct output_bitstream ostream; u32 match_tab[uncompressed_len]; freq_t freq_tab[XPRESS_NUM_SYMBOLS]; @@ -165,7 +168,7 @@ wimlib_xpress_compress(const void *__uncompressed_data, int ret; u8 uncompressed_data[uncompressed_len + 8]; - memcpy(uncompressed_data, __uncompressed_data, uncompressed_len); + memcpy(uncompressed_data, _uncompressed_data, uncompressed_len); memset(uncompressed_data + uncompressed_len, 0, 8); wimlib_assert(uncompressed_len <= 32768); @@ -239,10 +242,10 @@ wimlib_xpress_compress(const void *__uncompressed_data, * the compressed data, in which case they are actually unnecessary, or * they may precede a number of bytes embedded into the bitstream.) */ if (ostream.bit_output > - (const u8*)__compressed_data + uncompressed_len - 3) + (const u8*)_compressed_data + uncompressed_len - 3) return 0; *(u16*)ostream.bit_output = cpu_to_le16(0); - compressed_len = ostream.next_bit_output - (const u8*)__compressed_data; + compressed_len = ostream.next_bit_output - (const u8*)_compressed_data; wimlib_assert(compressed_len <= uncompressed_len - 1); @@ -250,7 +253,7 @@ wimlib_xpress_compress(const void *__uncompressed_data, /* Verify that we really get the same thing back when decompressing. */ { u8 buf[uncompressed_len]; - ret = wimlib_xpress_decompress(__compressed_data, compressed_len, + ret = wimlib_xpress_decompress(_compressed_data, compressed_len, buf, uncompressed_len); if (ret) { ERROR("xpress_compress(): Failed to decompress data we " diff --git a/src/xpress-decompress.c b/src/xpress-decompress.c index 584fa4aa..bf2faa1a 100644 --- a/src/xpress-decompress.c +++ b/src/xpress-decompress.c @@ -97,8 +97,8 @@ */ static int xpress_decode_match(unsigned huffsym, unsigned window_pos, - unsigned window_len, u8 window[], - struct input_bitstream *istream) + unsigned window_len, u8 window[restrict], + struct input_bitstream * restrict istream) { unsigned match_len; unsigned match_offset; @@ -111,7 +111,7 @@ xpress_decode_match(unsigned huffsym, unsigned window_pos, unsigned i; ret = bitstream_read_bits(istream, offset_bsr, &match_offset); - if (ret != 0) + if (ret) return ret; match_offset |= (1 << offset_bsr); @@ -168,11 +168,11 @@ xpress_decode_match(unsigned huffsym, unsigned window_pos, /* Decodes the Huffman-encoded matches and literal bytes in a block of * XPRESS-encoded data. */ static int -xpress_decompress_block(struct input_bitstream *istream, - u8 uncompressed_data[], +xpress_decompress_block(struct input_bitstream * restrict istream, + u8 uncompressed_data[restrict], unsigned uncompressed_len, - const u8 lens[], - const u16 decode_table[]) + const u8 lens[restrict], + const u16 decode_table[restrict]) { unsigned curpos; unsigned huffsym; @@ -206,8 +206,8 @@ xpress_decompress_block(struct input_bitstream *istream, /* Documented in wimlib.h */ WIMLIBAPI int -wimlib_xpress_decompress(const void *__compressed_data, unsigned compressed_len, - void *uncompressed_data, unsigned uncompressed_len) +wimlib_xpress_decompress(const void * restrict _compressed_data, unsigned compressed_len, + void * restrict uncompressed_data, unsigned uncompressed_len) { u8 lens[XPRESS_NUM_SYMBOLS]; u16 decode_table[(1 << XPRESS_TABLEBITS) + 2 * XPRESS_NUM_SYMBOLS]; @@ -217,7 +217,7 @@ wimlib_xpress_decompress(const void *__compressed_data, unsigned compressed_len, unsigned i; int ret; - compressed_data = __compressed_data; + compressed_data = _compressed_data; lens_p = lens; DEBUG2("compressed_len = %d, uncompressed_len = %d", -- 2.43.0