about summary refs log tree commit diff
path: root/llvm_mode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc2
-rw-r--r--llvm_mode/afl-clang-fast.c10
-rw-r--r--llvm_mode/afl-llvm-common.cc4
-rw-r--r--llvm_mode/afl-llvm-lto-instrumentation.so.cc1
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc2
5 files changed, 14 insertions, 5 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 775e9591..61a420ba 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -243,7 +243,7 @@ struct InsTrim : public ModulePass {
     for (unsigned I = 0; I < PrevLocSize - 1; ++I)
       PrevLocShuffle.push_back(ConstantInt::get(Int32Ty, I));
 
-    for (unsigned I = PrevLocSize; I < PrevLocVecSize; ++I)
+    for (int I = PrevLocSize; I < PrevLocVecSize; ++I)
       PrevLocShuffle.push_back(ConstantInt::get(Int32Ty, PrevLocSize));
 
     Constant *PrevLocShuffleMask = ConstantVector::get(PrevLocShuffle);
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index d1fa548c..6ea98111 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -811,13 +811,17 @@ int main(int argc, char **argv, char **envp) {
       if (strncasecmp(ptr, "ngram", strlen("ngram")) == 0) {
 
         ptr += strlen("ngram");
-        while (*ptr && (*ptr < '0' || *ptr > '9'))
+        while (*ptr && (*ptr < '0' || *ptr > '9')) {
           ptr++;
-        if (!*ptr)
-          if ((ptr = getenv("AFL_LLVM_NGRAM_SIZE")) != NULL)
+        }
+        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(
diff --git a/llvm_mode/afl-llvm-common.cc b/llvm_mode/afl-llvm-common.cc
index d9e63bd3..59ad65c9 100644
--- a/llvm_mode/afl-llvm-common.cc
+++ b/llvm_mode/afl-llvm-common.cc
@@ -346,6 +346,10 @@ static std::string getSourceName(llvm::Function *F) {
 
     DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
 
+    if (!cDILoc) {
+      FATAL("DebugLoc is no DILocation");
+    }
+
     StringRef instFilename = cDILoc->getFilename();
 
     if (instFilename.str().empty()) {
diff --git a/llvm_mode/afl-llvm-lto-instrumentation.so.cc b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
index 0d82d09e..c25cad9d 100644
--- a/llvm_mode/afl-llvm-lto-instrumentation.so.cc
+++ b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
@@ -381,6 +381,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
             bool HasStr2 = getConstantStringInfo(Str2P, TmpStr);
             if (TmpStr.empty())
               HasStr2 = false;
+              (void) HasStr2 /* never read */
             else
               Str2 = TmpStr.str();
 
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 86c6f3c6..8c8c987a 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -284,7 +284,7 @@ bool AFLCoverage::runOnModule(Module &M) {
   for (unsigned I = 0; I < PrevLocSize - 1; ++I)
     PrevLocShuffle.push_back(ConstantInt::get(Int32Ty, I));
 
-  for (unsigned I = PrevLocSize; I < PrevLocVecSize; ++I)
+  for (int I = PrevLocSize; I < PrevLocVecSize; ++I)
     PrevLocShuffle.push_back(ConstantInt::get(Int32Ty, PrevLocSize));
 
   Constant *PrevLocShuffleMask = ConstantVector::get(PrevLocShuffle);