From 074e5d0136beb84dec62e0a40209c42dab793d87 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 15 Nov 2023 14:34:16 +0100 Subject: Reorder array index limit check This is *not* an issue, as it's not really a bounds check but a mere limit, and the array is NULL-terminated. However, it looks odd and cppcheck (unsurprisingly) doesn't understand the details well enough and reports this as a misordered bounds check. > mate-panel/panel-run-dialog.c:166:12: style: Array index 'i' is used before limits check. [arrayIndexThenCheck] > items[i] && i < history_max_size; > ^ --- mate-panel/panel-run-dialog.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c index 73f1c2db..a469e6ed 100644 --- a/mate-panel/panel-run-dialog.c +++ b/mate-panel/panel-run-dialog.c @@ -162,9 +162,7 @@ _panel_run_get_recent_programs_list (PanelRunDialog *dialog) history_max_size = g_settings_get_uint (dialog->settings, PANEL_RUN_HISTORY_MAX_SIZE_KEY); history_reverse = g_settings_get_boolean (dialog->settings, PANEL_RUN_HISTORY_REVERSE_KEY); items = g_settings_get_strv (dialog->settings, PANEL_RUN_HISTORY_KEY); - for (i = 0; - items[i] && i < history_max_size; - i++) { + for (i = 0; i < history_max_size && items[i]; i++) { GtkTreeIter iter; /* add history in reverse */ if (history_reverse) -- cgit v1.2.1