[Swan-dev] more code that looks suspicious

Paul Wouters paul at nohats.ca
Thu Mar 27 21:51:46 EET 2014


On Sat, 22 Mar 2014, D. Hugh Redelmeier wrote:

> In find_host_connection2:
> 		for (; c != NULL; c = c->hp_next) {
> 		   	DBG(DBG_CONTROLMORE,
> 				DBG_log("found policy = %s (%s)",
> 	                                bitnamesof(sa_policy_bit_names,
>      		                        	c->policy),
> 			         	c->name));
> 			if (NEVER_NEGOTIATE(c->policy))
>     		                continue;
>
> 		        if ((c->policy & policy) == policy)
> 		   		break;
>
>                        if ((policy & POLICY_XAUTH) !=
>        	                (c->policy & POLICY_XAUTH))
> 		                continue;
> 		}
>
> Look at that last if.  If the test is true, the loop continues.
> Otherwise, the loop continues.  In other words: it cannot have any
> effect.
>
> What was intended here?

It looks like older versions had the last two if statements reversed,
eg:

>                        if ((policy & POLICY_XAUTH) !=
>                               (c->policy & POLICY_XAUTH))
>                               continue;

>                       if ((c->policy & policy) == policy)
>                               break;

In either case, I don't see why POLICY_XAUTH should be special in this
code, and I think it can be safely removed.

Paul


More information about the Swan-dev mailing list