3 ms·
In the context of where this would be a bad idea (e.g. flight control, rescue rover, etc), you would not use `printf()`, or perhaps any standard output at all.
by vortico 11y ago
In the context of where this would be a bad idea (e.g. flight control, rescue rover, etc), you would not use `printf()`, or perhaps any standard output at all. If anything, you will use lower level `write()`, where EFAULT or something would be raised on NULL, and/or static buffers, where NULL is impossible. `printf()` is really only good for developer-friendly programming, where absolute rigor is not the focus.
- cperciva 11y ago`printf()` is really only good for developer-friendly programming, where absolute rigor is not the focus. printf gets used all the time in systems code. I count 1221 occurrences of printf (and friends) in BIND 9 alone. More to the point, "(null)" was just an example of a debugging-hostile pro-vulnerability attempt to silently "fix" bad data.
- jeremiep 11y agoBIND 9 doesn't have the same requirements as flight control software. Nobody will die if BIND segfaults, at least I hope not. The software running in your car, plane, spacecraft and the likes have very strict regulations and you will find it radically different from systems code found in a linux distribution, even if written in the same language! See http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf for more details. I wouldn't want to write code like this as it sounds very unproductive, but their reliability and astronomically small number of bugs speaks for itself.
- cperciva 11y agoMaybe we're just disagreeing about the scope of "developer-friendly programming".
- jeremiep 11y agoI was talking in the scope of the grand-parent, which mentioned flight control and rescue rover software. These environments don't care much for developer-friendly programming the way linux system utilities do.
- setpatchaddress 11y agoBIND is important internet infrastructure. We'd all be better off if it did follow the JPL standard.
- jeremiep 11y agoImportant yes but BIND can also afford having crashed nodes without the internet coming down to its knees. I'd be surprised if such a node came down and caused damages in the hundred of millions of dollars in the process. This is the distinction I wanted to make. I can't remember the last time my DNS didn't work. The internet can afford to be 'good enough', life critical software can't.
- deleted 11y ago[deleted]
- setpatchaddress 11y agoVenerable Unix utilities are generally not paragons of good modern systems programming practice.
- SamReidHughes 11y agoWith compiler-checked format strings (the norm today) printf is just fine.