From 6e9a1c4cd64b0ba0748cfe905ab64eb9ffaf3538 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 25 Jun 2026 11:07:15 +0200 Subject: [PATCH] terminal-util: use LESS_BY() where appropriate --- src/basic/terminal-util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index e756fcd45a..436daa7311 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -531,6 +531,7 @@ int show_menu(char **x, assert(x); assert(n_columns > 0); + assert(column_width > 0); if (n_columns == SIZE_MAX) n_columns = 3; @@ -542,16 +543,16 @@ int show_menu(char **x, size_t column_max = (columns()-1) / n_columns; /* Subtract room for numbers */ - if (with_numbers && column_max > 6) - column_max -= 6; + if (with_numbers) + column_max = LESS_BY(column_max, 6U); /* If columns would get too tight let's make this a linear list instead. */ if (column_max < 10 && widest > 10) { n_columns = 1; column_max = columns()-1; - if (with_numbers && column_max > 6) - column_max -= 6; + if (with_numbers) + column_max = LESS_BY(column_max, 6U); } column_width = CLAMP(widest+1, 10U, column_max);