Re: [hackers] [scroll] Catch invalid cursor positions || Jochen Sprickerhof

From: Steve Ward <planet36_AT_gmail.com>
Date: Mon, 20 Apr 2020 21:05:04 -0400

On Sat, Apr 18, 2020 at 5:04 PM <git_AT_suckless.org> wrote:

> commit a4faed60e37174f43dce47e099a8b55b1f1a5556
> Author: Jochen Sprickerhof <git_AT_jochen.sprickerhof.de>
> AuthorDate: Fri Apr 17 23:33:34 2020 +0200
> Commit: Jochen Sprickerhof <git_AT_jochen.sprickerhof.de>
> CommitDate: Fri Apr 17 23:33:34 2020 +0200
>
> Catch invalid cursor positions
>
> diff --git a/scroll.c b/scroll.c
> index 25bd3fc..09a2c3e 100644
> --- a/scroll.c
> +++ b/scroll.c
> _AT__AT_ -232,6 +232,9 @@ getcursorposition(int *x, int *y)
>
> if (sscanf(input, "\033[%d;%dR", x, y) != 2)
> die("parsing cursor position");
> +
> + if (x <= 0 || y <= 0)
> + die("invalid cursor position");
> }
>
> void
>
>
gcc emits this warning when using the "-Wextra" option. Should x and y be
dereferenced?

scroll.c: In function ‘getcursorposition’:
scroll.c:236:8: warning: ordered comparison of pointer with integer zero
[-Wextra]
  236 | if (x <= 0 || y <= 0)
      | ^~
scroll.c:236:18: warning: ordered comparison of pointer with integer zero
[-Wextra]
  236 | if (x <= 0 || y <= 0)
      | ^~
Received on Tue Apr 21 2020 - 03:05:04 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 21 2020 - 03:12:35 CEST