Hi Jukka

Jukka Salmi wrote:
I'm not sure whether dwm really should try that hard to fix the input
it is given...
Yeh, probably not necessary and wasted code.

- '\0'-terminates the error message if read() failed (just in case
  strlen(strerror(errno)) >= sizeof stext - 1)
stext is declared as global and therefore aligned in the programs bss segment, which will be zeroed at startup. As whether read nor strncpy use its full length (strlen/sizeof - 1) the string will be 0 terminated in any case. But I agree that it would be safer in case someone ever moves it down into main (this time I'm not sure if necessary/wasted).

- saves 1020 bytes from being zeroed unnecessarily (performance! ;-))
Ok, never thought about that. Yet I didn't read much about the implementation of the ANSI stdio functions (I presumed to understand them). Is strncpy really zeroing up to the specified n bytes? I thought it just copies until '\0' or n, whatever comes first (leaving dest unterminated in the latter case).

Regards, Manuel

Reply via email to