diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-04-26 11:36:28 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-04-26 11:36:28 +0000 |
commit | c0fe56ca3adfe07b5bb3969d7e73386e349eb357 (patch) | |
tree | 703545bfdef57e98ad3b52d59b052728fcdfcdb9 /usr/src/common | |
parent | ce79a84f945c46383786999babb4bcf38fd56a43 (diff) | |
parent | 935ca2ec57f70d4ab88ff9e6c036c55019ad3a22 (diff) | |
download | illumos-joyent-c0fe56ca3adfe07b5bb3969d7e73386e349eb357.tar.gz |
[illumos-gate merge]
commit 935ca2ec57f70d4ab88ff9e6c036c55019ad3a22
10567 lofi should support basic EFI ioctl()s
commit 0ce4bbcb47d8f86307fb8d2c84fd0f4e070f576e
10841 predictive prefetch disabled on new pools until export/reboot
commit 6721053b711f01c893fdb63ff6bd07538074ec9d
10568 bop_trap() should report %cr2
commit 679c9deae74d7b935e94eaaff2566ea45c1afe2b
10805 Fix for 10687 can be improved
commit 238e18a0612111ee326ff2764b2d37a9b79c882d
10744 bzip2: smatch cleanup
commit 8af61ecc4fc33ded07f60b6664781dff06728e63
10669 qede: NULL pointer errors
commit a08b13667a992ffe0995985257aab50b2fb9796b
10828 loader: smatch should ignore .S files
commit 0605ac6144f41502681d3c1c7607950a281228de
10794 acpippm: NULL pointer errors
commit 5ffc25366dbf720731d0c0ba074595513d16690e
10793 apix: NULL pointer errors
Diffstat (limited to 'usr/src/common')
-rw-r--r-- | usr/src/common/bzip2/bzlib.c | 254 | ||||
-rw-r--r-- | usr/src/common/bzip2/decompress.c | 54 |
2 files changed, 159 insertions, 149 deletions
diff --git a/usr/src/common/bzip2/bzlib.c b/usr/src/common/bzip2/bzlib.c index de5c009de8..06b37767c9 100644 --- a/usr/src/common/bzip2/bzlib.c +++ b/usr/src/common/bzip2/bzlib.c @@ -11,7 +11,7 @@ bzip2/libbzip2 version 1.0.6 of 6 September 2010 Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> - Please read the WARNING, DISCLAIMER and PATENTS sections in the + Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. This program is released under the terms of the license contained @@ -41,7 +41,7 @@ #ifndef BZ_NO_STDIO void BZ2_bz__AssertH__fail ( int errcode ) { - fprintf(stderr, + fprintf(stderr, "\n\nbzip2/libbzip2: internal error number %d.\n" "This is a bug in bzip2/libbzip2, %s.\n" "Please report it to me at: jseward@bzip.org. If this happened\n" @@ -115,9 +115,9 @@ BZE(BZ_DATA_ERROR_MAGIC) \ BZE(BZ_IO_ERROR) \ BZE(BZ_UNEXPECTED_EOF) \ BZE(BZ_OUTBUFF_FULL) \ -BZE(BZ_CONFIG_ERROR) +BZE(BZ_CONFIG_ERROR) -BZ_EXTERN const char * BZ_API(BZ2_bzErrorString) ( +const char * BZ_API(BZ2_bzErrorString) ( int error_code ) { @@ -228,8 +228,8 @@ Bool isempty_RL ( EState* s ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ) @@ -239,7 +239,7 @@ int BZ_API(BZ2_bzCompressInit) if (!bz_config_ok()) return BZ_CONFIG_ERROR; - if (strm == NULL || + if (strm == NULL || blockSize100k < 1 || blockSize100k > 9 || workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; @@ -297,7 +297,7 @@ int BZ_API(BZ2_bzCompressInit) /* * returns the BZALLOC size needed for bzCompressInit */ -int BZ_API(BZ2_bzCompressInitSize) ( +int BZ_API(BZ2_bzCompressInitSize) ( int blockSize100k) { Int32 n, t; @@ -438,7 +438,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- no input? --*/ if (s->strm->avail_in == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -456,7 +456,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- flush/finish end? --*/ if (s->avail_in_expect == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -502,18 +502,18 @@ Bool handle_compress ( bz_stream* strm ) Bool progress_in = False; Bool progress_out = False; EState* s = strm->state; - + while (True) { if (s->state == BZ_S_OUTPUT) { progress_out |= copy_output_until_stop ( s ); if (s->state_out_pos < s->numZ) break; - if (s->mode == BZ_M_FINISHING && + if (s->mode == BZ_M_FINISHING && s->avail_in_expect == 0 && isempty_RL(s)) break; prepare_new_block ( s ); s->state = BZ_S_INPUT; - if (s->mode == BZ_M_FLUSHING && + if (s->mode == BZ_M_FLUSHING && s->avail_in_expect == 0 && isempty_RL(s)) break; } @@ -562,7 +562,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) if (action == BZ_RUN) { progress = handle_compress ( strm ); return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; - } + } else if (action == BZ_FLUSH) { s->avail_in_expect = strm->avail_in; @@ -575,12 +575,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) s->mode = BZ_M_FINISHING; goto preswitch; } - else + else return BZ_PARAM_ERROR; case BZ_M_FLUSHING: if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (s->avail_in_expect > 0 || !isempty_RL(s) || @@ -590,7 +590,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) case BZ_M_FINISHING: if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; @@ -617,7 +617,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) if (s->ftab != NULL) BZFREE(s->ftab); BZFREE(strm->state); - strm->state = NULL; + strm->state = NULL; return BZ_OK; } @@ -629,8 +629,8 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, int verbosity, int small ) { @@ -728,34 +728,34 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; - + /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -793,7 +793,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) } s_state_out_len_eq_one: { - if (cs_avail_out == 0) { + if (cs_avail_out == 0) { c_state_out_len = 1; goto return_notr; }; *( (UChar*)(cs_next_out) ) = c_state_out_ch; @@ -801,7 +801,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) cs_next_out++; cs_avail_out--; } - } + } /* Only caused by corrupt data stream? */ if (c_nblock_used > s_save_nblockPP) return True; @@ -809,26 +809,30 @@ Bool unRLE_obuf_to_output_FAST ( DState* s ) /* can a new run be started? */ if (c_nblock_used == s_save_nblockPP) { c_state_out_len = 0; goto return_notr; - }; + }; c_state_out_ch = c_k0; - BZ_GET_FAST_C(k1); c_nblock_used++; - if (k1 != c_k0) { - c_k0 = k1; goto s_state_out_len_eq_one; + BZ_GET_FAST_C(k1); + c_nblock_used++; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; }; - if (c_nblock_used == s_save_nblockPP) + if (c_nblock_used == s_save_nblockPP) goto s_state_out_len_eq_one; - + c_state_out_len = 2; - BZ_GET_FAST_C(k1); c_nblock_used++; + BZ_GET_FAST_C(k1); + c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + c_state_out_len = 3; - BZ_GET_FAST_C(k1); c_nblock_used++; + BZ_GET_FAST_C(k1); + c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - - BZ_GET_FAST_C(k1); c_nblock_used++; + + BZ_GET_FAST_C(k1); + c_nblock_used++; c_state_out_len = ((Int32)k1) + 4; BZ_GET_FAST_C(c_k0); c_nblock_used++; } @@ -895,37 +899,37 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -944,31 +948,35 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return False; /* Only caused by corrupt data stream? */ if (s->nblock_used > s->save_nblock+1) return True; - + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); s->nblock_used++; + BZ_GET_SMALL(k1); + s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_SMALL(k1); s->nblock_used++; + BZ_GET_SMALL(k1); + s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_SMALL(k1); s->nblock_used++; + BZ_GET_SMALL(k1); + s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); s->nblock_used++; + + BZ_GET_SMALL(k1); + s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; BZ_GET_SMALL(s->k0); s->nblock_used++; } @@ -996,14 +1004,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) if (corrupt) return BZ_DATA_ERROR; if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); - if (s->verbosity >= 3) - VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, + if (s->verbosity >= 3) + VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, s->calculatedBlockCRC ); if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->calculatedBlockCRC != s->storedBlockCRC) return BZ_DATA_ERROR; - s->calculatedCombinedCRC - = (s->calculatedCombinedCRC << 1) | + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | (s->calculatedCombinedCRC >> 31); s->calculatedCombinedCRC ^= s->calculatedBlockCRC; s->state = BZ_X_BLKHDR_1; @@ -1015,7 +1023,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Int32 r = BZ2_decompress ( s ); if (r == BZ_STREAM_END) { if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", + VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", s->storedCombinedCRC, s->calculatedCombinedCRC ); if (s->calculatedCombinedCRC != s->storedCombinedCRC) return BZ_DATA_ERROR; @@ -1065,7 +1073,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) if (bzf != NULL) bzf->lastErr = eee; \ } -typedef +typedef struct { FILE* handle; Char buf[BZ_MAX_UNUSED]; @@ -1089,10 +1097,10 @@ static Bool myfeof ( FILE* f ) /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzWriteOpen) - ( int* bzerror, - FILE* f, - int blockSize100k, +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, int verbosity, int workFactor ) { @@ -1124,23 +1132,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen) bzf->strm.opaque = NULL; if (workFactor == 0) workFactor = 30; - ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) { BZ_SETERR(ret); free(bzf); return NULL; }; bzf->strm.avail_in = 0; bzf->initialisedOk = True; - return bzf; + return bzf; } /*---------------------------------------------------*/ void BZ_API(BZ2_bzWrite) - ( int* bzerror, - BZFILE* b, - void* buf, + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, n2, ret; @@ -1169,7 +1177,7 @@ void BZ_API(BZ2_bzWrite) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -1183,20 +1191,20 @@ void BZ_API(BZ2_bzWrite) /*---------------------------------------------------*/ void BZ_API(BZ2_bzWriteClose) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ) { - BZ2_bzWriteClose64 ( bzerror, b, abandon, + BZ2_bzWriteClose64 ( bzerror, b, abandon, nbytes_in, NULL, nbytes_out, NULL ); } void BZ_API(BZ2_bzWriteClose64) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, @@ -1228,7 +1236,7 @@ void BZ_API(BZ2_bzWriteClose64) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -1260,9 +1268,9 @@ void BZ_API(BZ2_bzWriteClose64) /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzReadOpen) - ( int* bzerror, - FILE* f, +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, int verbosity, int small, void* unused, @@ -1273,7 +1281,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) BZ_SETERR(BZ_OK); - if (f == NULL || + if (f == NULL || (small != 0 && small != 1) || (verbosity < 0 || verbosity > 4) || (unused == NULL && nUnused != 0) || @@ -1284,7 +1292,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) + if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; BZ_SETERR(BZ_OK); @@ -1296,7 +1304,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.bzalloc = NULL; bzf->strm.bzfree = NULL; bzf->strm.opaque = NULL; - + while (nUnused > 0) { bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; unused = ((void*)( 1 + ((UChar*)(unused)) )); @@ -1311,7 +1319,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.next_in = bzf->buf; bzf->initialisedOk = True; - return bzf; + return bzf; } @@ -1334,10 +1342,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzRead) - ( int* bzerror, - BZFILE* b, - void* buf, +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, ret; @@ -1359,11 +1367,11 @@ int BZ_API(BZ2_bzRead) while (True) { - if (ferror(bzf->handle)) + if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { - n = fread ( bzf->buf, sizeof(UChar), + n = fread ( bzf->buf, sizeof(UChar), BZ_MAX_UNUSED, bzf->handle ); if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; @@ -1377,7 +1385,7 @@ int BZ_API(BZ2_bzRead) if (ret != BZ_OK && ret != BZ_STREAM_END) { BZ_SETERR(ret); return 0; }; - if (ret == BZ_OK && myfeof(bzf->handle) && + if (ret == BZ_OK && myfeof(bzf->handle) && bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; @@ -1386,7 +1394,7 @@ int BZ_API(BZ2_bzRead) return len - bzf->strm.avail_out; }; if (bzf->strm.avail_out == 0) { BZ_SETERR(BZ_OK); return len; }; - + } return 0; /*not reached*/ @@ -1394,10 +1402,10 @@ int BZ_API(BZ2_bzRead) /*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadGetUnused) - ( int* bzerror, - BZFILE* b, - void** unused, +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, int* nUnused ) { bzFile* bzf = (bzFile*)b; @@ -1420,30 +1428,30 @@ void BZ_API(BZ2_bzReadGetUnused) /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -1457,7 +1465,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; (void) BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -1472,10 +1480,10 @@ int BZ_API(BZ2_bzBuffToBuffCompress) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffDecompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, int small, int verbosity ) @@ -1483,10 +1491,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || (small != 0 && small != 1) || - verbosity < 0 || verbosity > 4) + verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; strm.bzalloc = NULL; @@ -1516,11 +1524,11 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) } else { (void) BZ2_bzDecompressEnd ( &strm ); return BZ_OUTBUFF_FULL; - } + } errhandler: (void) BZ2_bzDecompressEnd ( &strm ); - return ret; + return ret; } @@ -1572,7 +1580,7 @@ BZFILE * bzopen_or_bzdopen int verbosity = 0; int workFactor = 30; int smallMode = 0; - int nUnused = 0; + int nUnused = 0; if (mode == NULL) return NULL; while (*mode) { @@ -1612,7 +1620,7 @@ BZFILE * bzopen_or_bzdopen if (writing) { /* Guard against total chaos and anarchy -- JRS */ if (blockSize100k < 1) blockSize100k = 1; - if (blockSize100k > 9) blockSize100k = 9; + if (blockSize100k > 9) blockSize100k = 9; bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, verbosity,workFactor); } else { @@ -1691,7 +1699,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) { int bzerr; FILE *fp; - + if (b==NULL) {return;} fp = ((bzFile *)b)->handle; if(((bzFile*)b)->writing){ @@ -1710,7 +1718,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) /*---------------------------------------------------*/ /*-- - return last error code + return last error code --*/ static const char *bzerrorstrings[] = { "OK" diff --git a/usr/src/common/bzip2/decompress.c b/usr/src/common/bzip2/decompress.c index d1da427b26..9a2f91695f 100644 --- a/usr/src/common/bzip2/decompress.c +++ b/usr/src/common/bzip2/decompress.c @@ -11,7 +11,7 @@ bzip2/libbzip2 version 1.0.6 of 6 September 2010 Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> - Please read the WARNING, DISCLAIMER and PATENTS sections in the + Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. This program is released under the terms of the license contained @@ -128,7 +128,7 @@ Int32 BZ2_decompress ( DState* s ) Int32 N; Int32 curr; Int32 zt; - Int32 zn; + Int32 zn; Int32 zvec; Int32 zj; Int32 gSel; @@ -182,7 +182,7 @@ Int32 BZ2_decompress ( DState* s ) N = s->save_N; curr = s->save_curr; zt = s->save_zt; - zn = s->save_zn; + zn = s->save_zn; zvec = s->save_zvec; zj = s->save_zj; gSel = s->save_gSel; @@ -205,14 +205,14 @@ Int32 BZ2_decompress ( DState* s ) if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) - if (s->blockSize100k < (BZ_HDR_0 + 1) || + if (s->blockSize100k < (BZ_HDR_0 + 1) || s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k -= BZ_HDR_0; if (s->smallDecompress) { s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( - ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { @@ -238,7 +238,7 @@ Int32 BZ2_decompress ( DState* s ) s->currBlockNo++; if (s->verbosity >= 2) VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); - + s->storedBlockCRC = 0; GET_UCHAR(BZ_X_BCRC_1, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); @@ -261,14 +261,14 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0) RETURN(BZ_DATA_ERROR); - if (s->origPtr > 10 + 100000*s->blockSize100k) + if (s->origPtr > 10 + 100000*s->blockSize100k) RETURN(BZ_DATA_ERROR); /*--- Receive the mapping table ---*/ for (i = 0; i < 16; i++) { GET_BIT(BZ_X_MAPPING_1, uc); - if (uc == 1) - s->inUse16[i] = True; else + if (uc == 1) + s->inUse16[i] = True; else s->inUse16[i] = False; } @@ -304,7 +304,7 @@ Int32 BZ2_decompress ( DState* s ) { UChar pos[BZ_N_GROUPS], tmp, v; for (v = 0; v < nGroups; v++) pos[v] = v; - + for (i = 0; i < nSelectors; i++) { v = s->selectorMtf[i]; tmp = pos[v]; @@ -337,10 +337,10 @@ Int32 BZ2_decompress ( DState* s ) if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } - BZ2_hbCreateDecodeTables ( - &(s->limit[t][0]), - &(s->base[t][0]), - &(s->perm[t][0]), + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); @@ -439,23 +439,23 @@ Int32 BZ2_decompress ( DState* s ) s->mtfa[(z)-3] = s->mtfa[(z)-4]; nn -= 4; } - while (nn > 0) { - s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; }; s->mtfa[pp] = uc; - } else { + } else { /* general case */ lno = nn / MTFL_SIZE; off = nn % MTFL_SIZE; pp = s->mtfbase[lno] + off; uc = s->mtfa[pp]; - while (pp > s->mtfbase[lno]) { - s->mtfa[pp] = s->mtfa[pp-1]; pp--; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; }; s->mtfbase[lno]++; while (lno > 0) { s->mtfbase[lno]--; - s->mtfa[s->mtfbase[lno]] + s->mtfa[s->mtfbase[lno]] = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; lno--; } @@ -549,8 +549,9 @@ Int32 BZ2_decompress ( DState* s ) s->nblock_used = 0; if (s->blockRandomised) { BZ_RAND_INIT_MASK; - BZ_GET_SMALL(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_GET_SMALL(s->k0); + s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_SMALL(s->k0); s->nblock_used++; } @@ -568,8 +569,9 @@ Int32 BZ2_decompress ( DState* s ) s->nblock_used = 0; if (s->blockRandomised) { BZ_RAND_INIT_MASK; - BZ_GET_FAST(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_GET_FAST(s->k0); + s->nblock_used++; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_FAST(s->k0); s->nblock_used++; } @@ -638,7 +640,7 @@ Int32 BZ2_decompress ( DState* s ) s->save_gBase = gBase; s->save_gPerm = gPerm; - return retVal; + return retVal; } |