Skip to content

Commit

Permalink
Address review concern
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-hbrhbr committed Dec 12, 2024
1 parent e751ee6 commit 1c5efcd
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ auto is_flush_action(lzma_action action) -> bool;

/**
* Initializes the LZMA compression stream
* @param strm A pre-allocated `lzma_stream` object
* @param stream A pre-allocated `lzma_stream` object
* @param compression_level
* @param dict_size Dictionary size that specifies how many bytes of the
* recently processed uncompressed data to keep in the memory
*/
auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_size) -> void;
auto init_lzma_encoder(lzma_stream* stream, int compression_level, size_t dict_size) -> void;

auto is_flush_action(lzma_action action) -> bool {
return LZMA_SYNC_FLUSH == action || LZMA_FULL_FLUSH == action || LZMA_FULL_BARRIER == action
|| LZMA_FINISH == action;
}

auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_size) -> void {
auto init_lzma_encoder(lzma_stream* stream, int compression_level, size_t dict_size) -> void {
lzma_options_lzma options;
if (0 != lzma_lzma_preset(&options, compression_level)) {
SPDLOG_ERROR("Failed to initialize LZMA options' compression level.");
Expand All @@ -48,7 +48,7 @@ auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_siz
// Initializes the encoder using a preset. Set the integrity to check to CRC64, which is the
// default in the xz command line tool. If the .xz file needs to be decompressed with
// XZ-Embedded, use LZMA_CHECK_CRC32 instead.
auto const rc{lzma_stream_encoder(strm, filters.data(), LZMA_CHECK_CRC64)};
auto const rc = lzma_stream_encoder(stream, filters.data(), LZMA_CHECK_CRC64);

if (LZMA_OK == rc) {
return;
Expand All @@ -71,8 +71,11 @@ auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_siz
msg = "Specified integrity check is not supported";
break;

case LZMA_PROG_ERROR:
msg = "Input arguments are not sane";
break;

default:
// This is most likely LZMA_PROG_ERROR indicating a bug in liblzma
msg = "Unknown error";
break;
}
Expand Down

0 comments on commit 1c5efcd

Please sign in to comment.