From 211acc10da2e032afc86680b7c22c6c21d4c3127 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 28 Jan 2026 11:06:36 -0600 Subject: [PATCH] cpukit/shell/edit: Address -Wsign-compare warnings This warning occurs when comparing a signed variable to an unsigned one. This is frequently an int or ssize_t variable compared to a uint32_t or size_t. Sometimes the size_t is from a sizeof() use. --- cpukit/libmisc/shell/main_edit.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c index f2a4d5bb87..67993c09df 100644 --- a/cpukit/libmisc/shell/main_edit.c +++ b/cpukit/libmisc/shell/main_edit.c @@ -710,7 +710,12 @@ static int get_selection(struct editor *ed, size_t *start, size_t *end) { } static int get_selected_text(struct editor *ed, char *buffer, int size) { +#ifdef __rtems__ + int len; + size_t selstart, selend; +#else size_t selstart, selend, len; +#endif if (!get_selection(ed, &selstart, &selend)) return 0; len = selend - selstart; @@ -1112,10 +1117,18 @@ static void display_line(struct editor *ed, int pos, int fullline) { (void) get_selection(ed, &selstart, &selend); while (col < maxcol) { if (margin == 0) { +#ifdef __rtems__ + if (!hilite && (size_t)pos >= selstart && (size_t)pos < selend) { +#else if (!hilite && pos >= selstart && pos < selend) { +#endif for (s = SELECT_COLOR; *s; s++) *bufptr++ = *s; hilite = 1; +#ifdef __rtems__ + } else if (hilite && (size_t)pos >= selend) { +#else } else if (hilite && pos >= selend) { +#endif for (s = TEXT_COLOR; *s; s++) *bufptr++ = *s; hilite = 0; } @@ -1580,7 +1593,11 @@ static void indent(struct editor *ed, unsigned char *indentation) { toplines = 0; newline = 1; for (i = start; i < end; i++) { +#ifdef __rtems__ + if (i == (size_t)ed->toppos) toplines = lines; +#else if (i == ed->toppos) toplines = lines; +#endif if (newline) { lines++; newline = 0; @@ -1643,7 +1660,11 @@ static void unindent(struct editor *ed, unsigned char *indentation) { if (compare(ed, indentation, i, width)) { i += width; shrinkage += width; +#ifdef __rtems__ + if ((int)i < ed->toppos) topofs -= width; +#else if (i < ed->toppos) topofs -= width; +#endif continue; } }