Skip to content

Commit a16014c

Browse files
Nicolas Pitregregkh
authored andcommitted
vt: ucs.c: fix misappropriate in_range() usage
The in_range() helper accepts a start and a length, not a start and an end. Signed-off-by: Nicolas Pitre <[email protected]> Reviewed-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 063a896 commit a16014c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/tty/vt/ucs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int interval32_cmp(const void *key, const void *element)
4646

4747
static bool cp_in_range16(u16 cp, const struct ucs_interval16 *ranges, size_t size)
4848
{
49-
if (!in_range(cp, ranges[0].first, ranges[size - 1].last))
49+
if (cp < ranges[0].first || cp > ranges[size - 1].last)
5050
return false;
5151

5252
return __inline_bsearch(&cp, ranges, size, sizeof(*ranges),
@@ -55,7 +55,7 @@ static bool cp_in_range16(u16 cp, const struct ucs_interval16 *ranges, size_t si
5555

5656
static bool cp_in_range32(u32 cp, const struct ucs_interval32 *ranges, size_t size)
5757
{
58-
if (!in_range(cp, ranges[0].first, ranges[size - 1].last))
58+
if (cp < ranges[0].first || cp > ranges[size - 1].last)
5959
return false;
6060

6161
return __inline_bsearch(&cp, ranges, size, sizeof(*ranges),
@@ -144,8 +144,8 @@ static int recomposition_cmp(const void *key, const void *element)
144144
u32 ucs_recompose(u32 base, u32 mark)
145145
{
146146
/* Check if characters are within the range of our table */
147-
if (!in_range(base, UCS_RECOMPOSE_MIN_BASE, UCS_RECOMPOSE_MAX_BASE) ||
148-
!in_range(mark, UCS_RECOMPOSE_MIN_MARK, UCS_RECOMPOSE_MAX_MARK))
147+
if (base < UCS_RECOMPOSE_MIN_BASE || base > UCS_RECOMPOSE_MAX_BASE ||
148+
mark < UCS_RECOMPOSE_MIN_MARK || mark > UCS_RECOMPOSE_MAX_MARK)
149149
return 0;
150150

151151
struct compare_key key = { base, mark };

0 commit comments

Comments
 (0)