Purpose of while(1); statement in C -
what purpose while(1); serve ? aware while(1) (no semicolon) loops infinitely , similar spinlock situation. not see while(1); used ?
if(!condition) { while(1); } note: not case of do-while() or plain while(1).
please note valid statements of language not have to serve purpose. valid per grammar of language. 1 can build many similar "useless" statements, such if (1);. see such statements conjunction of conditional (if, while, etc.) , empty statement ; (which valid statement although serves no specific purpose).
that beingness said, encountered while (1); in security code. when user bad embedded device, can block them trying else. while (1);, can unconditionally block device until accredited operator manually reboots it.
while(1); can part of implementation of kernel panic, although for(;;) {} loop seems more mutual way of expressing infinite loop, , there might non-empty body (for instance panic_blink()).
c while-loop
No comments:
Post a Comment