Mark one-parameter constructors as explicit & use override where possible

This commit marks (hopefully) ever one-parameter constructor as explicit.

It also uses override in (hopefully) all circumstances where a virtual
method is overridden.

There are a very few other minor changes - most of them were necessary
to get everything to compile (like one additional constructor). In one
case I changed an implicit operation to an explicit string conversion -
I think the automatically chosen conversion was much more convoluted.

This took longer than I want to admit but not as long as I feared :)
This commit is contained in:
Johanna Amann 2018-03-16 22:14:22 -07:00
parent 1f2bf50b49
commit 6d612ced3d
173 changed files with 1052 additions and 1046 deletions

View file

@ -29,7 +29,7 @@ public:
* Constructor. Nothing special.
* @param arg_file the file to which all analyzers in the set are attached.
*/
AnalyzerSet(File* arg_file);
explicit AnalyzerSet(File* arg_file);
/**
* Destructor. Any queued analyzer additions/removals are aborted and
@ -173,9 +173,9 @@ private:
*/
AddMod(file_analysis::Analyzer* arg_a, HashKey* arg_key)
: Modification(), a(arg_a), key(arg_key) {}
virtual ~AddMod() {}
virtual bool Perform(AnalyzerSet* set);
virtual void Abort() { delete a; delete key; }
~AddMod() override {}
bool Perform(AnalyzerSet* set) override;
void Abort() override { delete a; delete key; }
protected:
file_analysis::Analyzer* a;
@ -194,9 +194,9 @@ private:
*/
RemoveMod(file_analysis::Tag arg_tag, HashKey* arg_key)
: Modification(), tag(arg_tag), key(arg_key) {}
virtual ~RemoveMod() {}
virtual bool Perform(AnalyzerSet* set);
virtual void Abort() { delete key; }
~RemoveMod() override {}
bool Perform(AnalyzerSet* set) override;
void Abort() override { delete key; }
protected:
file_analysis::Tag tag;

View file

@ -52,7 +52,7 @@ public:
/**
* Destructor.
*/
~Component();
~Component() override;
/**
* Initialization function. This function has to be called before any

View file

@ -15,7 +15,7 @@ class FileReassembler : public Reassembler {
public:
FileReassembler(File* f, uint64 starting_offset);
virtual ~FileReassembler();
~FileReassembler() override;
void Done();

View file

@ -28,7 +28,7 @@ public:
* @param t current unix time
* @param is_expire true if all pending timers are being expired.
*/
void Dispatch(double t, int is_expire);
void Dispatch(double t, int is_expire) override;
private:
string file_id;

View file

@ -97,14 +97,14 @@ protected:
* @param subtype The sub type, which is left to an analyzer for
* interpretation. By default it's set to zero.
*/
Tag(type_t type, subtype_t subtype = 0);
explicit Tag(type_t type, subtype_t subtype = 0);
/**
* Constructor.
*
* @param val An enum value of script type \c Files::Tag.
*/
Tag(EnumVal* val) : ::Tag(val) {}
explicit Tag(EnumVal* val) : ::Tag(val) {}
};
}

View file

@ -25,7 +25,7 @@ public:
* @param offset number of bytes from start of file at which chunk occurs.
* @return always true
*/
virtual bool DeliverChunk(const u_char* data, uint64 len, uint64 offset);
bool DeliverChunk(const u_char* data, uint64 len, uint64 offset) override;
/**
* Generates the event, if any, specified by the "stream_event" field of
@ -34,7 +34,7 @@ public:
* @param len number of bytes in the data chunk.
* @return always true
*/
virtual bool DeliverStream(const u_char* data, uint64 len);
bool DeliverStream(const u_char* data, uint64 len) override;
/**
* Create a new instance of a DataEvent analyzer.

View file

@ -23,7 +23,7 @@ public:
/**
* Destructor.
*/
virtual ~Entropy();
~Entropy() override;
/**
* Create a new instance of an Extract analyzer.
@ -40,13 +40,13 @@ public:
* @param len number of bytes in the data chunk.
* @return false if the digest is in an invalid state, else true.
*/
virtual bool DeliverStream(const u_char* data, uint64 len);
bool DeliverStream(const u_char* data, uint64 len) override;
/**
* Finalizes the hash and raises a "file_entropy_test" event.
* @return always false so analyze will be deteched from file.
*/
virtual bool EndOfFile();
bool EndOfFile() override;
/**
* Missing data can't be handled, so just indicate the this analyzer should
@ -55,7 +55,7 @@ public:
* @param len number of missing bytes.
* @return always false so analyzer will detach from file.
*/
virtual bool Undelivered(uint64 offset, uint64 len);
bool Undelivered(uint64 offset, uint64 len) override;
protected:

View file

@ -22,7 +22,7 @@ public:
/**
* Destructor. Will close the file that was used for data extraction.
*/
virtual ~Extract();
~Extract() override;
/**
* Write a chunk of file data to the local extraction file.
@ -31,7 +31,7 @@ public:
* @return false if there was no extraction file open and the data couldn't
* be written, else true.
*/
virtual bool DeliverStream(const u_char* data, uint64 len);
bool DeliverStream(const u_char* data, uint64 len) override;
/**
* Report undelivered bytes.
@ -39,7 +39,7 @@ public:
* @param len number of bytes undelivered.
* @return true
*/
virtual bool Undelivered(uint64 offset, uint64 len);
bool Undelivered(uint64 offset, uint64 len) override;
/**
* Create a new instance of an Extract analyzer.

View file

@ -23,7 +23,7 @@ public:
/**
* Destructor.
*/
virtual ~Hash();
~Hash() override;
/**
* Incrementally hash next chunk of file contents.
@ -31,13 +31,13 @@ public:
* @param len number of bytes in the data chunk.
* @return false if the digest is in an invalid state, else true.
*/
virtual bool DeliverStream(const u_char* data, uint64 len);
bool DeliverStream(const u_char* data, uint64 len) override;
/**
* Finalizes the hash and raises a "file_hash" event.
* @return always false so analyze will be deteched from file.
*/
virtual bool EndOfFile();
bool EndOfFile() override;
/**
* Missing data can't be handled, so just indicate the this analyzer should
@ -46,7 +46,7 @@ public:
* @param len number of missing bytes.
* @return always false so analyzer will detach from file.
*/
virtual bool Undelivered(uint64 offset, uint64 len);
bool Undelivered(uint64 offset, uint64 len) override;
protected:

View file

@ -17,9 +17,9 @@ namespace file_analysis {
*/
class Unified2 : public file_analysis::Analyzer {
public:
virtual ~Unified2();
~Unified2() override;
virtual bool DeliverStream(const u_char* data, uint64 len);
bool DeliverStream(const u_char* data, uint64 len) override;
static file_analysis::Analyzer* Instantiate(RecordVal* args, File* file);

View file

@ -40,7 +40,7 @@ private:
class OCSP_RESPVal: public OpaqueVal {
public:
explicit OCSP_RESPVal(OCSP_RESPONSE *);
~OCSP_RESPVal();
~OCSP_RESPVal() override;
OCSP_RESPONSE *GetResp() const;
protected:
OCSP_RESPVal();

View file

@ -121,7 +121,7 @@ public:
/**
* Destructor.
*/
~X509Val();
~X509Val() override;
/**
* Get the wrapped X509 certificate. Please take care, that the

View file

@ -16,7 +16,7 @@ namespace file_analysis {
class X509Common : public file_analysis::Analyzer {
public:
virtual ~X509Common() {};
~X509Common() override {};
/**
* Retrieve an X509 extension value from an OpenSSL BIO to which it was