summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-07-01 17:48:21 +0200
committerGravatar Nikias Bassen2021-07-01 17:48:21 +0200
commit3dda9d2701a34f02058425eea25431122283177c (patch)
treef73e0f8a828537441ea5853a21a4847b3e491d8d
parent47f6aec37c2df467bc705b4aaee5cefa0835c131 (diff)
downloadlibirecovery-3dda9d2701a34f02058425eea25431122283177c.tar.gz
libirecovery-3dda9d2701a34f02058425eea25431122283177c.tar.bz2
Use strcasecmp instead of copying and lower-casing string in irecv_devices_get_device_by_hardware_model()
-rw-r--r--configure.ac2
-rw-r--r--src/libirecovery.c8
2 files changed, 2 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 7e8c7ea..d136f93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,7 +41,7 @@ AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
-AC_CHECK_FUNCS([strdup strerror strndup malloc realloc calloc])
+AC_CHECK_FUNCS([strdup strerror strcasecmp strndup malloc realloc calloc])
# Checks for libraries.
AC_CHECK_HEADERS([readline/readline.h], [],
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 1defaac..2219f36 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -3271,14 +3271,8 @@ IRECV_API irecv_error_t irecv_devices_get_device_by_hardware_model(const char* h
*device = NULL;
- /* lowercase hardware_model string for proper lookup */
- char model[8];
- strcpy(model, hardware_model);
- char *p = model;
- for (; *p; ++p) *p = tolower(*p);
-
for (i = 0; irecv_devices[i].hardware_model != NULL; i++) {
- if (!strcmp(model, irecv_devices[i].hardware_model)) {
+ if (!strcasecmp(hardware_model, irecv_devices[i].hardware_model)) {
*device = &irecv_devices[i];
return IRECV_E_SUCCESS;
}