zturner added inline comments.

================
Comment at: tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp:66
+  int error = ::sysctlbyname(feature, &answer, &answer_size, NULL, 0);
+  return !error & answer;
+}
----------------
jasonmolenda wrote:
> I see what you're doing -- this can either return "false, meaning the 
> sysctlbyname failed or I got a zero value, or true meaning it succeeded and I 
> got a nonzero value" but the use of a bitwise AND is going to look like a bug 
> to any casual reader and make them re-read the code a few times before 
> they've realized it is intended (at least it did me).  It might be easier for 
> future maintainers if it's written more like like
> 
> if (error != 0 && answer != 0)
>   return true;
> else
>   return false;
> 
> and let the compiler come up with the shorter form when generating the 
> instructions.
Maybe I'm missing something, but why not just `return !error && answer`?


https://reviews.llvm.org/D30918



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to