[Lldb-commits] [PATCH] D30918: [debugserver] This is a small cleanup patch to AVX support detection

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 13 16:18:34 PDT 2017


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





More information about the lldb-commits mailing list