File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -1292,9 +1292,8 @@ static int on_resize (pingobj_t *ping) /* {{{ */
12921292 if ((height < 1 ) || (width < 1 ))
12931293 return (EINVAL );
12941294
1295- int box_rows_count = host_num / opt_columns ;
1296- if (box_rows_count < 1 )
1297- box_rows_count = 1 ;
1295+ /* calculate the number of box rows, rounding up */
1296+ int box_rows_count = (host_num + opt_columns - 1 ) / opt_columns ;
12981297
12991298 main_win_height = height - (box_height * box_rows_count );
13001299 wresize (main_win , main_win_height , /* width = */ width );
@@ -1385,9 +1384,8 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */
13851384 init_pair (OPING_RED_HIST , COLOR_RED , COLOR_YELLOW );
13861385 }
13871386
1388- int box_rows_count = host_num / opt_columns ;
1389- if (box_rows_count < 1 )
1390- box_rows_count = 1 ;
1387+ /* calculate the number of box rows, rounding up */
1388+ int box_rows_count = (host_num + opt_columns - 1 ) / opt_columns ;
13911389
13921390 main_win_height = height - (box_height * box_rows_count );
13931391 main_win = newwin (/* height = */ main_win_height ,
You can’t perform that action at this time.
0 commit comments