proposed time zone package changes--core dump avoidance

Robert Elz kre at munnari.OZ.AU
Sat Feb 6 19:35:32 UTC 2010


The only issue I have is that it is traditional (not sure if required
by the standards or not) to return a writable string from asctime - callers
often stick nuls on top of spaces to remove the parts that aren't needed.

Returning a "" string directly returns a const (read only memory, possibly)
string, what's more, if it is able to be modified, and is modified, then
the next time it is returned, the modified version will be.

Further, I think asctime_r() is supposed to return its result in the
buffer that's passed in, so I think I'd do

	memcpy(buf, "??? ??? ?? ??:??:?? ????\n");
	return buf;

rather than

	return "??? ??? ?? ??:??:?? ????\n";

kre

ps: I'm not really convinced the changes to the time*() funcs are worth
the bother, there are zillions of library functions that crash if passed
a NULL arg - asctime_r() is only special here, as when ctime() calls it,
it is called with the result of localtime() which can be null, and aside
from calling localtime() and checking the result, there's no real way for
the programmer to avoid that one.




More information about the tz mailing list