On Wed, Oct 24, 2001 at 04:53:12PM +0400, Alexey V . Neyman wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello there!
> 
> I've stumbled accross the following in sys/netinet/ip_input.c (v.1.173)
> 
> - --- lines 470-477 ---
>         if (m == NULL) {    /* Packet discarded by firewall */
>             static int __debug=10;
>             if (__debug >0) {
>             printf("firewall returns NULL, please update!\n");
>             __debug-- ;
>             }
>             return;
>         }
> 
> What is the meaning of this construct? Isn't it functionally equivalent to
> 
>         if (m == NULL) {     /* Packet discarded by firewall */
>           printf("firewall returns NULL, please update!\n");
>           return;
>       }

No.  This is a C syntax issue: if a variable local to a function is
declared as static, this means that it is initialized to the specified
value once at program start, and then its value is preserved across
function calls.  That is, the variable does not start over from 10
each time; it starts at 10 at boot time, then with each pass through
this piece of code its value is decremented.  At the tenth pass since
boottime, its value reaches 0 and no more warnings are printed out.

G'luck,
Peter

-- 
This sentence would be seven words long if it were six words shorter.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to