Hacker News new | past | comments | ask | show | jobs | submit login

One thought, most targets are not built as -ffreestanding and while the kernel doesn't link against a libc, it does provide most symbols with the same semantics. This allows the compiler to perform libcall optimizations.

For example, calls to printf can be transformed into calls to puts under certain conditions. The compiler can check + find those, even after optimizations. There are many of these tricks for the str* functions that assume NUL terminated C strings.

Though perhaps if the mem* functions were used to implement a fat strings implementation, many of those might still apply.

Point being; the compiler can help when your strings representation is first class by the language spec.

The compiler can also help with FORTIFY; it can insert compile time length checks in certain cases that can make code safer. This avoids treewide rewrites which are relatively painful to do for the Linux kernel due to its development model, but not impossible. That's another barrier to a new string representation and a library of routines for these.

That said, strscpy is not part of the language spec, so I'm guessing unless it's implemented in terms of language defined functions, it gets neither libcall optimizations nor fortified.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: