From 7d8450e5ab11c0608eba13c1af2b20f36a77b371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 27 Jan 2020 18:55:05 +0100 Subject: [PATCH] device: Mark fingers names array as const and use unique name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the stronger warnings enabled when building with meson, we get a warning for all the fingers definitions: ../src/device.c:38:24: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 38 | [FP_FINGER_UNKNOWN] = "unknown", As the `fingers` array name was shadowed in another file: ../src/device.c:1000:11: warning: declaration of ‘fingers’ shadows a global declaration [-Wshadow] 1000 | GSList *fingers, *finger; --- src/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 70d985f..e4f7b1d 100644 --- a/src/device.c +++ b/src/device.c @@ -34,7 +34,7 @@ #include "fprintd.h" #include "storage.h" -static char *fingers[] = { +static const char *FINGERS_NAMES[] = { [FP_FINGER_UNKNOWN] = "unknown", "left-thumb", "left-index-finger", @@ -298,7 +298,7 @@ finger_num_to_name (int finger_num) return "any"; if (!FP_FINGER_IS_VALID (finger_num)) return NULL; - return fingers[finger_num]; + return FINGERS_NAMES[finger_num]; } static int @@ -310,7 +310,7 @@ finger_name_to_num (const char *finger_name) return -1; for (i = FP_FINGER_FIRST; i <= FP_FINGER_LAST; i++) { - if (g_str_equal (finger_name, fingers[i])) + if (g_str_equal (finger_name, FINGERS_NAMES[i])) return i; }