On Fri, Jun 29, 2012 at 15:08, sven falempin wrote:
> Code Rewriting (nothing new) and asking
> 
> I seriously wonder if 'that' is good in sys/net/if_bridge.c
> if (flags == 0)
> goto return_action;
> 
> Because if i m not wrong it could be rewritten this way (diff)

That does look clearer to me.

> 
> ----------------------------------------------------------------------------------------------------------------------
> 
> Index: sys/net/if_bridge.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_bridge.c,v
> retrieving revision 1.193
> diff -u -r1.193 if_bridge.c
> --- sys/net/if_bridge.c 4 Jul 2011 06:54:49 -0000       1.193
> +++ sys/net/if_bridge.c 29 Jun 2012 19:05:19 -0000
> @@ -2208,29 +2208,17 @@
> bridge_filterrule(struct brl_head *h, struct ether_header *eh, struct mbuf
> *m)
> {
> struct brl_node *n;
> -       u_int8_t flags;
> 
> SIMPLEQ_FOREACH(n, h, brl_next) {
> -               flags = n->brl_flags &
> (BRL_FLAG_SRCVALID|BRL_FLAG_DSTVALID);
> -               if (flags == 0)
> -                       goto return_action;
> -               if (flags == (BRL_FLAG_SRCVALID|BRL_FLAG_DSTVALID)) {
> +               if ( n->brl_flags & BRL_FLAG_SRCVALID ) {
> if (bcmp(eh->ether_shost, &n->brl_src,
> ETHER_ADDR_LEN))
> -                               continue;
> -                       if (bcmp(eh->ether_dhost, &n->brl_dst,
> ETHER_ADDR_LEN))
> -                               continue;
> -                       goto return_action;
> +                                continue;
> }
> -               if (flags == BRL_FLAG_SRCVALID) {
> -                       if (bcmp(eh->ether_shost, &n->brl_src,
> ETHER_ADDR_LEN))
> +               if (n->brl_flags &  BRL_FLAG_DSTVALID) {
> +                        if (bcmp(eh->ether_dhost, &n->brl_dst,
> ETHER_ADDR_LEN))
> continue;
> -                       goto return_action;
> -               }
> -               if (flags == BRL_FLAG_DSTVALID) {
> -                       if (bcmp(eh->ether_dhost, &n->brl_dst,
> ETHER_ADDR_LEN))
> -                               continue;
> -                       goto return_action;
> }
> +               goto return_action;
> }
> return (BRL_ACTION_PASS);
> ------------------------------------------------------------------------------------------------------------------------
> 
> 
> 
> 2012/6/29 sven falempin <sven.falem...@gmail.com>
> 
>> 2012/6/29 Henning Brauer <lists-openbsdt...@bsws.de>
>>
>>> * Mike Belopuhov <m...@crypt.org.ru> [2012-06-29 13:46]:
>>> > On Fri, Jun 29, 2012 at 1:36 PM, Henning Brauer
>>> > <lists-openbsdt...@bsws.de> wrote:
>>> > > now it's very unclear what your actual problem is - the struct is
>>> > > called ifbreq and used in a number of places, most notably of course
>>> > > the ioctls.
>>> > he's trying to add patterns to the mac address matching code
>>>
>>> got that much ;)
>>>
>>> > and pretends to be done with the homework (:
>>>
>>> well... let's see wether we'll get a diff.
>>>
>>>
>> is there a theory that '&' is more time consuming than ' =='
>> because the flag use is weard
>>
>> Must .. compile ... all .. kernel .... :( (Am i right ?)
>>
>>
>>> --
>>> Henning Brauer, h...@bsws.de, henn...@openbsd.org
>>> BS Web Services, http://bsws.de, Full-Service ISP
>>> Secure Hosting, Mail and DNS Services. Dedicated Servers, Root to Fully
>>> Managed
>>> Henning Brauer Consulting, http://henningbrauer.com/
>>>
>>>
>>
>>
>> --
>>
>>
> ---------------------------------------------------------------------------------------------------------------------
> 
>> () ascii ribbon campaign - against html e-mail
>> /\

Reply via email to