Fix clang style warnings in webrtc/base
Mostly this consists of marking functions with override when
applicable, and moving function bodies from .h to .cc files.
Not inlining virtual functions with simple bodies such as
{ return false; }
strikes me as probably losing more in readability than we gain in
binary size and compilation time, but I guess it's just like any other
case where enabling a generally good warning forces us to write
slightly worse code in a couple of places.
BUG=163
R=kjellander@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/47429004
Cr-Commit-Position: refs/heads/master@{#8656}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8656 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/base/helpers.cc b/webrtc/base/helpers.cc
index 84d1c93..bd7ff96 100644
--- a/webrtc/base/helpers.cc
+++ b/webrtc/base/helpers.cc
@@ -51,11 +51,9 @@
class SecureRandomGenerator : public RandomGenerator {
public:
SecureRandomGenerator() {}
- ~SecureRandomGenerator() {}
- virtual bool Init(const void* seed, size_t len) {
- return true;
- }
- virtual bool Generate(void* buf, size_t len) {
+ ~SecureRandomGenerator() override {}
+ bool Init(const void* seed, size_t len) override { return true; }
+ bool Generate(void* buf, size_t len) override {
return (RAND_bytes(reinterpret_cast<unsigned char*>(buf), len) > 0);
}
};
@@ -65,11 +63,9 @@
class SecureRandomGenerator : public RandomGenerator {
public:
SecureRandomGenerator() {}
- ~SecureRandomGenerator() {}
- virtual bool Init(const void* seed, size_t len) {
- return true;
- }
- virtual bool Generate(void* buf, size_t len) {
+ ~SecureRandomGenerator() override {}
+ bool Init(const void* seed, size_t len) override { return true; }
+ bool Generate(void* buf, size_t len) override {
return (PK11_GenerateRandom(reinterpret_cast<unsigned char*>(buf),
static_cast<int>(len)) == SECSuccess);
}
@@ -153,12 +149,10 @@
public:
TestRandomGenerator() : seed_(7) {
}
- ~TestRandomGenerator() {
+ ~TestRandomGenerator() override {
}
- virtual bool Init(const void* seed, size_t len) {
- return true;
- }
- virtual bool Generate(void* buf, size_t len) {
+ bool Init(const void* seed, size_t len) override { return true; }
+ bool Generate(void* buf, size_t len) override {
for (size_t i = 0; i < len; ++i) {
static_cast<uint8*>(buf)[i] = static_cast<uint8>(GetRandom());
}