Merge pull request #111 from jserv/avoid-strlen-in-loop

Avoid using strlen function in loop
This commit is contained in:
Daan
2019-07-22 09:51:02 -07:00
committed by GitHub

View File

@@ -176,7 +176,8 @@ static void mi_option_init(mi_option_desc_t* desc) {
#pragma warning(suppress:4996)
char* s = getenv(buf);
if (s == NULL) {
for (size_t i = 0; i < strlen(buf); i++) {
size_t buf_size = strlen(buf);
for (size_t i = 0; i < buf_size; i++) {
buf[i] = toupper(buf[i]);
}
#pragma warning(suppress:4996)
@@ -184,7 +185,8 @@ static void mi_option_init(mi_option_desc_t* desc) {
}
if (s != NULL) {
mi_strlcpy(buf, s, sizeof(buf));
for (size_t i = 0; i < strlen(buf); i++) {
size_t buf_size = strlen(buf); // TODO: use strnlen?
for (size_t i = 0; i < buf_size; i++) {
buf[i] = toupper(buf[i]);
}
if (buf[0]==0 || strstr("1;TRUE;YES;ON", buf) != NULL) {