Quantcast

openbsd - expression is always false

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

openbsd - expression is always false

appchecker
Hi!� Please look [this code
fragment](https://github.com/openbsd/src/blob/14a309e3a4feb469e2b128b77f1f2144a55b1bbb/usr.bin/tic/dump_entry.c#L296):```

#define FNKEY(i)    (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))

```i can't be less than 65 and more than 75 at the same time� ```This
possible defect found by
[AppChecker](https://npo-echelon.ru/en/solutions/appchecker.php)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: openbsd - expression is always false

Todd C. Miller
On Thu, 11 May 2017 08:32:05 +0300, [hidden email] wrote:

> Hi!� Please look [this code
> fragment](https://github.com/openbsd/src/blob/14a309e3a4feb469e2b128b77f1f214
> 4a55b1bbb/usr.bin/tic/dump_entry.c#L296):```
>
> #define FNKEY(i)    (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
>
> ```i can't be less than 65 and more than 75 at the same time� ```This
> possible defect found by
> [AppChecker](https://npo-echelon.ru/en/solutions/appchecker.php)

If you examing the defines in term.h it is obvious that this is a
typo.  The correct test is as follows:

 - todd

Index: usr.bin/tic/dump_entry.c
===================================================================
RCS file: /cvs/src/usr.bin/tic/dump_entry.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 dump_entry.c
--- usr.bin/tic/dump_entry.c 12 Jan 2010 23:22:14 -0000 1.19
+++ usr.bin/tic/dump_entry.c 11 May 2017 18:57:01 -0000
@@ -293,7 +293,7 @@ dump_predicate(PredType type, PredIdx id
 static void set_obsolete_termcaps(TERMTYPE *tp);
 
 /* is this the index of a function key string? */
-#define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
+#define FNKEY(i) (((i)>= 65 && (i)<= 75) || ((i)>= 216 && (i)<= 268))
 
 /*
  * If we configure with a different Caps file, the offsets into the arrays

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: openbsd - expression is always false

Theo Buehler
On Thu, May 11, 2017 at 01:03:07PM -0600, Todd C. Miller wrote:

> On Thu, 11 May 2017 08:32:05 +0300, [hidden email] wrote:
>
> > Hi!� Please look [this code
> > fragment](https://github.com/openbsd/src/blob/14a309e3a4feb469e2b128b77f1f214
> > 4a55b1bbb/usr.bin/tic/dump_entry.c#L296):```
> >
> > #define FNKEY(i)    (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
> >
> > ```i can't be less than 65 and more than 75 at the same time� ```This
> > possible defect found by
> > [AppChecker](https://npo-echelon.ru/en/solutions/appchecker.php)
>
> If you examing the defines in term.h it is obvious that this is a
> typo.  The correct test is as follows:

ok

(I would prefer some spaces in front of the > and < signs)

>
>  - todd
>
> Index: usr.bin/tic/dump_entry.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/tic/dump_entry.c,v
> retrieving revision 1.19
> diff -u -p -u -r1.19 dump_entry.c
> --- usr.bin/tic/dump_entry.c 12 Jan 2010 23:22:14 -0000 1.19
> +++ usr.bin/tic/dump_entry.c 11 May 2017 18:57:01 -0000
> @@ -293,7 +293,7 @@ dump_predicate(PredType type, PredIdx id
>  static void set_obsolete_termcaps(TERMTYPE *tp);
>  
>  /* is this the index of a function key string? */
> -#define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
> +#define FNKEY(i) (((i)>= 65 && (i)<= 75) || ((i)>= 216 && (i)<= 268))
>  
>  /*
>   * If we configure with a different Caps file, the offsets into the arrays
>

Loading...