lkml.org 
[lkml]   [1999]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Strange piece of code
Giovanni Picoli Tirloni wrote:

> Hi, I was having a tour in the kernel sources and I found some codes
> that I can't understand why. Like this in ppp:
>
> int
> ppp_init (struct device *dev)
> {
> static int first_time = 1; <== define to 1
> int answer = 0;

^^^^^^^^^^^^^^^^^^^
static defined here!! look at a C programming Refrence.

>
>
> if (first_time) { <== check if is 1, why ? any special special reason?
>

the first time this function be called , it is first=1 setted by the definition
above. And the second time the function be called , first_time=0 setted below.



> first_time = 0;
> answer = ppp_first_time();
> if (answer == 0)
> (void) register_symtab (&ppp_syms);
> }
> if (answer == 0)
> answer = -ENODEV;
> return answer;
> }
>
> I found many more codes like this in the source, I cant remeber where anymore.

Kevin Xie.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.036 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site