X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fresource.c;h=f37b8958300e6cd024a8882f559ed0d043781926;hp=d60f5476ebadd9557e948e6c7e823f5d30e536b5;hb=fced769402ff6ef0bf75fe9e4dcb2880891469e0;hpb=761ec06065819eb2af9e2554813f8b87ff48f695 diff --git a/src/resource.c b/src/resource.c index d60f5476..f37b8958 100644 --- a/src/resource.c +++ b/src/resource.c @@ -97,8 +97,8 @@ read_compressed_resource(int in_fd, /* Calculate how many chunks the resource consists of in its entirety. * */ - u64 num_chunks = (resource_uncompressed_size + WIM_CHUNK_SIZE - 1) / - WIM_CHUNK_SIZE; + u64 num_chunks = DIV_ROUND_UP(resource_uncompressed_size, WIM_CHUNK_SIZE); + /* As mentioned, the first chunk has no entry in the chunk table. */ u64 num_chunk_entries = num_chunks - 1; @@ -691,13 +691,13 @@ extract_wim_resource(const struct wim_lookup_table_entry *lte, u8 hash[SHA1_HASH_SIZE]; sha1_final(hash, &ctx.sha_ctx); if (!hashes_equal(hash, lte->hash)) { - #ifdef ENABLE_ERROR_MESSAGES - ERROR("Invalid SHA1 message digest " - "on the following WIM resource:"); - print_lookup_table_entry(lte, stderr); - if (lte->resource_location == RESOURCE_IN_WIM) - ERROR("The WIM file appears to be corrupt!"); - #endif + if (wimlib_print_errors) { + ERROR("Invalid SHA1 message digest " + "on the following WIM resource:"); + print_lookup_table_entry(lte, stderr); + if (lte->resource_location == RESOURCE_IN_WIM) + ERROR("The WIM file appears to be corrupt!"); + } ret = WIMLIB_ERR_INVALID_RESOURCE_HASH; } }