From: Matthew Fernandez Date: Tue, 11 Oct 2022 01:13:19 +0000 (-0700) Subject: gvc gvconfig: replace existence check using 'stat' with using 'access' X-Git-Tag: 7.0.0~13^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01bbb7b93b94f0121206d20547e2464a7b3db480;p=graphviz gvc gvconfig: replace existence check using 'stat' with using 'access' This probably uses `stat` under the hood too, but is slightly more concise and clear about intent. --- diff --git a/lib/gvc/gvconfig.c b/lib/gvc/gvconfig.c index 1b8c0af50..76f7fac15 100644 --- a/lib/gvc/gvconfig.c +++ b/lib/gvc/gvconfig.c @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef ENABLE_LTDL #ifdef HAVE_DL_ITERATE_PHDR @@ -552,7 +553,7 @@ void gvconfig(GVC_t * gvc, bool rescan) { #ifdef ENABLE_LTDL int rc; - struct stat config_st, libdir_st; + struct stat config_st; FILE *f = NULL; char *config_text = NULL; char *libdir; @@ -568,8 +569,7 @@ void gvconfig(GVC_t * gvc, bool rescan) if (gvc->common.demand_loading) { /* see if there are any new plugins */ libdir = gvconfig_libdir(gvc); - rc = stat(libdir, &libdir_st); - if (rc == -1) { + if (access(libdir, F_OK) < 0) { gvtextlayout_select(gvc); /* choose best available textlayout plugin immediately */ /* if we fail to stat it then it probably doesn't exist so just fail silently */ return;