Re: Socket selection.

From: Pawel Jakub Dawidek (pjd_at_FreeBSD.org)
Date: 05/20/04

  • Next message: Dmitri Denissov: "protecting netgraph calls from outside of the network context"
    Date: Thu, 20 May 2004 23:10:58 +0200
    To: Andre Oppermann <andre@freebsd.org>
    
    
    

    On Thu, May 20, 2004 at 11:01:46PM +0200, Andre Oppermann wrote:
    +> Pawel Jakub Dawidek wrote:
    +> >
    +> > Hello.
    +> >
    +> > In in_pcblookup_hash() function, in the last loop if we find exact
    +> > match, we return immediately, if it is "wild", we store a pointer and
    +> > we countinue looking for exact match.
    +> > I wonder if this is ok, that we change pointer every time we find a
    +> > "wild" match. Is it inteded? Shouldn't it be:
    +> >
    +> > http://people.freebsd.org/~pjd/patches/in_pcb.c.2.patch
    +>
    +> No. This is a stack variable which is unconditionally initialized to
    +> NULL a few lines earlier. Checking for variable == NULL is always
    +> going to be true and makes your 'optimization' just redundand.

    But we have loop there:

            local_wild = NULL;
            [...]
            LIST_FOREACH(...) {
                    [...]
                    local_wild = <something>;
                    [...]
            }

    Isn't that possible that local_wild will be set few times?

    +> > While I'm here, I want to improve code readability a bit:
    +> >
    +> > http://people.freebsd.org/~pjd/patches/in_pcb.c.3.patch
    +> >
    +> > Is it ok?
    +>
    +> No. You change the logic of the 'if' statements to something totally
    +> different. This ain't going to work in any way.

    Hmm, no:

    for (...) {
            if (a == b && c == d) {
                    /* do something */
            }
            /* nothing here */
    }

    is equivalent to:

    for (...) {
            if (a != b || c != d)
                    continue;
            /* do something */
    }

    isn't it?

    -- 
    Pawel Jakub Dawidek                       http://www.FreeBSD.org
    pjd@FreeBSD.org                           http://garage.freebsd.pl
    FreeBSD committer                         Am I Evil? Yes, I Am!
    
    



  • Next message: Dmitri Denissov: "protecting netgraph calls from outside of the network context"

    Relevant Pages

    • Re: Function to extract values
      ... If you don't need a full-word match, you can just use the InStr function to ... do a nested loop: outer loop iterates through each name in column A. Inner ... It becomes more complicated if you need an exact match of the full word. ... with the individual words within that string, ...
      (microsoft.public.excel.programming)
    • Re: Someone
      ... basic) in order to check my program *Binomial* exactness due to his weakness in this program language. ... After Afonso suggested to other to do exactly THAT for those who ... verify the program provided exact results he call me a LIAR. ... The error was the convention of IGNORING a LOOP before the ...
      (sci.stat.math)
    • Re: Remove String from file
      ... Er, and if exact means exact, then case might be important ... ... a basic DCL loop solution: ... $OPEN/READ inp 'p1 ... $READ/END=done inp record ...
      (comp.os.vms)
    • Re: for problem...
      ... DC> why this loop does not go to k=1? ... to use floating point numbers as part of a loop control structure, ... certainly *never* if you want a specific exact result. ... and then increment to something like ...
      (comp.lang.tcl)