Fix -Wunused-function

`mi_strnicmp` is defined but not used If `MI_USE_ENVIRON` is not set,
which triggers a `-Wunused-function` warning. Since the function is
used only by `mi_getenv`, we can move the `mi_strnicmp` just before
`mi_getenv` to fix the warning.
This commit is contained in:
Rui Ueyama 2022-12-10 15:58:24 +08:00
parent c7d4a099d9
commit a96a5c89c1

View file

@ -479,15 +479,7 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
MI_UNUSED(result_size);
return false;
}
#else
static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
if (n==0) return 0;
for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) {
if (toupper(*s) != toupper(*t)) break;
}
return (n==0 ? 0 : *s - *t);
}
#if defined _WIN32
#elif defined _WIN32
// On Windows use GetEnvironmentVariable instead of getenv to work
// reliably even when this is invoked before the C runtime is initialized.
// i.e. when `_mi_preloading() == true`.
@ -512,6 +504,14 @@ static char** mi_get_environ(void) {
return environ;
}
# endif
static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
if (n==0) return 0;
for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) {
if (toupper(*s) != toupper(*t)) break;
}
return (n==0 ? 0 : *s - *t);
}
static bool mi_getenv(const char* name, char* result, size_t result_size) {
if (name==NULL) return false;
const size_t len = strlen(name);
@ -554,7 +554,6 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
return false;
}
}
#endif // !MI_USE_ENVIRON
#endif // !MI_NO_GETENV
static void mi_option_init(mi_option_desc_t* desc) {