strncpy(3) is abused to copy char data that are not zero-terminated with the length argument computed based on the source data, not the destination buffer. strncpy(3) is really (ab)used here as memcpy(3) and the code doesn't even take advantage of the zero-filling behavior of strncpy and adds the zero byte manually where it's needed.
Gcc complained about some of these, so fix all of them in a preemptive move. While here, do CSE on the length calculation where applicable.
strncpy
(3) is abused to copy char data that are not zero-terminated with the length argument computed based on the source data, not the destination buffer.strncpy
(3) is really (ab)used here asmemcpy
(3) and the code doesn't even take advantage of the zero-filling behavior ofstrncpy
and adds the zero byte manually where it's needed.Gcc complained about some of these, so fix all of them in a preemptive move. While here, do CSE on the length calculation where applicable.