From 6f69a781357e99f7e2381d8d4da749f1123db00b Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Thu, 29 Jul 2021 12:31:53 +0200 Subject: [PATCH] spdk_top: fix poller selection in pollers tab Change 821d8e2 introduced a bug in pollers tab - user might select rows below last displayed poller and possibly crash the application when invoking a pop-up details window there. This patch aims to resolve the issue. Change-Id: I9aa3a42e2327a27597a48b32dd8e9fa216e2b17e Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8978 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- app/spdk_top/spdk_top.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 38b2bf838..ea880a2f3 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -1413,7 +1413,7 @@ refresh_pollers_tab(uint8_t current_page) struct col_desc *col_desc = g_col_desc[POLLERS_TAB]; uint64_t last_run_counter, last_busy_counter; uint64_t i, j; - uint16_t col; + uint16_t col, empty_col = 0; uint8_t max_pages, item_index; char run_count[MAX_POLLER_RUN_COUNT], period_ticks[MAX_PERIOD_STR_LEN], status[MAX_POLLER_IND_STR_LEN]; @@ -1433,6 +1433,7 @@ refresh_pollers_tab(uint8_t current_page) mvwprintw(g_tabs[POLLERS_TAB], item_index + TABS_DATA_START_ROW, j, " "); } + empty_col++; continue; } @@ -1528,7 +1529,7 @@ refresh_pollers_tab(uint8_t current_page) } } - g_max_selected_row = i - current_page * g_max_data_rows - 1; + g_max_selected_row = i - current_page * g_max_data_rows - 1 - empty_col; return max_pages; }