Tick-tock: Understanding the Neutrino microkernel's concept

Mario Charest a écrit :

// — Set priority to max so we don’t get disrupted but anything
// — else then interrupts
{
struct sched_param param;
int ret;
param.sched_priority = sched_get_priority_max( SCHED_RR );
ret = sched_setscheduler( 0, SCHED_RR, &param);
assert ( ret != -1 );
}


That made me remember why I use

if ( … ) {

}

instead of

if ( …)
{

}

The reason being that if by mistake, the line with the if is deleted, in the
first style it will be detected at compile time. In the second style it is
not detected at all.

Hence if I see my own code like this:

{
struct sched_param param;
int ret;
param.sched_priority = sched_get_priority_max( SCHED_RR );
ret = sched_setscheduler( 0, SCHED_RR, &param);
assert ( ret != -1 );
}

I never have to ask myself if something got deleted > :wink:

Of course some people will intent the {}

if ()
{

}

But I still find this dangerous in case of mismatch tab versus space setup
in a editor > :wink:

Oh good, I never though of this trick.

Alain.