[tz] suggestions for potential code improvements?
Kees.Dekker at infor.com
Thu Jul 23 14:50:17 UTC 2015
I extracted the v2015e code and like to ask some things:
1. Why do you not always initialize the variables that are now passed to the INITIALIZE macro (see date.c/localtime.c/zic.c/private.h)? It has (almost) no impact on performance and prevents strict compilers to complain about (potentially) non-initialized variables. If you assign zero upon declaration, the INITIALIZE macro can go away.
2. In asctime_r() (asctime.c:72 and later) two arrays are used for week days. These arrays use a size of '3' for a 3-letter weekday. I expect to use an array of '4', because the '\0' character need to fit too, because the wn and mn variables are used in a call to sprintf() (line 106), where sprintf() normally requires to use 0-terminated strings. By using a '4'-sized array, this is automatically achieved. I don't know whether all sprintf() implementations for all operating systems respect the width/size specifier and allow non-0 terminated string. Now a size/width of '3' is specified, which is not needed if the strings are well terminated, or by accident used somewhere else.
I really appreciate if you will do something with these suggestions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the tz