summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/gzip.c2
-rw-r--r--archival/libarchive/decompress_gunzip.c2
-rw-r--r--archival/libarchive/decompress_unxz.c2
-rw-r--r--archival/lzop.c2
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/crc32.c10
-rw-r--r--miscutils/flash_eraseall.c2
-rw-r--r--util-linux/fdisk_gpt.c2
8 files changed, 18 insertions, 6 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index e3dd792..c5a1fe9 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -2239,7 +2239,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
ALLOC(ush, G1.prev, 1L << BITS);
/* Initialize the CRC32 table */
- global_crc32_table = crc32_filltable(NULL, 0);
+ global_crc32_new_table_le();
argv += optind;
return bbunpack(argv, pack_gzip, append_ext, "gz");
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c
index c8245d7..edff7e0 100644
--- a/archival/libarchive/decompress_gunzip.c
+++ b/archival/libarchive/decompress_gunzip.c
@@ -1000,7 +1000,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
gunzip_bb = 0;
/* Create the crc table */
- gunzip_crc_table = crc32_filltable(NULL, 0);
+ gunzip_crc_table = crc32_new_table_le();
gunzip_crc = ~0;
error_msg = "corrupted data";
diff --git a/archival/libarchive/decompress_unxz.c b/archival/libarchive/decompress_unxz.c
index 0be8550..8ae7a27 100644
--- a/archival/libarchive/decompress_unxz.c
+++ b/archival/libarchive/decompress_unxz.c
@@ -52,7 +52,7 @@ unpack_xz_stream(transformer_state_t *xstate)
IF_DESKTOP(long long) int total = 0;
if (!global_crc32_table)
- global_crc32_table = crc32_filltable(NULL, /*endian:*/ 0);
+ global_crc32_new_table_le();
memset(&iobuf, 0, sizeof(iobuf));
membuf = xmalloc(2 * BUFSIZ);
diff --git a/archival/lzop.c b/archival/lzop.c
index ba27aef..fef8cdb 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -1148,6 +1148,6 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
if (ENABLE_UNLZOP && applet_name[4] == 'o')
option_mask32 |= OPT_DECOMPRESS;
- global_crc32_table = crc32_filltable(NULL, 0);
+ global_crc32_new_table_le();
return bbunpack(argv, pack_lzop, make_new_name_lzop, /*unused:*/ NULL);
}
diff --git a/include/libbb.h b/include/libbb.h
index a938640..2bb3643 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1928,6 +1928,8 @@ typedef struct md5_ctx_t md5sha_ctx_t;
extern uint32_t *global_crc32_table;
uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;
+uint32_t *crc32_new_table_le(void) FAST_FUNC;
+uint32_t *global_crc32_new_table_le(void) FAST_FUNC;
uint32_t crc32_block_endian1(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC;
uint32_t crc32_block_endian0(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC;
diff --git a/libbb/crc32.c b/libbb/crc32.c
index b00b580..728bcb7 100644
--- a/libbb/crc32.c
+++ b/libbb/crc32.c
@@ -41,6 +41,16 @@ uint32_t* FAST_FUNC crc32_filltable(uint32_t *crc_table, int endian)
return crc_table - 256;
}
+/* Common uses: */
+uint32_t* FAST_FUNC crc32_new_table_le(void)
+{
+ return crc32_filltable(NULL, 0);
+}
+uint32_t* FAST_FUNC global_crc32_new_table_le(void)
+{
+ global_crc32_table = crc32_new_table_le();
+ return global_crc32_table;
+}
uint32_t FAST_FUNC crc32_block_endian1(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table)
{
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c
index fab2129..8e93060 100644
--- a/miscutils/flash_eraseall.c
+++ b/miscutils/flash_eraseall.c
@@ -101,7 +101,7 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv)
if (flags & OPTION_J) {
uint32_t *crc32_table;
- crc32_table = crc32_filltable(NULL, 0);
+ crc32_table = crc32_new_table_le();
cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c
index 45d2aa6..cdb9062 100644
--- a/util-linux/fdisk_gpt.c
+++ b/util-linux/fdisk_gpt.c
@@ -177,7 +177,7 @@ check_gpt_label(void)
init_unicode();
if (!global_crc32_table) {
- global_crc32_table = crc32_filltable(NULL, 0);
+ global_crc32_new_table_le();
}
crc = SWAP_LE32(gpt_hdr->hdr_crc32);