Skip to content

Commit

Permalink
Enable clang::find_bad_constructs for sdk/android (part 1/2).
Browse files Browse the repository at this point in the history
This CL removes //build/config/clang:find_bad_constructs from the
suppressed_configs list, which means that clang:find_bad_constructs
is now enabled on these translation units.

Bug: webrtc:9251, webrtc:163, webrtc:9544
Change-Id: I7c211c4ac6b2e095e4c6594fce09fdb487bb1d9e
Reviewed-on: https://webrtc-review.googlesource.com/89600
Reviewed-by: Steve Anton <[email protected]>
Reviewed-by: Sami Kalliomäki <[email protected]>
Commit-Queue: Mirko Bonadei <[email protected]>
Cr-Commit-Position: refs/heads/master@{#24056}
  • Loading branch information
MirkoBonadei authored and Commit Bot committed Jul 20, 2018
1 parent 97ddbd7 commit 2ffed6d
Show file tree
Hide file tree
Showing 23 changed files with 176 additions and 101 deletions.
1 change: 1 addition & 0 deletions api/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ rtc_static_library("libjingle_peerconnection_api") {
"dtmfsenderinterface.h",
"jsep.cc",
"jsep.h",
"jsepicecandidate.cc",
"jsepicecandidate.h",
"jsepsessiondescription.h",
"mediaconstraintsinterface.cc",
Expand Down
83 changes: 83 additions & 0 deletions api/jsepicecandidate.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#include "api/jsepicecandidate.h"

namespace webrtc {

std::string JsepIceCandidate::sdp_mid() const {
return sdp_mid_;
}

int JsepIceCandidate::sdp_mline_index() const {
return sdp_mline_index_;
}

const cricket::Candidate& JsepIceCandidate::candidate() const {
return candidate_;
}

std::string JsepIceCandidate::server_url() const {
return candidate_.url();
}

JsepCandidateCollection::JsepCandidateCollection() = default;

JsepCandidateCollection::JsepCandidateCollection(JsepCandidateCollection&& o)
: candidates_(std::move(o.candidates_)) {}

size_t JsepCandidateCollection::count() const {
return candidates_.size();
}

void JsepCandidateCollection::add(JsepIceCandidate* candidate) {
candidates_.push_back(candidate);
}

const IceCandidateInterface* JsepCandidateCollection::at(size_t index) const {
return candidates_[index];
}

JsepCandidateCollection::~JsepCandidateCollection() {
for (std::vector<JsepIceCandidate*>::iterator it = candidates_.begin();
it != candidates_.end(); ++it) {
delete *it;
}
}

bool JsepCandidateCollection::HasCandidate(
const IceCandidateInterface* candidate) const {
bool ret = false;
for (std::vector<JsepIceCandidate*>::const_iterator it = candidates_.begin();
it != candidates_.end(); ++it) {
if ((*it)->sdp_mid() == candidate->sdp_mid() &&
(*it)->sdp_mline_index() == candidate->sdp_mline_index() &&
(*it)->candidate().IsEquivalent(candidate->candidate())) {
ret = true;
break;
}
}
return ret;
}

size_t JsepCandidateCollection::remove(const cricket::Candidate& candidate) {
auto iter = std::find_if(candidates_.begin(), candidates_.end(),
[candidate](JsepIceCandidate* c) {
return candidate.MatchesForRemoval(c->candidate());
});
if (iter != candidates_.end()) {
delete *iter;
candidates_.erase(iter);
return 1;
}
return 0;
}

} // namespace webrtc
31 changes: 13 additions & 18 deletions api/jsepicecandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ class JsepIceCandidate : public IceCandidateInterface {
JsepIceCandidate(const std::string& sdp_mid,
int sdp_mline_index,
const cricket::Candidate& candidate);
~JsepIceCandidate();
~JsepIceCandidate() override;
// |err| may be null.
bool Initialize(const std::string& sdp, SdpParseError* err);
void SetCandidate(const cricket::Candidate& candidate) {
candidate_ = candidate;
}

virtual std::string sdp_mid() const { return sdp_mid_; }
virtual int sdp_mline_index() const { return sdp_mline_index_; }
virtual const cricket::Candidate& candidate() const { return candidate_; }
std::string sdp_mid() const override;
int sdp_mline_index() const override;
const cricket::Candidate& candidate() const override;

virtual std::string server_url() const { return candidate_.url(); }
std::string server_url() const override;

virtual bool ToString(std::string* out) const;
bool ToString(std::string* out) const override;

private:
std::string sdp_mid_;
Expand All @@ -57,23 +57,18 @@ class JsepIceCandidate : public IceCandidateInterface {
// Implementation of IceCandidateCollection which stores JsepIceCandidates.
class JsepCandidateCollection : public IceCandidateCollection {
public:
JsepCandidateCollection() {}
JsepCandidateCollection();
// Move constructor is defined so that a vector of JsepCandidateCollections
// can be resized.
JsepCandidateCollection(JsepCandidateCollection&& o)
: candidates_(std::move(o.candidates_)) {}
~JsepCandidateCollection();
virtual size_t count() const { return candidates_.size(); }
virtual bool HasCandidate(const IceCandidateInterface* candidate) const;
JsepCandidateCollection(JsepCandidateCollection&& o);
~JsepCandidateCollection() override;
size_t count() const override;
bool HasCandidate(const IceCandidateInterface* candidate) const override;
// Adds and takes ownership of the JsepIceCandidate.
// TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
// more clear.
virtual void add(JsepIceCandidate* candidate) {
candidates_.push_back(candidate);
}
virtual const IceCandidateInterface* at(size_t index) const {
return candidates_[index];
}
virtual void add(JsepIceCandidate* candidate);
const IceCandidateInterface* at(size_t index) const override;
// Removes the candidate that has a matching address and protocol.
//
// Returns the number of candidates that were removed.
Expand Down
52 changes: 30 additions & 22 deletions api/rtpparameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,65 @@ namespace webrtc {

const double kDefaultBitratePriority = 1.0;

RtcpFeedback::RtcpFeedback() {}
RtcpFeedback::RtcpFeedback() = default;
RtcpFeedback::RtcpFeedback(RtcpFeedbackType type) : type(type) {}
RtcpFeedback::RtcpFeedback(RtcpFeedbackType type,
RtcpFeedbackMessageType message_type)
: type(type), message_type(message_type) {}
RtcpFeedback::~RtcpFeedback() {}
RtcpFeedback::RtcpFeedback(const RtcpFeedback& rhs) = default;
RtcpFeedback::~RtcpFeedback() = default;

RtpCodecCapability::RtpCodecCapability() {}
RtpCodecCapability::~RtpCodecCapability() {}
RtpCodecCapability::RtpCodecCapability() = default;
RtpCodecCapability::~RtpCodecCapability() = default;

RtpHeaderExtensionCapability::RtpHeaderExtensionCapability() {}
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability() = default;
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(
const std::string& uri)
: uri(uri) {}
RtpHeaderExtensionCapability::RtpHeaderExtensionCapability(
const std::string& uri,
int preferred_id)
: uri(uri), preferred_id(preferred_id) {}
RtpHeaderExtensionCapability::~RtpHeaderExtensionCapability() {}
RtpHeaderExtensionCapability::~RtpHeaderExtensionCapability() = default;

RtpExtension::RtpExtension() {}
RtpExtension::RtpExtension() = default;
RtpExtension::RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {}
RtpExtension::RtpExtension(const std::string& uri, int id, bool encrypt)
: uri(uri), id(id), encrypt(encrypt) {}
RtpExtension::~RtpExtension() {}
RtpExtension::~RtpExtension() = default;

RtpFecParameters::RtpFecParameters() {}
RtpFecParameters::RtpFecParameters() = default;
RtpFecParameters::RtpFecParameters(FecMechanism mechanism)
: mechanism(mechanism) {}
RtpFecParameters::RtpFecParameters(FecMechanism mechanism, uint32_t ssrc)
: ssrc(ssrc), mechanism(mechanism) {}
RtpFecParameters::~RtpFecParameters() {}
RtpFecParameters::RtpFecParameters(const RtpFecParameters& rhs) = default;
RtpFecParameters::~RtpFecParameters() = default;

RtpRtxParameters::RtpRtxParameters() {}
RtpRtxParameters::RtpRtxParameters() = default;
RtpRtxParameters::RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {}
RtpRtxParameters::~RtpRtxParameters() {}
RtpRtxParameters::RtpRtxParameters(const RtpRtxParameters& rhs) = default;
RtpRtxParameters::~RtpRtxParameters() = default;

RtpEncodingParameters::RtpEncodingParameters() {}
RtpEncodingParameters::~RtpEncodingParameters() {}
RtpEncodingParameters::RtpEncodingParameters() = default;
RtpEncodingParameters::RtpEncodingParameters(const RtpEncodingParameters& rhs) =
default;
RtpEncodingParameters::~RtpEncodingParameters() = default;

RtpCodecParameters::RtpCodecParameters() {}
RtpCodecParameters::~RtpCodecParameters() {}
RtpCodecParameters::RtpCodecParameters() = default;
RtpCodecParameters::RtpCodecParameters(const RtpCodecParameters& rhs) = default;
RtpCodecParameters::~RtpCodecParameters() = default;

RtpCapabilities::RtpCapabilities() {}
RtpCapabilities::~RtpCapabilities() {}
RtpCapabilities::RtpCapabilities() = default;
RtpCapabilities::~RtpCapabilities() = default;

RtcpParameters::RtcpParameters() {}
RtcpParameters::~RtcpParameters() {}
RtcpParameters::RtcpParameters() = default;
RtcpParameters::RtcpParameters(const RtcpParameters& rhs) = default;
RtcpParameters::~RtcpParameters() = default;

RtpParameters::RtpParameters() {}
RtpParameters::~RtpParameters() {}
RtpParameters::RtpParameters() = default;
RtpParameters::RtpParameters(const RtpParameters& rhs) = default;
RtpParameters::~RtpParameters() = default;

std::string RtpExtension::ToString() const {
char buf[256];
Expand Down
7 changes: 7 additions & 0 deletions api/rtpparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct RtcpFeedback {
RtcpFeedback();
explicit RtcpFeedback(RtcpFeedbackType type);
RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
RtcpFeedback(const RtcpFeedback&);
~RtcpFeedback();

bool operator==(const RtcpFeedback& o) const {
Expand Down Expand Up @@ -321,6 +322,7 @@ struct RtpFecParameters {
RtpFecParameters();
explicit RtpFecParameters(FecMechanism mechanism);
RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
RtpFecParameters(const RtpFecParameters&);
~RtpFecParameters();

bool operator==(const RtpFecParameters& o) const {
Expand All @@ -337,6 +339,7 @@ struct RtpRtxParameters {
// Constructors for convenience.
RtpRtxParameters();
explicit RtpRtxParameters(uint32_t ssrc);
RtpRtxParameters(const RtpRtxParameters&);
~RtpRtxParameters();

bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
Expand All @@ -345,6 +348,7 @@ struct RtpRtxParameters {

struct RtpEncodingParameters {
RtpEncodingParameters();
RtpEncodingParameters(const RtpEncodingParameters&);
~RtpEncodingParameters();

// If unset, a value is chosen by the implementation.
Expand Down Expand Up @@ -460,6 +464,7 @@ struct RtpEncodingParameters {

struct RtpCodecParameters {
RtpCodecParameters();
RtpCodecParameters(const RtpCodecParameters&);
~RtpCodecParameters();

// Build MIME "type/subtype" string from |name| and |kind|.
Expand Down Expand Up @@ -545,6 +550,7 @@ struct RtpCapabilities {

struct RtcpParameters final {
RtcpParameters();
RtcpParameters(const RtcpParameters&);
~RtcpParameters();

// The SSRC to be used in the "SSRC of packet sender" field. If not set, one
Expand Down Expand Up @@ -579,6 +585,7 @@ struct RtcpParameters final {

struct RtpParameters {
RtpParameters();
RtpParameters(const RtpParameters&);
~RtpParameters();

// Used when calling getParameters/setParameters with a PeerConnection
Expand Down
2 changes: 2 additions & 0 deletions api/rtptransceiverinterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace webrtc {

RtpTransceiverInit::RtpTransceiverInit() = default;

RtpTransceiverInit::RtpTransceiverInit(const RtpTransceiverInit& rhs) = default;

RtpTransceiverInit::~RtpTransceiverInit() = default;

absl::optional<RtpTransceiverDirection>
Expand Down
1 change: 1 addition & 0 deletions api/rtptransceiverinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum class RtpTransceiverDirection {
// https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit
struct RtpTransceiverInit final {
RtpTransceiverInit();
RtpTransceiverInit(const RtpTransceiverInit&);
~RtpTransceiverInit();
// Direction of the RtpTransceiver. See RtpTransceiverInterface::direction().
RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv;
Expand Down
35 changes: 0 additions & 35 deletions pc/jsepicecandidate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,4 @@ bool JsepIceCandidate::ToString(std::string* out) const {
return !out->empty();
}

JsepCandidateCollection::~JsepCandidateCollection() {
for (std::vector<JsepIceCandidate*>::iterator it = candidates_.begin();
it != candidates_.end(); ++it) {
delete *it;
}
}

bool JsepCandidateCollection::HasCandidate(
const IceCandidateInterface* candidate) const {
bool ret = false;
for (std::vector<JsepIceCandidate*>::const_iterator it = candidates_.begin();
it != candidates_.end(); ++it) {
if ((*it)->sdp_mid() == candidate->sdp_mid() &&
(*it)->sdp_mline_index() == candidate->sdp_mline_index() &&
(*it)->candidate().IsEquivalent(candidate->candidate())) {
ret = true;
break;
}
}
return ret;
}

size_t JsepCandidateCollection::remove(const cricket::Candidate& candidate) {
auto iter = std::find_if(candidates_.begin(), candidates_.end(),
[candidate](JsepIceCandidate* c) {
return candidate.MatchesForRemoval(c->candidate());
});
if (iter != candidates_.end()) {
delete *iter;
candidates_.erase(iter);
return 1;
}
return 0;
}

} // namespace webrtc
2 changes: 1 addition & 1 deletion pc/mediastreamobserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace webrtc {
class MediaStreamObserver : public ObserverInterface {
public:
explicit MediaStreamObserver(MediaStreamInterface* stream);
~MediaStreamObserver();
~MediaStreamObserver() override;

const MediaStreamInterface* stream() const { return stream_; }

Expand Down
10 changes: 0 additions & 10 deletions sdk/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,6 @@ rtc_static_library("peerconnection_jni") {
"src/jni/pc/turncustomizer.h",
]

if (is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
}

deps = [
":base_jni",
":generated_external_classes_jni",
Expand Down Expand Up @@ -1256,11 +1251,6 @@ rtc_static_library("native_api_peerconnection") {
"native_api/peerconnection/peerconnectionfactory.h",
]

if (is_clang) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
}

deps = [
":base_jni",
":peerconnection_jni",
Expand Down
2 changes: 1 addition & 1 deletion sdk/android/src/jni/pc/datachannel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
class DataChannelObserverJni : public DataChannelObserver {
public:
DataChannelObserverJni(JNIEnv* jni, const JavaRef<jobject>& j_observer);
virtual ~DataChannelObserverJni() {}
~DataChannelObserverJni() override {}

void OnBufferedAmountChange(uint64_t previous_amount) override;
void OnStateChange() override;
Expand Down
Loading

0 comments on commit 2ffed6d

Please sign in to comment.