code-format

This commit is contained in:
van Hauser
2020-08-31 10:57:01 +02:00
parent ca0105ddf6
commit 4566bcf122
5 changed files with 27 additions and 16 deletions

View File

@ -1027,11 +1027,15 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) {
}
/* Modulo is biased - we don't want our fuzzing to be biased so let's do it right. */
/* Modulo is biased - we don't want our fuzzing to be biased so let's do it
* right. */
u64 unbiased_rnd;
do {
unbiased_rnd = rand_next(afl);
} while (unlikely(unbiased_rnd >= (UINT64_MAX - (UINT64_MAX % limit))));
return unbiased_rnd % limit;
}

View File

@ -812,16 +812,24 @@ int main(int argc, char **argv, char **envp) {
ptr += strlen("ngram");
while (*ptr && (*ptr < '0' || *ptr > '9')) {
ptr++;
}
if (!*ptr) {
ptr = getenv("AFL_LLVM_NGRAM_SIZE");
if (!ptr || !*ptr) {
FATAL(
"you must set the NGRAM size with (e.g. for value 2) "
"AFL_LLVM_INSTRUMENT=ngram-2");
}
}
ngram_size = atoi(ptr);
if (ngram_size < 2 || ngram_size > NGRAM_SIZE_MAX)
FATAL(

View File

@ -347,11 +347,7 @@ static std::string getSourceName(llvm::Function *F) {
StringRef instFilename;
DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
if (cDILoc) {
instFilename = cDILoc->getFilename();
}
if (cDILoc) { instFilename = cDILoc->getFilename(); }
if (instFilename.str().empty()) {

View File

@ -379,11 +379,9 @@ bool AFLLTOPass::runOnModule(Module &M) {
else
Str1 = TmpStr.str();
bool HasStr2 = getConstantStringInfo(Str2P, TmpStr);
if (TmpStr.empty())
HasStr2 = false;
(void) HasStr2 /* never read */
else
Str2 = TmpStr.str();
if (TmpStr.empty()) HasStr2 = false;
(void)HasStr2 /* never read */
else Str2 = TmpStr.str();
if (debug)
fprintf(stderr, "F:%s %p(%s)->\"%s\"(%s) %p(%s)->\"%s\"(%s)\n",

View File

@ -1843,7 +1843,8 @@ void setup_stdio_file(afl_state_t *afl) {
if (afl->file_extension) {
afl->fsrv.out_file = alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
afl->fsrv.out_file =
alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
} else {
@ -1855,7 +1856,11 @@ void setup_stdio_file(afl_state_t *afl) {
afl->fsrv.out_fd = open(afl->fsrv.out_file, O_RDWR | O_CREAT | O_EXCL, 0600);
if (afl->fsrv.out_fd < 0) { PFATAL("Unable to create '%s'", afl->fsrv.out_file); }
if (afl->fsrv.out_fd < 0) {
PFATAL("Unable to create '%s'", afl->fsrv.out_file);
}
}