Let RTC_[D]CHECK_op accept arguments of different signedness

With this change, instead of

  RTC_DCHECK_GE(unsigned_var, 17u);

we can simply write

  RTC_DCHECK_GE(unsigned_var, 17);

or even

  RTC_DCHECK_GE(unsigned_var, -17);  // Always true.

and the mathematically sensible thing will happen.

Perhaps more importantly, we can replace checks like

  // index is size_t, num_channels is int.
  RTC_DCHECK(num_channels >= 0
             && index < static_cast<size_t>(num_channels));

or, even worse, just

  // Surely num_channels isn't negative. That would be absurd!
  RTC_DCHECK_LT(index, static_cast<size_t>(num_channels));

with simply

  RTC_DCHECK_LT(index, num_channels);

In short, you no longer have to keep track of the signedness of the arguments, because the sensible thing will happen.

BUG=webrtc:6645

Review-Url: https://codereview.webrtc.org/2459793002
Cr-Commit-Position: refs/heads/master@{#14878}
This commit is contained in:
kwiberg
2016-11-01 12:04:26 -07:00
committed by Commit bot
parent 803d97f159
commit 8a44e1d87b
6 changed files with 588 additions and 27 deletions

View File

@ -134,7 +134,7 @@ int DtmfToneGenerator::Init(int fs, int event, int attenuation) {
}
// Look up oscillator coefficient for low and high frequencies.
RTC_DCHECK_LE(0u, fs_index);
RTC_DCHECK_LE(0, fs_index);
RTC_DCHECK_GT(arraysize(kCoeff1), fs_index);
RTC_DCHECK_GT(arraysize(kCoeff2), fs_index);
RTC_DCHECK_LE(0, event);
@ -149,7 +149,7 @@ int DtmfToneGenerator::Init(int fs, int event, int attenuation) {
amplitude_ = kAmplitude[attenuation];
// Initialize sample history.
RTC_DCHECK_LE(0u, fs_index);
RTC_DCHECK_LE(0, fs_index);
RTC_DCHECK_GT(arraysize(kInitValue1), fs_index);
RTC_DCHECK_GT(arraysize(kInitValue2), fs_index);
RTC_DCHECK_LE(0, event);