From: Matthew Fernandez Date: Mon, 4 Apr 2022 02:33:29 +0000 (-0700) Subject: Lasi plugin: fix: use buffered I/O instead of raw I/O X-Git-Tag: 4.0.0~117^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=496958add08fe8b56aed3354cab6b39ec45895e1;p=graphviz Lasi plugin: fix: use buffered I/O instead of raw I/O 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 --- diff --git a/plugin/lasi/gvloadimage_lasi.c b/plugin/lasi/gvloadimage_lasi.c index 0d3207263..54de8cac7 100644 --- a/plugin/lasi/gvloadimage_lasi.c +++ b/plugin/lasi/gvloadimage_lasi.c @@ -11,6 +11,7 @@ #include "config.h" #include +#include #include #include #include @@ -75,7 +76,7 @@ static void lasi_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, bool filled) 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;