mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 01:31:37 +00:00
code cleanups (from cppcheck)
This commit is contained in:
parent
c423aebb1a
commit
33a7d6f168
@ -995,7 +995,7 @@ void mangle_mangleContent(run_t *run, int speed_factor) {
|
||||
|
||||
}
|
||||
|
||||
uint64_t changesCnt = run->global->mutate.mutationsPerRun;
|
||||
uint64_t changesCnt;
|
||||
|
||||
if (speed_factor < 5) {
|
||||
|
||||
|
@ -246,7 +246,7 @@ bool DataFlowTrace::Init(const std::string &DirPath, std::string *FocusFunction,
|
||||
|
||||
}
|
||||
|
||||
if (!NumFunctions || FocusFuncIdx == SIZE_MAX || Files.size() <= 1)
|
||||
if (FocusFuncIdx == SIZE_MAX || Files.size() <= 1)
|
||||
return false;
|
||||
|
||||
// Read traces.
|
||||
@ -259,8 +259,8 @@ bool DataFlowTrace::Init(const std::string &DirPath, std::string *FocusFunction,
|
||||
if (!CorporaHashes.count(Name)) continue; // not in the corpus.
|
||||
NumTraceFiles++;
|
||||
// Printf("=== %s\n", Name.c_str());
|
||||
std::ifstream IF(SF.File);
|
||||
while (std::getline(IF, L, '\n')) {
|
||||
std::ifstream IF2(SF.File);
|
||||
while (std::getline(IF2, L, '\n')) {
|
||||
|
||||
size_t FunctionNum = 0;
|
||||
std::string DFTString;
|
||||
@ -314,8 +314,8 @@ int CollectDataFlow(const std::string &DFTBinary, const std::string &DirPath,
|
||||
// we then request tags in [0,Size/2) and [Size/2, Size), and so on.
|
||||
// Function number => DFT.
|
||||
auto OutPath = DirPlusFile(DirPath, Hash(FileToVector(F.File)));
|
||||
std::unordered_map<size_t, Vector<uint8_t>> DFTMap;
|
||||
std::unordered_set<std::string> Cov;
|
||||
// std::unordered_map<size_t, Vector<uint8_t>> DFTMap;
|
||||
// std::unordered_set<std::string> Cov;
|
||||
Command Cmd;
|
||||
Cmd.addArgument(DFTBinary);
|
||||
Cmd.addArgument(F.File);
|
||||
|
@ -46,7 +46,7 @@ template<typename T>
|
||||
fuzzer_allocator() = default;
|
||||
|
||||
template<class U>
|
||||
fuzzer_allocator(const fuzzer_allocator<U>&) {}
|
||||
explicit fuzzer_allocator(const fuzzer_allocator<U>&) {}
|
||||
|
||||
template<class Other>
|
||||
struct rebind { typedef fuzzer_allocator<Other> other; };
|
||||
|
@ -49,7 +49,7 @@ typedef FixedWord<64> Word;
|
||||
class DictionaryEntry {
|
||||
public:
|
||||
DictionaryEntry() {}
|
||||
DictionaryEntry(Word W) : W(W) {}
|
||||
explicit DictionaryEntry(Word W) : W(W) {}
|
||||
DictionaryEntry(Word W, size_t PositionHint) : W(W), PositionHint(PositionHint) {}
|
||||
const Word &GetW() const { return W; }
|
||||
|
||||
@ -92,7 +92,7 @@ class Dictionary {
|
||||
assert(Idx < Size);
|
||||
return DE[Idx];
|
||||
}
|
||||
void push_back(DictionaryEntry DE) {
|
||||
void push_back(const DictionaryEntry &DE) {
|
||||
if (Size < kMaxDictSize)
|
||||
this->DE[Size++] = DE;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace fuzzer {
|
||||
class Random : public std::minstd_rand {
|
||||
public:
|
||||
Random(unsigned int seed) : std::minstd_rand(seed) {}
|
||||
explicit Random(unsigned int seed) : std::minstd_rand(seed) {}
|
||||
result_type operator()() { return this->std::minstd_rand::operator()(); }
|
||||
size_t Rand() { return this->operator()(); }
|
||||
size_t RandBool() { return Rand() % 2; }
|
||||
|
@ -145,10 +145,10 @@ private:
|
||||
};
|
||||
Region *Regions;
|
||||
size_t NumRegions;
|
||||
uint8_t *Start() { return Regions[0].Start; }
|
||||
uint8_t *Stop() { return Regions[NumRegions - 1].Stop; }
|
||||
size_t Size() { return Stop() - Start(); }
|
||||
size_t Idx(uint8_t *P) {
|
||||
uint8_t *Start() const { return Regions[0].Start; }
|
||||
uint8_t *Stop() const { return Regions[NumRegions - 1].Stop; }
|
||||
size_t Size() const { return Stop() - Start(); }
|
||||
size_t Idx(uint8_t *P) const {
|
||||
assert(P >= Start() && P < Stop());
|
||||
return P - Start();
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ static inline const char *colorfilter(const char *x) {
|
||||
\
|
||||
SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
|
||||
"\n[-] PROGRAM ABORT : " cRST x); \
|
||||
SAYF(cLRD "\n Location : " cRST "%s(), %s:%u\n\n", __func__, \
|
||||
SAYF(cLRD "\n Location : " cRST "%s(), %s:%d\n\n", __func__, \
|
||||
__FILE__, __LINE__); \
|
||||
exit(1); \
|
||||
\
|
||||
@ -308,7 +308,7 @@ static inline const char *colorfilter(const char *x) {
|
||||
\
|
||||
SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
|
||||
"\n[-] PROGRAM ABORT : " cRST x); \
|
||||
SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n\n", __func__, \
|
||||
SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%d\n\n", __func__, \
|
||||
__FILE__, __LINE__); \
|
||||
abort(); \
|
||||
\
|
||||
@ -322,7 +322,7 @@ static inline const char *colorfilter(const char *x) {
|
||||
fflush(stdout); \
|
||||
SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \
|
||||
"\n[-] SYSTEM ERROR : " cRST x); \
|
||||
SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n", __func__, \
|
||||
SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%d\n", __func__, \
|
||||
__FILE__, __LINE__); \
|
||||
SAYF(cLRD " OS message : " cRST "%s\n", strerror(errno)); \
|
||||
exit(1); \
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8cca4801adb767dce7cf72202d7d25bdb420cf7d
|
||||
Subproject commit 768e6bb29b7cb98bb2b9c4526ae3d234db5c1615
|
@ -1,4 +1,4 @@
|
||||
#define __GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,10 +1,10 @@
|
||||
all:
|
||||
afl-clang-fast -o persistent_demo persistent_demo.c
|
||||
afl-clang-fast -o persistent_demo_new persistent_demo_new.c
|
||||
AFL_DONT_OPTIMIZE=1 afl-clang-fast -o test-instr test-instr.c
|
||||
../../afl-clang-fast -o persistent_demo persistent_demo.c
|
||||
../../afl-clang-fast -o persistent_demo_new persistent_demo_new.c
|
||||
AFL_DONT_OPTIMIZE=1 ../../afl-clang-fast -o test-instr test-instr.c
|
||||
|
||||
document:
|
||||
AFL_DONT_OPTIMIZE=1 afl-clang-fast -D_AFL_DOCUMENT_MUTATIONS -o test-instr test-instr.c
|
||||
AFL_DONT_OPTIMIZE=1 ../../afl-clang-fast -D_AFL_DOCUMENT_MUTATIONS -o test-instr test-instr.c
|
||||
|
||||
clean:
|
||||
rm -f persistent_demo persistent_demo_new test-instr
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
int target_func(unsigned char *buf, int size) {
|
||||
|
||||
printf("buffer:%p, size:%p\n", buf, size);
|
||||
printf("buffer:%p, size:%d\n", buf, size);
|
||||
switch (buf[0]) {
|
||||
|
||||
case 1:
|
||||
|
Loading…
x
Reference in New Issue
Block a user