Re: pfctl/parse.y: don't check np->port for NULL

2017-05-28 Thread Alexander Bluhm
OK bluhm@

On Sat, May 27, 2017 at 07:53:30PM +0200, Michal Mazurek wrote:
> Index: sbin/pfctl/parse.y
> ===
> RCS file: /cvs/src/sbin/pfctl/parse.y,v
> retrieving revision 1.659
> diff -u -p -r1.659 parse.y
> --- sbin/pfctl/parse.y15 May 2017 11:23:25 -  1.659
> +++ sbin/pfctl/parse.y27 May 2017 17:46:24 -
> @@ -4596,7 +4596,7 @@ apply_redirspec(struct pf_pool *rpool, s
>   rpool->proxy_port[0] = ntohs(rs->rdr->rport.a);
>  
>   if (isrdr) {
> - if (!rs->rdr->rport.b && rs->rdr->rport.t && np->port != NULL) {
> + if (!rs->rdr->rport.b && rs->rdr->rport.t) {
>   rpool->proxy_port[1] = ntohs(rs->rdr->rport.a) +
>   (ntohs(np->port[1]) - ntohs(np->port[0]));
>   } else
> 
> -- 
> Michal Mazurek



pfctl/parse.y: don't check np->port for NULL

2017-05-28 Thread Michal Mazurek
Found with clang. The warning was:
clang -O2 -pipe  -Wall -Wmissing-prototypes -Wno-uninitialized 
-Wstrict-prototypes -I/usr/src/sbin/pfctl -Werror-implicit-function-declaration 
 -c parse.c  
/usr/src/sbin/pfctl/parse.y:4599:52: warning: comparison of array 
'np->port' not equal to a null pointer is always true   
  
  [-Wtautological-pointer-compare]   
if (!rs->rdr->rport.b && rs->rdr->rport.t && np->port 
!= NULL) {  
 ^~~~   
 

"np" is: struct node_port *np
which is:
struct node_port {
u_int16_tport[2];
u_int8_t op;
struct node_port*next;
struct node_port*tail;
};

Index: sbin/pfctl/parse.y
===
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.659
diff -u -p -r1.659 parse.y
--- sbin/pfctl/parse.y  15 May 2017 11:23:25 -  1.659
+++ sbin/pfctl/parse.y  27 May 2017 17:46:24 -
@@ -4596,7 +4596,7 @@ apply_redirspec(struct pf_pool *rpool, s
rpool->proxy_port[0] = ntohs(rs->rdr->rport.a);
 
if (isrdr) {
-   if (!rs->rdr->rport.b && rs->rdr->rport.t && np->port != NULL) {
+   if (!rs->rdr->rport.b && rs->rdr->rport.t) {
rpool->proxy_port[1] = ntohs(rs->rdr->rport.a) +
(ntohs(np->port[1]) - ntohs(np->port[0]));
} else

-- 
Michal Mazurek