7 ms·
strtomem_pad seems redundant with memcpy_and_pad, and also it requires the preprocessor: https://github.com/torvalds/linux/blob/1a3746ccbb0a97bed3c06ccde6b88001
by DerSaidin 3mo ago
strtomem_pad seems redundant with memcpy_and_pad, and also it requires the preprocessor:
https://github.com/torvalds/linux/blob/1a3746ccbb0a97bed3c06ccde6b880013b1dddc1/include/linux/string.h#L407 https://github.com/torvalds/linux/blob/1a3746ccbb0a97bed3c06...
I was curious: Why have it, instead of just using memcpy_and_pad?
AI's answer (paraphrased) was
* Avoid possible bugs from manually write sizeof(dest)
* Enforces the __nonstring Attribute
* signals: "I am converting an actual C-string into a fixed-width legacy memory field." vs copy binary data & pad it.
Interesting to learn about the __nonstring attribute:
https://github.com/torvalds/linux/blob/1a3746ccbb0a97bed3c06ccde6b880013b1dddc1/include/linux/compiler.h#L225 https://github.com/torvalds/linux/blob/1a3746ccbb0a97bed3c06...
https://github.com/search?q=repo%3Atorvalds%2Flinux+__nonstring%3B&type=code https://github.com/search?q=repo%3Atorvalds%2Flinux+__nonstr...