Subject: | Bad check for futimens() and utimensat() |
Makefile.PL checks for presence of futimens() with this program:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <sys/stat.h>
int main(int argc, char** argv)
{
int ret1, ret2;
struct timespec ts1[2], ts2[2];
ret1 = futimens(0, ts1);
char buf[1];
read(0, buf, 0); /* Assuming reading nothing updates atime (the [0]) */
ret2 = futimens(0, ts2);
ret1 == 0 && ret2 == 0 && (ts1[0].tv_nsec != 0 || ts2[0].tv_nsec != 0) ?
exit(0) : exit(errno ? errno : -1);
}
Clang compiler warns that ts1[0].tv_nsec is unitialized. And that's true because futimens() does not write into the timespec structure.
After reading the code I think that an author of the test mistaken stat() and futimens() calls. futimens() is used to copy a timespec argument value into a file system. While stat() is used for retrieving the time stamp from the file system.