[PATCH] D20409: [LibFuzzer] Fix NumberOfCpuCores() for Mac OSX

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 15:55:18 PDT 2016


kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

A few nits to make the code shorter. 
Ok to commit with those fixes.


================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:116
@@ -115,2 +115,3 @@
 int NumberOfCpuCores() {
-  FILE *F = popen("nproc", "r");
+  const char *cmdLine = nullptr;
+  if (LIBFUZZER_LINUX) {
----------------
Naming: CmdLIne

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:126
@@ -117,1 +125,3 @@
+  FILE *F = popen(cmdLine, "r");
   int N = 0;
+  if (!F || fscanf(F, "%d", &N) != 1) {
----------------
int N = 1;

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:135
@@ +134,3 @@
+  int PcloseRet = pclose(F);
+  if (PcloseRet != 0) {
+    Printf("WARNING: Executing command \"%s\" failed in %s(). ",
----------------
if (pclose(F))
   Printf("...")

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:140
@@ -121,1 +139,3 @@
+  }
+  assert(N > 0 && "Number of cpu cores must be > 0");
   return N;
----------------
with the default N = 1 you can just remove this. 


http://reviews.llvm.org/D20409





More information about the llvm-commits mailing list