Re[2]: [PATCH v2] Huge performance boost for recursion (cp, du, find, ls, rm, mv)
Laurent Bercot via busybox <[email protected]> Thu, 02 Apr 2026 11:19:37 +0000
| Newsgroups | gmane.linux.busybox |
|---|---|
| Message-ID | <[email protected]> |
>Defensive coding about p != NULL is a good practice that shouldn't be >avoided unless a branch-analyzer is used as an automatism to grant p >!= NULL at every code change. Or people could realize that a nullable pointer (indicating an option: either NULL or a reference to an object) and a non-nullable pointer (an unconditional reference to an object) are two different types, even if the C type system does not treat them as such; document their interfaces accordingly; and make sure the function contracts are respected. Using a nullable pointer where a non-nullable one is expected is a bug, and so is the opposite even though it won't cause a segfault. Defensive programming is a sign of lack of control on the code. "I don't know what my input is at this point, so I'll add a check just in case." Not exactly inspiring trust. It's just like input sanitization, which should only happen in the outer layers because *you should always know whether you're handling sanitized or unsanitized input*. Defense in depth is good practice when you're operating a system that can be breached. Programming is different - it's not operating the system, it's designing it, and I'd rather not have my architect say "is it breachable here? I don't know, but who cares, we test for intrusions anyway". -- Laurent