Skip to content

Commit 29d99fc

Browse files
pablodelaratkanteck
authored andcommitted
igzip: add zlib header init function
Add isal_zlib_hdr_init() function to initialize the isal_zlib_header structure to all 0. Signed-off-by: Pablo de Lara <[email protected]>
1 parent 6ef2abe commit 29d99fc

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

igzip/igzip.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,14 @@ void isal_gzip_header_init(struct isal_gzip_header *gz_hdr)
10231023
gz_hdr->flags = 0;
10241024
}
10251025

1026+
void isal_zlib_header_init(struct isal_zlib_header *z_hdr)
1027+
{
1028+
z_hdr->info = 0;
1029+
z_hdr->level = 0;
1030+
z_hdr->dict_id = 0;
1031+
z_hdr->dict_flag = 0;
1032+
}
1033+
10261034
uint32_t isal_write_gzip_header(struct isal_zstream *stream, struct isal_gzip_header *gz_hdr)
10271035
{
10281036
uint32_t flags = 0, hcrc, hdr_size = GZIP_HDR_BASE;

igzip/igzip_inflate.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,12 +2195,15 @@ int isal_inflate_stateless(struct inflate_state *state)
21952195

21962196
if (state->crc_flag == IGZIP_GZIP) {
21972197
struct isal_gzip_header gz_hdr;
2198+
21982199
isal_gzip_header_init(&gz_hdr);
21992200
ret = isal_read_gzip_header(state, &gz_hdr);
22002201
if (ret)
22012202
return ret;
22022203
} else if (state->crc_flag == IGZIP_ZLIB) {
2203-
struct isal_zlib_header z_hdr = { 0 };
2204+
struct isal_zlib_header z_hdr;
2205+
2206+
isal_zlib_header_init(&z_hdr);
22042207
ret = isal_read_zlib_header(state, &z_hdr);
22052208
if (ret)
22062209
return ret;
@@ -2268,14 +2271,17 @@ int isal_inflate(struct inflate_state *state)
22682271

22692272
if (!state->wrapper_flag && state->crc_flag == IGZIP_GZIP) {
22702273
struct isal_gzip_header gz_hdr;
2274+
22712275
isal_gzip_header_init(&gz_hdr);
22722276
ret = isal_read_gzip_header(state, &gz_hdr);
22732277
if (ret < 0)
22742278
return ret;
22752279
else if (ret > 0)
22762280
return ISAL_DECOMP_OK;
22772281
} else if (!state->wrapper_flag && state->crc_flag == IGZIP_ZLIB) {
2278-
struct isal_zlib_header z_hdr = { 0 };
2282+
struct isal_zlib_header z_hdr;
2283+
2284+
isal_zlib_header_init(&z_hdr);
22792285
ret = isal_read_zlib_header(state, &z_hdr);
22802286
if (ret < 0)
22812287
return ret;

igzip/igzip_wrapper_hdr_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ int main(int argc, char *argv[])
856856

857857
printf("zlib wrapper test: ");
858858
for (i = 0; i < RANDOMS; i++) {
859-
memset(&z_hdr_orig, 0, sizeof(z_hdr_orig));
859+
isal_zlib_header_init(&z_hdr_orig);
860860

861861
gen_rand_zlib_header(&z_hdr_orig);
862862

include/igzip_lib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,13 @@ void isal_deflate_reset(struct isal_zstream *stream);
604604
*/
605605
void isal_gzip_header_init(struct isal_gzip_header *gz_hdr);
606606

607+
/**
608+
* @brief Set zlib header default values
609+
*
610+
* @param z_hdr: zlib header to initialize.
611+
*/
612+
void isal_zlib_header_init(struct isal_zlib_header *z_hdr);
613+
607614
/**
608615
* @brief Write gzip header to output stream
609616
*

isa-l.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ crc64_rocksoft_refl_base @116
121121
crc64_rocksoft_norm @117
122122
crc64_rocksoft_refl @118
123123
ec_init_tables_base @119
124+
isal_zlib_header_init @120

0 commit comments

Comments
 (0)