]> granicus.if.org Git - graphviz/commitdiff
gvc gvplugin_library_load: replace read check using 'stat' with using 'access'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 11 Oct 2022 01:19:18 +0000 (18:19 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 13 Oct 2022 01:08:59 +0000 (18:08 -0700)
This probably uses `stat` under the hood too, but is slightly more concise and
clear about intent.

lib/gvc/gvplugin.c

index 542c1f2e3706fb89f7d7ec386c2c74c5c53f4de0..1618efc62c821b9014f9e4d3733aaff948567d0c 100644 (file)
@@ -13,8 +13,7 @@
 #include       <stdbool.h>
 #include       <stddef.h>
 #include       <string.h>
-#include        <sys/types.h>
-#include        <sys/stat.h>
+#include       <unistd.h>
 
 #ifdef ENABLE_LTDL
 #include       <ltdl.h>
@@ -159,7 +158,6 @@ gvplugin_library_t *gvplugin_library_load(GVC_t * gvc, char *path)
     static size_t lenp;
     char *libdir;
     char *suffix = "_LTX_library";
-    struct stat sb;
 
     if (!gvc->common.demand_loading)
         return NULL;
@@ -188,7 +186,7 @@ gvplugin_library_t *gvplugin_library_load(GVC_t * gvc, char *path)
     }
     hndl = lt_dlopen(p);
     if (!hndl) {
-        if (stat(p, &sb) == 0) {
+        if (access(p, R_OK) == 0) {
             agerr(AGWARN, "Could not load \"%s\" - %s\n", p, "It was found, so perhaps one of its dependents was not.  Try ldd.");
         }
         else {