Skip to content

Commit 88cdf78

Browse files
committed
(engine) avoid warning for unused var in get_execpath() for some archs
Src-commit: 6572649dc3390ea4c1a8008fe739e70b43b21cec
1 parent 486fa0d commit 88cdf78

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

core/engine/eng_start.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,26 +279,31 @@ void engine_init(const char *boot_path, const char *exec_path) {
279279
glb_init_each_time();
280280
}
281281

282-
/* Get executable path (when argv[0] is not reliable) */
283-
char *get_execpath(void) {
284-
char buffer[MAXPATHLEN+1];
285-
size_t size = MAXPATHLEN+1;
282+
static bool_t get_execpath_(char *buffer, size_t size) {
286283
#if defined(LINUX)/*||defined(EMSCRIPTEN)*/
287284
ssize_t len;
288-
if ((len = readlink("/proc/self/exe", buffer, size)) == -1) return NULL;
285+
len = readlink("/proc/self/exe", buffer, size);
286+
return (len != -1);
289287
#elif defined(DARWIN)
290288
uint32_t len = size;
291-
if (_NSGetExecutablePath(buffer, &len) == -1) return NULL;
289+
return (_NSGetExecutablePath(buffer, &len) != -1);
292290
#elif defined(_WIN32) || defined(_WIN64) /* MinGW */
293-
if (GetModuleFileName(NULL, buffer, size) == 0) return NULL;
291+
return (GetModuleFileName(NULL, buffer, size) != 0);
294292
#else
295-
return NULL;
293+
return FALSE;
296294
/* TODO: Missing support for other OS:
297295
- Solaris: getexecname()
298296
- FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1
299297
- BSD with procfs: readlink /proc/curproc/file
300298
*/
301299
#endif
300+
}
301+
302+
/* Get executable path (when argv[0] is not reliable) */
303+
char *get_execpath(void) {
304+
char buffer[MAXPATHLEN+1];
305+
size_t size = MAXPATHLEN+1;
306+
if (!get_execpath_(buffer, size)) return NULL;
302307
return strdup(buffer);
303308
}
304309

0 commit comments

Comments
 (0)