Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Issue 2459793002: Let RTC_[D]CHECK_op accept arguments of different signedness (Closed)

Created:
4 years, 1 month ago by kwiberg-webrtc
Modified:
4 years, 1 month ago
Reviewers:
tommi, ossu
CC:
webrtc-reviews_webrtc.org, yujie_mao (webrtc), hlundin-webrtc, tlegrand-webrtc, tterriberry_mozilla.com, audio-team_agora.io, qiang.lu, niklas.enbom, peah-webrtc, minyue-webrtc
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

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 Committed: https://crrev.com/8a44e1d87b2f80db21eda24d0c0c5742c2060827 Cr-Commit-Position: refs/heads/master@{#14878}

Patch Set 1 #

Total comments: 15

Patch Set 2 : by value #

Unified diffs Side-by-side diffs Delta from patch set Stats (+588 lines, -27 lines) Patch
M webrtc/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/base/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/base/checks.h View 4 chunks +25 lines, -25 lines 0 comments Download
A webrtc/base/safe_compare.h View 1 1 chunk +180 lines, -0 lines 0 comments Download
A webrtc/base/safe_compare_unittest.cc View 1 chunk +379 lines, -0 lines 0 comments Download
M webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc View 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 27 (13 generated)
kwiberg-webrtc
Weekend hacking project. Good idea? https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h File webrtc/base/safe_compare.h (right): https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h#newcode136 webrtc/base/safe_compare.h:136: static constexpr bool Op(T1&& ...
4 years, 1 month ago (2016-10-31 09:16:01 UTC) #6
ossu
It's a pretty sweet solution to the problem, but I'm not sure if it's worth ...
4 years, 1 month ago (2016-10-31 16:44:57 UTC) #8
kwiberg-webrtc
https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h File webrtc/base/safe_compare.h (right): https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h#newcode28 webrtc/base/safe_compare.h:28: // zero; in the remaining cases, it is just ...
4 years, 1 month ago (2016-10-31 21:32:26 UTC) #9
kwiberg-webrtc
On 2016/10/31 16:44:57, ossu wrote: > It's a pretty sweet solution to the problem, but ...
4 years, 1 month ago (2016-10-31 21:46:23 UTC) #10
kwiberg-webrtc
On 2016/10/31 21:46:23, kwiberg-webrtc wrote: > Well, yes, for CHECKs that's probably the most common ...
4 years, 1 month ago (2016-11-01 15:26:29 UTC) #11
ossu
Now that you mention it: the non-constant version of these comparisons is actually _much_ more ...
4 years, 1 month ago (2016-11-01 15:36:57 UTC) #12
kwiberg-webrtc
https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h File webrtc/base/safe_compare.h (right): https://codereview.webrtc.org/2459793002/diff/80001/webrtc/base/safe_compare.h#newcode28 webrtc/base/safe_compare.h:28: // zero; in the remaining cases, it is just ...
4 years, 1 month ago (2016-11-01 16:14:06 UTC) #13
ossu
Alright, looks good to me. Maybe run it by someone else for approval as well. ...
4 years, 1 month ago (2016-11-01 16:48:07 UTC) #14
ossu
Oh, and that's lgtm in computer-speak. Looked through the individual tests as well. Now my ...
4 years, 1 month ago (2016-11-01 17:28:22 UTC) #15
kwiberg-webrtc
Adding an additional reviewer. In addition to the commit message, the tl;dr is * "git ...
4 years, 1 month ago (2016-11-01 17:53:34 UTC) #19
tommi
lgtm. nice!
4 years, 1 month ago (2016-11-01 17:57:55 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2459793002/100001
4 years, 1 month ago (2016-11-01 18:39:13 UTC) #23
commit-bot: I haz the power
Committed patchset #2 (id:100001)
4 years, 1 month ago (2016-11-01 19:04:30 UTC) #25
commit-bot: I haz the power
4 years, 1 month ago (2016-11-01 19:32:14 UTC) #27
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/8a44e1d87b2f80db21eda24d0c0c5742c2060827
Cr-Commit-Position: refs/heads/master@{#14878}

Powered by Google App Engine
This is Rietveld 408576698