diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-10-30 14:27:30 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-10-30 14:27:38 -0400 |
commit | b020ff8074af22639e3f3c0f700f45d067521249 (patch) | |
tree | 52a5dcc3bd2b298e814b8f43c74d6aeac22edced /gdb/cris-tdep.c | |
parent | 1b81856f5b00e7ba860e4de2f3a426f342327165 (diff) | |
download | gdb-b020ff8074af22639e3f3c0f700f45d067521249.zip gdb-b020ff8074af22639e3f3c0f700f45d067521249.tar.gz gdb-b020ff8074af22639e3f3c0f700f45d067521249.tar.bz2 |
Introduce in_inclusive_range, fix -Wtautological-compare warnings
When compiling with clang or gcc 8, we see warnings like this:
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:10013:13: error: comparison of 0 <= unsigned expression is always true [-Werror,-Wtautological-compare]
if (0 <= insn_op1 && 3 >= insn_op1)
~ ^ ~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:11722:20: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]
else if (opB >= 0 && opB <= 2)
~~~ ^ ~
This is because an unsigned integer (opB in this case) will always be >=
0. It is still useful to keep both bounds of the range in the
expression, even if one is at the edge of the data type range. This
patch introduces a utility function in_inclusive_range that gets rid of
the warning while conveying that we are checking for a range.
Tested by rebuilding.
gdb/ChangeLog:
* common/common-utils.h (in_inclusive_range): New function.
* arm-tdep.c (arm_record_extension_space): Use
in_inclusive_range.
(thumb_record_ld_st_reg_offset): Use in_inclusive_range.
* cris-tdep.c (cris_spec_reg_applicable): Use
in_inclusive_range.
Diffstat (limited to 'gdb/cris-tdep.c')
-rw-r--r-- | gdb/cris-tdep.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index d623eb6..416843f 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -1434,19 +1434,19 @@ cris_spec_reg_applicable (struct gdbarch *gdbarch, /* Indeterminate/obsolete. */ return 0; case cris_ver_v0_3: - return (version >= 0 && version <= 3); + return in_inclusive_range (version, 0U, 3U); case cris_ver_v3p: return (version >= 3); case cris_ver_v8: - return (version == 8 || version == 9); + return in_inclusive_range (version, 8U, 9U); case cris_ver_v8p: return (version >= 8); case cris_ver_v0_10: - return (version >= 0 && version <= 10); + return in_inclusive_range (version, 0U, 10U); case cris_ver_v3_10: - return (version >= 3 && version <= 10); + return in_inclusive_range (version, 3U, 10U); case cris_ver_v8_10: - return (version >= 8 && version <= 10); + return in_inclusive_range (version, 8U, 10U); case cris_ver_v10: return (version == 10); case cris_ver_v10p: |