diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-04-05 19:53:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-04-05 19:53:13 -0700 |
commit | 2f4e803874067b1b6b8c372794b83ee2fc9fbf3a (patch) | |
tree | 408bcef91449c19059a3e5cd6e41fb7edb39e062 /linenoise | |
parent | e181b0717470194a853d5084f902fde539635822 (diff) | |
download | txr-2f4e803874067b1b6b8c372794b83ee2fc9fbf3a.tar.gz txr-2f4e803874067b1b6b8c372794b83ee2fc9fbf3a.tar.bz2 txr-2f4e803874067b1b6b8c372794b83ee2fc9fbf3a.zip |
warning cleanup: unsigned < 0 comparisons.
This is the fourth round of an effort to enable GCC's -Wextra
option. Instances of code that test whether an unsigned
quantity is negative are repaired. Real bugs are found.
* itypes.c (c_u32, c_uint, c_ulong): Remove useless comparison
for < 0 that was copy-pasted from the signed cases.
* linenoise/linenoise.c (show_help, edit): Do not test the
return value of the getch_fn callback for negative. It returns
wint_t, which may be unsigned. Test for the WEOF value.
This is a bug because since the original comparison is
always false, the code fails to catch the WEOF return.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 998314cf..83a08ec7 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -840,14 +840,14 @@ static void show_help(lino_t *l) break; continue; case ESC: - if ((seq[0] = lino_os.getch_fn(l->tty_ifs)) < 0) + if ((seq[0] = lino_os.getch_fn(l->tty_ifs)) == WEOF) break; - if ((seq[1] = lino_os.getch_fn(l->tty_ifs)) < 0) + if ((seq[1] = lino_os.getch_fn(l->tty_ifs)) == WEOF) break; if (seq[0] == '[') { if (seq[1] >= '0' && seq[1] <= '9') { - if ((seq[2] = lino_os.getch_fn(l->tty_ifs)) < 0) + if ((seq[2] = lino_os.getch_fn(l->tty_ifs)) == WEOF) break; if (seq[2] == '~') { switch(seq[1]) { @@ -2261,7 +2261,7 @@ static int edit(lino_t *l, const wchar_t *prompt) break; } - if (c < 0) + if (c == WEOF) goto out; if (c == 0) continue; |