3 ms·
If you look at uIP you'll realize its pretty much a gigantic function [1] with a lot of gotos and ifdefs. Not exactly what I would cite for sane code. 1: https
by lmb 12y ago
If you look at uIP you'll realize its pretty much a gigantic function [1] with a lot of gotos and ifdefs. Not exactly what I would cite for sane code.
1: https://github.com/contiki-os/contiki/blob/master/core/net/ipv4/uip.c#L673 https://github.com/contiki-os/contiki/blob/master/core/net/i...
P.S. UIP doesn't use the coroutine stuff at all it seems.
- psykotic 12y ago> Not exactly what I would cite for sane code. The uses of goto I saw compensate for C's lack of nested breaks and continues. Reasonable people may differ on this topic, but I'm perfectly fine with it. The real sin is obfuscating the natural control flow of a program by introducing dummy variables like try_again and keep_running, or being forced to split things into multiple functions just so you can use a return in lieu of a nested break. (There are single-exit zealots for whom an early-out return like that would be an equally grievous sin as the goto!) In any case, my point was to demonstrate by example that serious software can be written this way. The point wasn't to hold up uIP or Contiki or anything else as impeccable exemplars of coding style. > P.S. UIP doesn't use the coroutine stuff at all it seems. It's not used in the core but in the protocol servers: https://github.com/adamdunkels/uip/blob/master/apps/webserver/httpd.c https://github.com/adamdunkels/uip/blob/master/apps/webserve.... All the PT and PSOCK code is protothreads.