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

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


kcc added inline comments.

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:116
@@ -115,2 +115,3 @@
 int NumberOfCpuCores() {
-  FILE *F = popen("nproc", "r");
+  FILE *F = nullptr;
+  const char *cmdLine = nullptr;
----------------
move this to where you initialize it. 

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:128
@@ +127,3 @@
+  if (F == nullptr) {
+    Printf("libfuzzer: Failed to execute popen() in %s()\n", __func__);
+    exit(1);
----------------
fold this into the next warning and assume #CPUs == 1 instead of failing

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:133
@@ +132,3 @@
+  if (fscanf(F, "%d", &N) != 1) {
+    Printf("libfuzzer: Warning failed to parse output of command in %s(). "
+           "Assuming CPU count of 1.\n",
----------------
In most of similar cases we do 
Printf("WARNING: 

================
Comment at: lib/Fuzzer/FuzzerUtil.cpp:139
@@ +138,3 @@
+
+  int returnCode = pclose(F);
+  if (returnCode != 0) {
----------------
This code uses different coding style (ReturnCode or PcloseRet)


http://reviews.llvm.org/D20409





More information about the llvm-commits mailing list