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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user