[LLVMdev] Some fixes for the GetMainExecutable function

Kees van Reeuwijk reeuwijk at few.vu.nl
Thu Sep 2 10:03:35 PDT 2010


Hi,

The attached patch ensures that GetMainExecutable function in llvm-trunk/lib/System/Unix/Path.inc also works on Minix. I'm not sure it should be applied unmodified, because there may be controversial changes in it.

In particular, one of the things it changes is this:


-  snprintf(buf, PATH_MAX, "%s//%s", dir, bin);
+  snprintf(buf, PATH_MAX, "%s/%s", dir, bin);

in the function test_dir(), because Minix doesn't like multiple slashes to as path separator. Since it is not immediately obvious to use double slashes here, I'm wondering if this was a deliberate choice. Is there a reason for these two slashes?

Also, the if-all-else-fails return value of GetMainExecutable is an empty path, but since the users of this function don't test for that, this choice leads to rather obscure errors. Wouldn't it be better to give an explicit error in such cases, or at the very least to return a path just containing Arg0 rather than the empty string?

It would be nice if these fixes could be part of llvm 2.8, since we're planning to use that as our base version for Minix, once it's released.

-- 
Dr. ir. Kees van Reeuwijk, Vrije Universiteit Amsterdam



-------------- next part --------------
A non-text attachment was scrubbed...
Name: minix-patch.diff
Type: application/octet-stream
Size: 1005 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100902/9902780e/attachment.obj>
-------------- next part --------------




More information about the llvm-dev mailing list