From 3321a81f718e37309e21f8e8d484520b5d8b4797 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 2 Jan 2009 14:41:53 +0000 Subject: [PATCH] Fix unchecked result warnings for realpath svn path=/trunk/netsurf/; revision=5952 --- gtk/gtk_gui.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index 84afac06d..4d6487b42 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -118,32 +118,39 @@ static char *find_resource(char *buf, const char *filename, const char *def) strcpy(t, cdir); strcat(t, "/.netsurf/"); strcat(t, filename); - realpath(t, buf); - if (access(buf, R_OK) == 0) - return buf; + if (realpath(t, buf) != NULL) { + if (access(buf, R_OK) == 0) + return buf; + } } cdir = getenv("NETSURFRES"); if (cdir != NULL) { - realpath(cdir, buf); - strcat(buf, "/"); - strcat(buf, filename); - if (access(buf, R_OK) == 0) - return buf; + if (realpath(cdir, buf) != NULL) { + strcat(buf, "/"); + strcat(buf, filename); + if (access(buf, R_OK) == 0) + return buf; + } } strcpy(t, GTK_RESPATH); strcat(t, filename); - realpath(t, buf); - if (access(buf, R_OK) == 0) - return buf; + if (realpath(t, buf) != NULL) { + if (access(buf, R_OK) == 0) + return buf; + } if (def[0] == '~') { snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1); - realpath(t, buf); + if (realpath(t, buf) == NULL) { + strcpy(buf, t); + } } else { - realpath(def, buf); + if (realpath(def, buf) == NULL) { + strcpy(buf, def); + } } return buf;