Tuesday, 27 August 2013

Default clause before case sections in the switch statement

Default clause before case sections in the switch statement

Found this in linux/kernel/signal.c
switch (_NSIG_WORDS) {
default:
for (i = 1; i < _NSIG_WORDS; ++i) {
x = *++s &~ *++m;
if (!x)
continue;
sig = ffz(~x) + i*_NSIG_BPW + 1;
break;
}
break;
case 2:
x = s[1] &~ m[1];
if (!x)
break;
sig = ffz(~x) + _NSIG_BPW + 1;
break;
case 1:
/* Nothing to do */
break;
}
Maybe this is not quite good example, but I can't understand how it works
and what prompted Linus to put default-section at front of switch
statement.

No comments:

Post a Comment