Replace BUILD_BUG_ON() with STATIC_ASSERT()
authorEric Biggers <ebiggers3@gmail.com>
Sun, 13 Sep 2015 16:36:22 +0000 (11:36 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 19 Sep 2015 16:36:28 +0000 (11:36 -0500)
19 files changed:
include/wimlib/bitops.h
include/wimlib/compiler.h
include/wimlib/decompress_common.h
include/wimlib/lzms_common.h
include/wimlib/reparse.h
include/wimlib/wof.h
src/blob_table.c
src/capture_common.c
src/decompress_common.c
src/dentry.c
src/header.c
src/lzms_compress.c
src/lzms_decompress.c
src/lzx_compress.c
src/lzx_decompress.c
src/update_image.c
src/wimboot.c
src/win32_apply.c
src/write.c

index 2e7a948..191e95a 100644 (file)
@@ -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
index 5327318..72c100a 100644 (file)
 #  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 */
index 70f7dd5..5d7c4e5 100644 (file)
@@ -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;
index 093e50d..56e3511 100644 (file)
@@ -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)) {
index 235c168..7627ad4 100644 (file)
@@ -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
index 71d97d8..85ba31b 100644 (file)
@@ -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);
 }
 
 /*****************************************************************************
index 43ea485..dd5bbd7 100644 (file)
@@ -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);
        }
index 353ff2b..0a2f26c 100644 (file)
@@ -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
index c2f7695..a490882 100644 (file)
@@ -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;
index 4f842ea..13940a3 100644 (file)
@@ -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)
index d544950..cf19396 100644 (file)
@@ -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)
index f438e91..099a9db 100644 (file)
@@ -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)) !=
index 5093a3d..345b51d 100644 (file)
@@ -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];
index 3f3b836..339f27f 100644 (file)
@@ -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);
index a8fbcd7..687420a 100644 (file)
@@ -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;
index 03eb122..2b2c107 100644 (file)
@@ -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;
index 67798da..d4643d6 100644 (file)
@@ -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);
index 0367719..c030ba5 100644 (file)
@@ -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);
index b2e687a..b595c87 100644 (file)
@@ -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));