[PATCH] D79239: getMainExecutable: Fix hand-rolled AT_EXECPATH search for older branches

Kyle Evans via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 2 08:27:46 PDT 2020


kevans updated this revision to Diff 261650.
kevans added a comment.

Sure; I have no strong preference.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79239/new/

https://reviews.llvm.org/D79239

Files:
  llvm/lib/Support/Unix/Path.inc


Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -207,14 +207,9 @@
   while (*p++ != 0)
     ;
   // Iterate through auxiliary vectors for AT_EXECPATH.
-  for (;;) {
-    switch (*(uintptr_t *)p++) {
-    case AT_EXECPATH:
+  for (; *(uintptr_t *)p != AT_NULL; p++) {
+    if (*(uintptr_t *)p++ == AT_EXECPATH)
       return *p;
-    case AT_NULL:
-      break;
-    }
-    p++;
   }
 #endif
   // Fall back to argv[0] if auxiliary vectors are not available.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79239.261650.patch
Type: text/x-patch
Size: 589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/aac1eb47/attachment.bin>


More information about the llvm-commits mailing list