mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-13 22:03:09 +00:00
fix OSX build errors.
This commit is contained in:
parent
4440cf3af0
commit
db5daa20ee
8
os.c
8
os.c
@ -361,7 +361,13 @@ ssize_t get_self_executable_path(char *buf, size_t len)
|
||||
return read_symlink("/proc/self/path/a.out", buf, len);
|
||||
#elif defined (__APPLE__)
|
||||
uint32_t bufsize = len;
|
||||
return _NSGetExecutablePath(buf, &bufsize) || len == 0 ? bufsize : -1;
|
||||
// OSX complains if the ? : operator returns fields with different signedness
|
||||
// so we cast the uint32_t bufsize to signed. We should really check to make
|
||||
// sure that _NSGetExecutablePath doesn't return a value in bufsize that would
|
||||
// be negative when cast.
|
||||
ssize_t s = _NSGetExecutablePath(buf, &bufsize);
|
||||
assert(((int32_t)bufsize)>=0);
|
||||
return ( s || len == 0 ) ? (int32_t)bufsize : -1;
|
||||
#else
|
||||
#error Unable to find executable path
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user