[hackers] [surf][PATCH] Don't call setstyle with an empty path

From: Nick Hanley <nicholasjhanley_AT_gmail.com>
Date: Tue, 3 May 2022 04:02:56 -0400

There is no need to call setstyle if there is no style to be set. Fixes
spurious warnings about unreadable style files.
---
 surf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/surf.c b/surf.c
index 010e5e2..2192025 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -862,8 +862,11 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
 	case Style:
 		webkit_user_content_manager_remove_all_style_sheets(
 		    webkit_web_view_get_user_content_manager(c->view));
-		if (a->i)
-			setstyle(c, getstyle(geturi(c)));
+		if (a->i) {
+			const char *file = getstyle(geturi(c));
+			if (file)
+				setstyle(c, file);
+		}
 		refresh = 0;
 		break;
 	case WebGL:
_AT_@ -936,7 +939,7 @@ getstyle(const char *uri)
 			return styles[i].file;
 	}
 
-	return "";
+	return NULL;
 }
 
 void
-- 
2.35.1
Received on Tue May 03 2022 - 10:02:56 CEST

This archive was generated by hypermail 2.3.0 : Tue May 03 2022 - 12:12:34 CEST