From c24f1c029572b67c7023aa06a7c24a46cf938367 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 13 Sep 2015 11:36:22 -0500 Subject: [PATCH] Replace BUILD_BUG_ON() with STATIC_ASSERT() --- include/wimlib/bitops.h | 4 ++-- include/wimlib/compiler.h | 7 +++++-- include/wimlib/decompress_common.h | 2 +- include/wimlib/lzms_common.h | 2 +- include/wimlib/reparse.h | 8 ++++---- include/wimlib/wof.h | 6 +++--- src/blob_table.c | 22 +++++++++++----------- src/capture_common.c | 2 +- src/decompress_common.c | 2 +- src/dentry.c | 2 +- src/header.c | 2 +- src/lzms_compress.c | 12 ++++++------ src/lzms_decompress.c | 12 ++++++------ src/lzx_compress.c | 12 ++++++------ src/lzx_decompress.c | 2 +- src/update_image.c | 2 +- src/wimboot.c | 24 ++++++++++++------------ src/win32_apply.c | 2 +- src/write.c | 6 +++--- 19 files changed, 67 insertions(+), 64 deletions(-) diff --git a/include/wimlib/bitops.h b/include/wimlib/bitops.h index 2e7a948f..191e95a1 100644 --- a/include/wimlib/bitops.h +++ b/include/wimlib/bitops.h @@ -44,7 +44,7 @@ fls64(u64 v) static inline unsigned flsw(machine_word_t v) { - BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8); + STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8); if (WORDSIZE == 4) return fls32(v); else @@ -82,7 +82,7 @@ ffs64(u64 v) static inline unsigned ffsw(machine_word_t v) { - BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8); + STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8); if (WORDSIZE == 4) return ffs32(v); else diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 53273188..72c100a2 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -93,8 +93,11 @@ # define _force_attr #endif -#ifndef BUILD_BUG_ON -# define BUILD_BUG_ON(expr) ((void)sizeof(char[1 - 2*!!(expr)])) +/* STATIC_ASSERT() - verify the truth of an expression at compilation time. */ +#if __STDC_VERSION__ >= 201112L +# define STATIC_ASSERT(expr) _Static_assert((expr), "") +#else +# define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)])) #endif #endif /* _WIMLIB_COMPILER_H */ diff --git a/include/wimlib/decompress_common.h b/include/wimlib/decompress_common.h index 70f7dd5a..5d7c4e5a 100644 --- a/include/wimlib/decompress_common.h +++ b/include/wimlib/decompress_common.h @@ -261,7 +261,7 @@ repeat_byte(u8 b) { machine_word_t v; - BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8); + STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8); v = b; v |= v << 8; diff --git a/include/wimlib/lzms_common.h b/include/wimlib/lzms_common.h index 093e50d2..56e35110 100644 --- a/include/wimlib/lzms_common.h +++ b/include/wimlib/lzms_common.h @@ -74,7 +74,7 @@ lzms_init_probabilities(struct lzms_probabilites *probs); static inline void lzms_update_probability_entry(struct lzms_probability_entry *entry, int bit) { - BUILD_BUG_ON(LZMS_PROBABILITY_DENOMINATOR != sizeof(entry->recent_bits) * 8); + STATIC_ASSERT(LZMS_PROBABILITY_DENOMINATOR == sizeof(entry->recent_bits) * 8); #ifdef __x86_64__ if (__builtin_constant_p(bit)) { diff --git a/include/wimlib/reparse.h b/include/wimlib/reparse.h index 235c1680..7627ad41 100644 --- a/include/wimlib/reparse.h +++ b/include/wimlib/reparse.h @@ -52,10 +52,10 @@ struct reparse_buffer_disk { static inline void check_reparse_buffer_disk(void) { - BUILD_BUG_ON(offsetof(struct reparse_buffer_disk, rpdata) != 8); - BUILD_BUG_ON(offsetof(struct reparse_buffer_disk, link.junction.data) != 16); - BUILD_BUG_ON(offsetof(struct reparse_buffer_disk, link.symlink.data) != 20); - BUILD_BUG_ON(sizeof(struct reparse_buffer_disk) != REPARSE_POINT_MAX_SIZE); + STATIC_ASSERT(offsetof(struct reparse_buffer_disk, rpdata) == 8); + STATIC_ASSERT(offsetof(struct reparse_buffer_disk, link.junction.data) == 16); + STATIC_ASSERT(offsetof(struct reparse_buffer_disk, link.symlink.data) == 20); + STATIC_ASSERT(sizeof(struct reparse_buffer_disk) == REPARSE_POINT_MAX_SIZE); } /* Wrapper around a symbolic link or junction reparse point diff --git a/include/wimlib/wof.h b/include/wimlib/wof.h index 71d97d80..85ba31b7 100644 --- a/include/wimlib/wof.h +++ b/include/wimlib/wof.h @@ -294,9 +294,9 @@ struct WimOverlay_dat_entry_2 { static inline void wof_check_structs(void) { - BUILD_BUG_ON(sizeof(struct WimOverlay_dat_header) != 24); - BUILD_BUG_ON(sizeof(struct WimOverlay_dat_entry_1) != 40); - BUILD_BUG_ON(sizeof(struct WimOverlay_dat_entry_2) != 104); + STATIC_ASSERT(sizeof(struct WimOverlay_dat_header) == 24); + STATIC_ASSERT(sizeof(struct WimOverlay_dat_entry_1) == 40); + STATIC_ASSERT(sizeof(struct WimOverlay_dat_entry_2) == 104); } /***************************************************************************** diff --git a/src/blob_table.c b/src/blob_table.c index 43ea4854..dd5bbd7e 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -110,7 +110,7 @@ free_blob_table(struct blob_table *table) struct blob_descriptor * new_blob_descriptor(void) { - BUILD_BUG_ON(BLOB_NONEXISTENT != 0); + STATIC_ASSERT(BLOB_NONEXISTENT == 0); return CALLOC(1, sizeof(struct blob_descriptor)); } @@ -135,8 +135,8 @@ clone_blob_descriptor(const struct blob_descriptor *old) #endif #ifdef WITH_FUSE case BLOB_IN_STAGING_FILE: - BUILD_BUG_ON((void*)&old->file_on_disk != - (void*)&old->staging_file_name); + STATIC_ASSERT((void*)&old->file_on_disk == + (void*)&old->staging_file_name); #endif new->file_on_disk = TSTRDUP(old->file_on_disk); if (new->file_on_disk == NULL) @@ -178,12 +178,12 @@ blob_release_location(struct blob_descriptor *blob) #endif #ifdef WITH_FUSE case BLOB_IN_STAGING_FILE: - BUILD_BUG_ON((void*)&blob->file_on_disk != - (void*)&blob->staging_file_name); + STATIC_ASSERT((void*)&blob->file_on_disk == + (void*)&blob->staging_file_name); #endif case BLOB_IN_ATTACHED_BUFFER: - BUILD_BUG_ON((void*)&blob->file_on_disk != - (void*)&blob->attached_buffer); + STATIC_ASSERT((void*)&blob->file_on_disk == + (void*)&blob->attached_buffer); FREE(blob->file_on_disk); break; #ifdef WITH_NTFS_3G @@ -638,10 +638,10 @@ do_load_solid_info(WIMStruct *wim, struct wim_resource_descriptor **rdescs, /* Compression format numbers must be the same as in * WIMGAPI to be compatible here. */ - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_NONE != 0); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_XPRESS != 1); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZX != 2); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZMS != 3); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_NONE == 0); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_XPRESS == 1); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_LZX == 2); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_LZMS == 3); rdesc->compression_type = le32_to_cpu(hdr.compression_format); rdesc->chunk_size = le32_to_cpu(hdr.chunk_size); } diff --git a/src/capture_common.c b/src/capture_common.c index 353ff2b6..0a2f26cd 100644 --- a/src/capture_common.c +++ b/src/capture_common.c @@ -135,7 +135,7 @@ mangle_pat(tchar *pat, const tchar *path, unsigned long line_no) * Note: we expect that this function produces patterns that can be used * for both filesystem paths and WIM paths, so the desired path * separators must be the same. */ - BUILD_BUG_ON(OS_PREFERRED_PATH_SEPARATOR != WIM_PATH_SEPARATOR); + STATIC_ASSERT(OS_PREFERRED_PATH_SEPARATOR == WIM_PATH_SEPARATOR); do_canonicalize_path(pat, pat); /* Relative patterns can only match file names, so they must be diff --git a/src/decompress_common.c b/src/decompress_common.c index c2f76955..a490882d 100644 --- a/src/decompress_common.c +++ b/src/decompress_common.c @@ -281,7 +281,7 @@ make_huffman_decode_table(u16 decode_table[const], aliased_word_t *p; unsigned n; - BUILD_BUG_ON(WORDSIZE != 4 && WORDSIZE != 8); + STATIC_ASSERT(WORDSIZE == 4 || WORDSIZE == 8); v = MAKE_DIRECT_ENTRY(sorted_syms[sym_idx], codeword_len); v |= v << 16; diff --git a/src/dentry.c b/src/dentry.c index 4f842eaa..13940a32 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -1394,7 +1394,7 @@ read_dentry(const u8 * restrict buf, size_t buf_len, u64 calculated_size; int ret; - BUILD_BUG_ON(sizeof(struct wim_dentry_on_disk) != WIM_DENTRY_DISK_SIZE); + STATIC_ASSERT(sizeof(struct wim_dentry_on_disk) == WIM_DENTRY_DISK_SIZE); /* Before reading the whole dentry, we need to read just the length. * This is because a dentry of length 8 (that is, just the length field) diff --git a/src/header.c b/src/header.c index d5449507..cf193963 100644 --- a/src/header.c +++ b/src/header.c @@ -76,7 +76,7 @@ read_wim_header(WIMStruct *wim, struct wim_header *hdr) filename = pipe_str; } - BUILD_BUG_ON(sizeof(struct wim_header_disk) != WIM_HEADER_DISK_SIZE); + STATIC_ASSERT(sizeof(struct wim_header_disk) == WIM_HEADER_DISK_SIZE); ret = full_read(in_fd, &disk_hdr, sizeof(disk_hdr)); if (ret) diff --git a/src/lzms_compress.c b/src/lzms_compress.c index f438e91c..099a9dbf 100644 --- a/src/lzms_compress.c +++ b/src/lzms_compress.c @@ -173,7 +173,7 @@ struct lzms_item { static inline void check_that_powers_fit_in_bitfield(void) { - BUILD_BUG_ON(LZMS_NUM_DELTA_POWER_SYMS > (1 << (31 - DELTA_SOURCE_POWER_SHIFT))); + STATIC_ASSERT(LZMS_NUM_DELTA_POWER_SYMS <= (1 << (31 - DELTA_SOURCE_POWER_SHIFT))); } /* A stripped-down version of the adaptive state in LZMS which excludes the @@ -975,7 +975,7 @@ static inline void check_cost_shift(void) { /* lzms_bit_costs is hard-coded to the current COST_SHIFT. */ - BUILD_BUG_ON(COST_SHIFT != 6); + STATIC_ASSERT(COST_SHIFT == 6); } #if 0 @@ -1180,7 +1180,7 @@ static void lzms_init_delta_matchfinder(struct lzms_compressor *c) { /* Set all entries to use an invalid power, which will never match. */ - BUILD_BUG_ON(NUM_POWERS_TO_CONSIDER >= (1 << (32 - DELTA_SOURCE_POWER_SHIFT))); + STATIC_ASSERT(NUM_POWERS_TO_CONSIDER < (1 << (32 - DELTA_SOURCE_POWER_SHIFT))); memset(c->delta_hash_table, 0xFF, sizeof(c->delta_hash_table)); /* Initialize the next hash code for each power. We can just use zeroes @@ -1203,7 +1203,7 @@ lzms_delta_hash(const u8 *p, const u32 pos, u32 span) * include in the hash code computation the span and the low-order bits * of the current position. */ - BUILD_BUG_ON(NBYTES_HASHED_FOR_DELTA != 3); + STATIC_ASSERT(NBYTES_HASHED_FOR_DELTA == 3); u8 d0 = *(p + 0) - *(p + 0 - span); u8 d1 = *(p + 1) - *(p + 1 - span); u8 d2 = *(p + 2) - *(p + 2 - span); @@ -1712,7 +1712,7 @@ begin: const u32 pos = in_next - c->in_buffer; /* Consider each possible power (log2 of span) */ - BUILD_BUG_ON(NUM_POWERS_TO_CONSIDER > LZMS_NUM_DELTA_POWER_SYMS); + STATIC_ASSERT(NUM_POWERS_TO_CONSIDER <= LZMS_NUM_DELTA_POWER_SYMS); for (u32 power = 0; power < NUM_POWERS_TO_CONSIDER; power++) { const u32 span = (u32)1 << power; @@ -1741,7 +1741,7 @@ begin: /* Check the first 3 bytes before entering the * extension loop. */ - BUILD_BUG_ON(NBYTES_HASHED_FOR_DELTA != 3); + STATIC_ASSERT(NBYTES_HASHED_FOR_DELTA == 3); if (((u8)(*(in_next + 0) - *(in_next + 0 - span)) != (u8)(*(matchptr + 0) - *(matchptr + 0 - span))) || ((u8)(*(in_next + 1) - *(in_next + 1 - span)) != diff --git a/src/lzms_decompress.c b/src/lzms_decompress.c index 5093a3d3..345b51db 100644 --- a/src/lzms_decompress.c +++ b/src/lzms_decompress.c @@ -796,7 +796,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, if (pending_lz_offset != 0 && out_next != lz_offset_still_pending) { - BUILD_BUG_ON(LZMS_NUM_LZ_REPS != 3); + STATIC_ASSERT(LZMS_NUM_LZ_REPS == 3); recent_lz_offsets[3] = recent_lz_offsets[2]; recent_lz_offsets[2] = recent_lz_offsets[1]; recent_lz_offsets[1] = recent_lz_offsets[0]; @@ -804,7 +804,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, pending_lz_offset = 0; } - BUILD_BUG_ON(LZMS_NUM_LZ_REPS != 3); + STATIC_ASSERT(LZMS_NUM_LZ_REPS == 3); if (!lzms_decode_bit(&rd, &lz_rep_states[0], LZMS_NUM_LZ_REP_PROBS, d->probs.lz_rep[0])) @@ -827,7 +827,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, } if (pending_lz_offset != 0) { - BUILD_BUG_ON(LZMS_NUM_LZ_REPS != 3); + STATIC_ASSERT(LZMS_NUM_LZ_REPS == 3); recent_lz_offsets[3] = recent_lz_offsets[2]; recent_lz_offsets[2] = recent_lz_offsets[1]; recent_lz_offsets[1] = recent_lz_offsets[0]; @@ -872,7 +872,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, if (pending_delta_pair != 0 && out_next != delta_pair_still_pending) { - BUILD_BUG_ON(LZMS_NUM_DELTA_REPS != 3); + STATIC_ASSERT(LZMS_NUM_DELTA_REPS == 3); recent_delta_pairs[3] = recent_delta_pairs[2]; recent_delta_pairs[2] = recent_delta_pairs[1]; recent_delta_pairs[1] = recent_delta_pairs[0]; @@ -880,7 +880,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, pending_delta_pair = 0; } - BUILD_BUG_ON(LZMS_NUM_DELTA_REPS != 3); + STATIC_ASSERT(LZMS_NUM_DELTA_REPS == 3); if (!lzms_decode_bit(&rd, &delta_rep_states[0], LZMS_NUM_DELTA_REP_PROBS, d->probs.delta_rep[0])) @@ -905,7 +905,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, } if (pending_delta_pair != 0) { - BUILD_BUG_ON(LZMS_NUM_DELTA_REPS != 3); + STATIC_ASSERT(LZMS_NUM_DELTA_REPS == 3); recent_delta_pairs[3] = recent_delta_pairs[2]; recent_delta_pairs[2] = recent_delta_pairs[1]; recent_delta_pairs[1] = recent_delta_pairs[0]; diff --git a/src/lzx_compress.c b/src/lzx_compress.c index 3f3b836c..339f27fe 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -1121,8 +1121,8 @@ lzx_declare_explicit_offset_match(struct lzx_compressor *c, unsigned len, u32 of extra_bits = (offset + LZX_OFFSET_ADJUSTMENT) - lzx_offset_slot_base[offset_slot]; - BUILD_BUG_ON(LZX_MAINCODE_MAX_NUM_SYMBOLS > (1 << 10)); - BUILD_BUG_ON(LZX_LENCODE_NUM_SYMBOLS > (1 << 8)); + STATIC_ASSERT(LZX_MAINCODE_MAX_NUM_SYMBOLS <= (1 << 10)); + STATIC_ASSERT(LZX_LENCODE_NUM_SYMBOLS <= (1 << 8)); *(*next_chosen_item)++ = (struct lzx_item) { .data = (u64)main_symbol | ((u64)len_symbol << 10) | @@ -1242,7 +1242,7 @@ lzx_find_min_cost_path(struct lzx_compressor * const restrict c, * it is no longer needed. */ struct lzx_lru_queue queues[512]; - BUILD_BUG_ON(ARRAY_LEN(queues) < LZX_MAX_MATCH_LEN + 1); + STATIC_ASSERT(ARRAY_LEN(queues) >= LZX_MAX_MATCH_LEN + 1); #define QUEUE(in) (queues[(uintptr_t)(in) % ARRAY_LEN(queues)]) /* Initially, the cost to reach each node is "infinity". */ @@ -1294,7 +1294,7 @@ lzx_find_min_cost_path(struct lzx_compressor * const restrict c, matchptr = in_next - lzx_lru_queue_R0(QUEUE(in_next)); if (load_u16_unaligned(matchptr) != load_u16_unaligned(in_next)) goto R0_done; - BUILD_BUG_ON(LZX_MIN_MATCH_LEN != 2); + STATIC_ASSERT(LZX_MIN_MATCH_LEN == 2); do { u32 cost = cur_node->cost + c->costs.match_cost[0][ @@ -1479,7 +1479,7 @@ lzx_set_default_costs(struct lzx_compressor *c, const u8 *block, u32 block_size) unsigned num_used_bytes; /* The costs below are hard coded to use a scaling factor of 16. */ - BUILD_BUG_ON(LZX_BIT_COST != 16); + STATIC_ASSERT(LZX_BIT_COST == 16); /* * Heuristics: @@ -1734,7 +1734,7 @@ lzx_find_longest_repeat_offset_match(const u8 * const in_next, struct lzx_lru_queue queue, unsigned *rep_max_idx_ret) { - BUILD_BUG_ON(LZX_NUM_RECENT_OFFSETS != 3); + STATIC_ASSERT(LZX_NUM_RECENT_OFFSETS == 3); LZX_ASSERT(bytes_remaining >= 2); const unsigned max_len = min(bytes_remaining, LZX_MAX_MATCH_LEN); diff --git a/src/lzx_decompress.c b/src/lzx_decompress.c index a8fbcd7d..687420a9 100644 --- a/src/lzx_decompress.c +++ b/src/lzx_decompress.c @@ -498,7 +498,7 @@ lzx_decompress_block(int block_type, u8 * const out_begin, match_offset -= LZX_OFFSET_ADJUSTMENT; /* Update the match offset LRU queue. */ - BUILD_BUG_ON(LZX_NUM_RECENT_OFFSETS != 3); + STATIC_ASSERT(LZX_NUM_RECENT_OFFSETS == 3); queue->R[2] = queue->R[1]; queue->R[1] = queue->R[0]; queue->R[0] = match_offset; diff --git a/src/update_image.c b/src/update_image.c index 03eb122e..2b2c107b 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -689,7 +689,7 @@ attach_branch(struct wim_dentry *branch, const tchar *target_tstr, if (ret) goto out_free_branch; - BUILD_BUG_ON(WIM_PATH_SEPARATOR != OS_PREFERRED_PATH_SEPARATOR); + STATIC_ASSERT(WIM_PATH_SEPARATOR == OS_PREFERRED_PATH_SEPARATOR); ret = dentry_set_name(branch, path_basename(target_tstr)); if (ret) goto out_free_target; diff --git a/src/wimboot.c b/src/wimboot.c index 67798da3..d4643d67 100644 --- a/src/wimboot.c +++ b/src/wimboot.c @@ -187,8 +187,8 @@ query_partition_and_disk_info(const wchar_t *path, } if (part_info->PartitionStyle == PARTITION_STYLE_GPT) { - BUILD_BUG_ON(sizeof(part_info->Gpt.PartitionId) != - sizeof(drive_info->Gpt.DiskId)); + STATIC_ASSERT(sizeof(part_info->Gpt.PartitionId) == + sizeof(drive_info->Gpt.DiskId)); if (!memcmp(&part_info->Gpt.PartitionId, &drive_info->Gpt.DiskId, sizeof(drive_info->Gpt.DiskId))) @@ -395,7 +395,7 @@ fill_in_wimoverlay_dat(u8 *buf, new_entry_1->entry_2_length = new_entry_2_size; new_entry_1->wim_type = WIM_BOOT_NOT_OS_WIM; new_entry_1->wim_index = image; - BUILD_BUG_ON(sizeof(new_entry_1->guid) != GUID_SIZE); + STATIC_ASSERT(sizeof(new_entry_1->guid) == GUID_SIZE); copy_guid(new_entry_1->guid, wim_guid); p += sizeof(struct WimOverlay_dat_entry_1); @@ -438,21 +438,21 @@ fill_in_wimoverlay_dat(u8 *buf, new_entry_2->disk.mbr.padding[1] = 0x00000000; new_entry_2->disk.mbr.padding[2] = 0x00000000; } else { - BUILD_BUG_ON(sizeof(new_entry_2->partition.gpt.part_unique_guid) != - sizeof(part_info->Gpt.PartitionId)); + STATIC_ASSERT(sizeof(new_entry_2->partition.gpt.part_unique_guid) == + sizeof(part_info->Gpt.PartitionId)); memcpy(new_entry_2->partition.gpt.part_unique_guid, &part_info->Gpt.PartitionId, sizeof(part_info->Gpt.PartitionId)); new_entry_2->partition_table_type = WIMOVERLAY_PARTITION_TYPE_GPT; - BUILD_BUG_ON(sizeof(new_entry_2->disk.gpt.disk_guid) != - sizeof(disk_info->Gpt.DiskId)); + STATIC_ASSERT(sizeof(new_entry_2->disk.gpt.disk_guid) == + sizeof(disk_info->Gpt.DiskId)); memcpy(new_entry_2->disk.gpt.disk_guid, &disk_info->Gpt.DiskId, sizeof(disk_info->Gpt.DiskId)); - BUILD_BUG_ON(sizeof(new_entry_2->disk.gpt.disk_guid) != - sizeof(new_entry_2->partition.gpt.part_unique_guid)); + STATIC_ASSERT(sizeof(new_entry_2->disk.gpt.disk_guid) == + sizeof(new_entry_2->partition.gpt.part_unique_guid)); } new_entry_2->unknown_0x58[0] = 0x00000000; new_entry_2->unknown_0x58[1] = 0x00000000; @@ -1135,9 +1135,9 @@ wimboot_set_pointer(HANDLE h, struct wim_provider_rpdata wim_info; } in; - BUILD_BUG_ON(sizeof(in) != 8 + - sizeof(struct wof_external_info) + - sizeof(struct wim_provider_rpdata)); + STATIC_ASSERT(sizeof(in) == 8 + + sizeof(struct wof_external_info) + + sizeof(struct wim_provider_rpdata)); in.hdr.rptag = WIM_IO_REPARSE_TAG_WOF; in.hdr.rpdatalen = sizeof(in) - sizeof(in.hdr); diff --git a/src/win32_apply.c b/src/win32_apply.c index 03677195..c030ba53 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -352,7 +352,7 @@ load_prepopulate_pats(struct win32_apply_ctx *ctx) LOAD_TEXT_FILE_REMOVE_QUOTES | LOAD_TEXT_FILE_NO_WARNINGS, mangle_pat); - BUILD_BUG_ON(OS_PREFERRED_PATH_SEPARATOR != WIM_PATH_SEPARATOR); + STATIC_ASSERT(OS_PREFERRED_PATH_SEPARATOR == WIM_PATH_SEPARATOR); FREE(buf); if (ret) { FREE(s); diff --git a/src/write.c b/src/write.c index b2e687a8..b595c875 100644 --- a/src/write.c +++ b/src/write.c @@ -548,9 +548,9 @@ end_chunk_table(struct write_blobs_ctx *ctx, u64 res_actual_size, hdr.chunk_size = cpu_to_le32(ctx->out_chunk_size); hdr.compression_format = cpu_to_le32(ctx->out_ctype); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_XPRESS != 1); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZX != 2); - BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZMS != 3); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_XPRESS == 1); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_LZX == 2); + STATIC_ASSERT(WIMLIB_COMPRESSION_TYPE_LZMS == 3); ret = full_pwrite(ctx->out_fd, &hdr, sizeof(hdr), chunk_table_offset - sizeof(hdr)); -- 2.43.0