[llvm-commits] [test-suite] r157803 - /test-suite/trunk/MultiSource/Applications/minisat/Main.cpp

Bob Wilson bob.wilson at apple.com
Thu May 31 22:49:43 PDT 2012


Author: bwilson
Date: Fri Jun  1 00:49:42 2012
New Revision: 157803

URL: http://llvm.org/viewvc/llvm-project?rev=157803&view=rev
Log:
Fix strtol error handling.  <rdar://problem/11495620>

If the value converted by strtol is zero, then errno is not set and does not
have a well-defined value.

Modified:
    test-suite/trunk/MultiSource/Applications/minisat/Main.cpp

Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/Main.cpp?rev=157803&r1=157802&r2=157803&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Applications/minisat/Main.cpp (original)
+++ test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Fri Jun  1 00:49:42 2012
@@ -261,8 +261,9 @@
             S.var_decay = 1 / decay;
 
         }else if ((value = hasPrefix(argv[i], "-verbosity="))){
-            int verbosity = (int)strtol(value, NULL, 10);
-            if (verbosity == 0 && errno == EINVAL){
+            char *end;
+            int verbosity = (int)strtol(value, &end, 10);
+            if (end == value || *end != 0){
                 reportf("ERROR! illegal verbosity level %s\n", value);
                 exit(0); }
             S.verbosity = verbosity;





More information about the llvm-commits mailing list