On non-Windows operating systems that lack `mmap`, this code fell back to
calling `read` but was not #including unistd.h. The result was a compilation
failure:
plugin/lasi/gvloadimage_lasi.c:78:17: error: implicit declaration of function
'read'; did you mean 'fread'? [-Werror=implicit-function-declaration]
78 | read(fd, us->data, statbuf.st_size);
| ^~~~
| fread
By moving to the higher level `fread` function we fix this problem as well as
enabling prefetching optimizations and avoiding `EINTR` complications.
This issue was discovered while attempting to enable this plugin in the CMake
build system.
Gitlab: related to #1836
#include "config.h"
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
us->data = NULL;
#else
us->data = malloc(statbuf.st_size);
- read(fd, us->data, statbuf.st_size);
+ fread(us->data, 1, (size_t)statbuf.st_size, us->f);
#endif
us->must_inline = true;
break;