POSIX allows for the atime (or technically, any of the times) to be
updated as a side effect of searching a directory (allows, not requires).
The NetBSD UDF implementation apparently works that way, treating a
directory search as a read of the directory, and hence updating the
access time. Compensate for that in the test (rather than just
expecting failure) by verifying that the atime after the directory
search is within a small margin of the atime before the search
(currently, "small" is 1 second). We could fetch the time before
the mkdir and both stat() calls, do all of that, fetch the time after,
subtract, and require the after stat() atime to be bounded by the atime
set by the original mkdir and returned in the first stat() and that time
+ the difference in elapsed time - that would be more accurate, but is
a lot more work for little real benefit.
Should anyone be interested in doing that extra work, remember to use
monotonic time (clock_gettime(CLOCK_MOMNOTONIC, ...)) not the time of day
clock for measuring the elapsed time.
Along with this, remove the "if (udf) failure expected" and the
if (udf && we haven't failed yet) fail("random failure failed to happen")
stuff... (the "random" would have been that sometimes the mkdir and
two lookups (stat() calls) would all occur within the same clock tick,
meaning that the atimes would all be the same. Other times the clock
would tick somewhere between the mkdir() and the 2nd stat().)
behavior and when new memory is zeroed.
Also, strengthen the warning about mixing with calls to malloc (which
is not a bug) and mention that the portable way to fetch the initial
break is to call sbrk(0). There are implementations in the wild where
using _end as the initial break doesn't work.
to timeval. Also, don't truncate the seconds part to int for y2038.
I've had this patch sitting around since 2010 and I completely forget
what motivated it.
1) Set the stdio error indicator on __slbexpand() failure.
2) fgetwc(3) may succeed even when ferror(3) is already set
(for example, consider a program using SIG_IGN on SIGTTIN,
reading from the tty while in the background, getting EIO,
then coming to the foreground and reading again).
So do not force fgetwln(3) to fail in such a case either.
(Yes, the program should probably clearerr(3) before
reading again, but let's be nicer in case it forgets.)