Fix console_print_box*() parameters.

When we made lib build with the correct CFLAGS, it inherited
-Werror=sign-compare, and I fixed up some parameters on
console_print_box() and console_print_box_at() to avoid sign comparison
errors.

The fixups were *completely wrong*, as some behavior relies on negative
values.  So this fixes them in a completely different way, by casting
appropriately to signed types where we're doing comparisons.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2015-06-16 11:41:32 -04:00
parent 0a7003faec
commit 1fefa29c34
2 changed files with 18 additions and 19 deletions

View File

@ -4,12 +4,12 @@
EFI_STATUS EFI_STATUS
console_get_keystroke(EFI_INPUT_KEY *key); console_get_keystroke(EFI_INPUT_KEY *key);
void void
console_print_box_at(CHAR16 *str_arr[], unsigned int highlight, console_print_box_at(CHAR16 *str_arr[], int highlight,
unsigned int start_col, unsigned int start_row, int start_col, int start_row,
unsigned int size_cols, unsigned int size_rows, int size_cols, int size_rows,
int offset, unsigned int lines); int offset, int lines);
void void
console_print_box(CHAR16 *str_arr[], unsigned int highlight); console_print_box(CHAR16 *str_arr[], int highlight);
int int
console_yes_no(CHAR16 *str_arr[]); console_yes_no(CHAR16 *str_arr[]);
int int

View File

@ -55,12 +55,12 @@ console_get_keystroke(EFI_INPUT_KEY *key)
} }
void void
console_print_box_at(CHAR16 *str_arr[], unsigned int highlight, console_print_box_at(CHAR16 *str_arr[], int highlight,
unsigned int start_col, unsigned int start_row, int start_col, int start_row,
unsigned int size_cols, unsigned int size_rows, int size_cols, int size_rows,
int offset, unsigned int lines) int offset, int lines)
{ {
unsigned int i; int i;
SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;
UINTN rows, cols; UINTN rows, cols;
CHAR16 *Line; CHAR16 *Line;
@ -87,14 +87,14 @@ console_print_box_at(CHAR16 *str_arr[], unsigned int highlight,
if (start_row < 0) if (start_row < 0)
start_row = 0; start_row = 0;
if (start_col > cols || start_row > rows) { if (start_col > (int)cols || start_row > (int)rows) {
Print(L"Starting Position (%d,%d) is off screen\n", Print(L"Starting Position (%d,%d) is off screen\n",
start_col, start_row); start_col, start_row);
return; return;
} }
if (size_cols + start_col > cols) if (size_cols + start_col > (int)cols)
size_cols = cols - start_col; size_cols = cols - start_col;
if (size_rows + start_row > rows) if (size_rows + start_row > (int)rows)
size_rows = rows - start_row; size_rows = rows - start_row;
if (lines > size_rows - 2) if (lines > size_rows - 2)
@ -125,9 +125,8 @@ console_print_box_at(CHAR16 *str_arr[], unsigned int highlight,
/* from top */ /* from top */
start = start_row + offset; start = start_row + offset;
for (i = start_row + 1; i < size_rows + start_row - 1; i++) { for (i = start_row + 1; i < size_rows + start_row - 1; i++) {
unsigned int line = i - start; int line = i - start;
SetMem16 (Line, size_cols*2, L' '); SetMem16 (Line, size_cols*2, L' ');
Line[0] = BOXDRAW_VERTICAL; Line[0] = BOXDRAW_VERTICAL;
@ -163,7 +162,7 @@ console_print_box_at(CHAR16 *str_arr[], unsigned int highlight,
} }
void void
console_print_box(CHAR16 *str_arr[], unsigned int highlight) console_print_box(CHAR16 *str_arr[], int highlight)
{ {
SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode; SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode;
SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;