From 42a829e6233e42f0882c6ee7c5bcbd8506aab422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 5 May 2022 16:10:51 +0200 Subject: [PATCH] Delete implicit conversion from rtc::scoped_refptr to T* Bug: webrtc:13464 Change-Id: I24c742c11a4ea5c4e307e170ee4fbd4e81cf1814 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260325 Commit-Queue: Niels Moller Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36808} --- api/scoped_refptr.h | 21 +++++++++++++++++++-- test/fuzzers/sdp_integration_fuzzer.cc | 11 +++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/api/scoped_refptr.h b/api/scoped_refptr.h index b1c90fcbbe..e145509127 100644 --- a/api/scoped_refptr.h +++ b/api/scoped_refptr.h @@ -105,8 +105,6 @@ class scoped_refptr { T* get() const { return ptr_; } explicit operator bool() const { return ptr_ != nullptr; } - // TODO(bugs.webrtc.org/13464): Delete this conversion operator. - operator T*() const { return ptr_; } T& operator*() const { return *ptr_; } T* operator->() const { return ptr_; } @@ -194,6 +192,25 @@ bool operator!=(std::nullptr_t, const rtc::scoped_refptr& a) { return !(a == nullptr); } +// Comparison with raw pointer. +template +bool operator==(const rtc::scoped_refptr& a, const U* b) { + return a.get() == b; +} +template +bool operator!=(const rtc::scoped_refptr& a, const U* b) { + return !(a == b); +} + +template +bool operator==(const T* a, const rtc::scoped_refptr& b) { + return a == b.get(); +} +template +bool operator!=(const T* a, const rtc::scoped_refptr& b) { + return !(a == b); +} + // Ordered comparison, needed for use as a std::map key. template bool operator<(const rtc::scoped_refptr& a, const rtc::scoped_refptr& b) { diff --git a/test/fuzzers/sdp_integration_fuzzer.cc b/test/fuzzers/sdp_integration_fuzzer.cc index 2a8be3978c..ece4b50505 100644 --- a/test/fuzzers/sdp_integration_fuzzer.cc +++ b/test/fuzzers/sdp_integration_fuzzer.cc @@ -27,22 +27,21 @@ class FuzzerTest : public PeerConnectionIntegrationBaseTest { // generated are discarded. auto srd_observer = - rtc::make_ref_counted(); + rtc::make_ref_counted(); SdpParseError error; std::unique_ptr sdp( CreateSessionDescription("offer", std::string(message), &error)); - // Note: This form of SRD takes ownership of the description. - caller()->pc()->SetRemoteDescription(srd_observer, sdp.release()); + caller()->pc()->SetRemoteDescription(std::move(sdp), srd_observer); // Wait a short time for observer to be called. Timeout is short // because the fuzzer should be trying many branches. EXPECT_TRUE_WAIT(srd_observer->called(), 100); // If set-remote-description was successful, try to answer. auto sld_observer = - rtc::make_ref_counted(); - if (srd_observer->result()) { - caller()->pc()->SetLocalDescription(sld_observer.get()); + rtc::make_ref_counted(); + if (srd_observer->error().ok()) { + caller()->pc()->SetLocalDescription(sld_observer); EXPECT_TRUE_WAIT(sld_observer->called(), 100); } // If there is an EXPECT failure, die here.