goto ignore;
}
- /* Let's hash the include file. */
- fd = open(path, O_RDONLY|O_BINARY);
- if (fd == -1) {
- cc_log("Failed to open include file %s", path);
- goto failure;
- }
- if (fstat(fd, &st) != 0) {
- cc_log("Failed to fstat include file %s", path);
+ if (stat(path, &st) != 0) {
+ cc_log("Failed to stat include file %s", path);
goto failure;
}
if (S_ISDIR(st.st_mode)) {
/* Ignore directory, typically $PWD. */
goto ignore;
}
+
+ /* Let's hash the include file. */
+ fd = open(path, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ cc_log("Failed to open include file %s", path);
+ goto failure;
+ }
if (!(sloppiness & SLOPPY_INCLUDE_FILE_MTIME)
&& st.st_mtime >= time_of_compilation) {
cc_log("Include file %s too new", path);
char *data;
int result;
- fd = open(path, O_RDONLY|O_BINARY);
- if (fd == -1) {
- cc_log("Failed to open %s", path);
- return HASH_SOURCE_CODE_ERROR;
- }
- if (fstat(fd, &st) == -1) {
- cc_log("Failed to fstat %s", path);
- close(fd);
+ if (stat(path, &st) == -1) {
+ cc_log("Failed to stat %s", path);
return HASH_SOURCE_CODE_ERROR;
}
if (st.st_size == 0) {
- close(fd);
return HASH_SOURCE_CODE_OK;
}
+ fd = open(path, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ cc_log("Failed to open %s", path);
+ return HASH_SOURCE_CODE_ERROR;
+ }
data = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
if (data == (void *)-1) {