Help me code

I study lib RF24NETWORK of maniacbug , and I don't understand this code
void RF24Network::setup_address(void)
{
// First, establish the node_mask
uint16_t node_mask_check = 0xFFFF;
while ( node_address & node_mask_check )
node_mask_check <<= 3;

node_mask = ~ node_mask_check;

// parent mask is the next level down
uint16_t parent_mask = node_mask >> 3;

// parent node is the part IN the mask
parent_node = node_address & parent_mask;

// parent pipe is the part OUT of the mask
uint16_t i = node_address;
uint16_t m = parent_mask;
while (m)
{
i >>= 3;
m >>= 3;
}
parent_pipe = i;

#ifdef SERIAL_DEBUG
printf_P(PSTR("setup_address node=0%o mask=0%o parent=0%o pipe=0%o\n\r"),node_address,node_mask,parent_node,parent_pipe);
#endif
}

why after while ( node_address & node_mask_check ) don't have {} , so how do this run ??(

A few ground rules of the C language.

  1. All whitespace is equivalent to a single whitespace character.
    A tab, a line break, a string of spaces, are all reduced to a single space, during the first pass of the compiler.

  2. Statements are delimited by a semicolon.
    statement;

  3. A compound statement is one or more statements delimited by braces, better known as a code block
    { statement; statement; }

  4. A compound statement is syntactically equivalent to a statement.
    Anywhere you can use a statement, you can use a compound statement.

'while' is a conditional loop with the syntax
while(condition) statement;

Following the rules above

while (true)  doSomething();

//is the same as...
while (true)
  doSomething();

//is the same as
while (true) { doSomething(); }  

//is the same as...
while(true) 
{
 doSomething();
}

//is the same as
while(true) {
 doSomething();
}

Because the compiler only insists the syntax is correct,
it is very important to adopt a consistent formatting style,
to maintain readability of the source.

Personally I favour the last example,
as lines of code always end in a semicolon or a brace character.

thank you very much ^^

while(true) {

doSomething();
}

Personally I favour the last example,
as lines of code always end in a semicolon or a brace character.

Last night I tried formatting an entire sketch to this:

while(true) 
{
 doSomething();
}

I couldnt figure out why I didnt like the way it looks.

as lines of code always end in a semicolon or a brace character

This is exactly why I prefer this format, I just couldnt put my finger on it ! :slight_smile: