diff options
author | zbao <fishbaozi@gmail.com> | 2015-11-05 14:35:57 +0800 |
---|---|---|
committer | Zheng Bao <zheng.bao@amd.com> | 2015-11-20 05:36:48 +0100 |
commit | 37450ff5343ffa3326a3f23a8ae7448d48e14e3c (patch) | |
tree | cd973e287cf98b752b6052c888bf6ef48f88e770 /util/cbfstool | |
parent | f730e44baaf061e2ab8ea4e21b5b0d60bc681dc3 (diff) |
cbfstool: Fix build error with clang when comparing enum
If HOSTCC=clang, the -Wtautological-constant-out-of-range-compare is
set automaticaaly. That assume the value of type enum is in the defined
range. Then testing if a type enum is out of range causes build error.
Error:
coreboot/util/cbfstool/cbfs_image.c:1387:16: error:
comparison of constant 4 with expression of type 'enum vb2_hash_algorithm'
is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (hash_type >= CBFS_NUM_SUPPORTED_HASHES)
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
clang version:
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.2
Thread model: posix
Change-Id: I3e1722bf6f9553793a9f0c7f4e790706b6938522
Signed-off-by: zbao <fishbaozi@gmail.com>
Reviewed-on: http://review.coreboot.org/12330
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/cbfstool')
-rw-r--r-- | util/cbfstool/cbfs_image.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 2b250114d0..1cfe90d273 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -1389,7 +1389,9 @@ struct cbfs_file_attribute *cbfs_add_file_attr(struct cbfs_file *header, int cbfs_add_file_hash(struct cbfs_file *header, struct buffer *buffer, enum vb2_hash_algorithm hash_type) { - if (hash_type >= CBFS_NUM_SUPPORTED_HASHES) + uint32_t hash_index = hash_type; + + if (hash_index >= CBFS_NUM_SUPPORTED_HASHES) return -1; unsigned hash_size = widths_cbfs_hash[hash_type]; |