changeset 1190:91a783779a32 release-4.0

irccd: fix warning on invalid comparison
author David Demelier <markand@malikania.fr>
date Thu, 09 Mar 2023 12:45:22 +0100
parents b98294e7cadc
children c3235828de9a
files CHANGES.md lib/irccd/subst.c
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.md	Thu Mar 09 12:40:47 2023 +0100
+++ b/CHANGES.md	Thu Mar 09 12:45:22 2023 +0100
@@ -1,6 +1,12 @@
 IRC Client Daemon CHANGES
 =========================
 
+irccd 4.0.4 ????-??-??
+======================
+
+- Improve tests running on a slow machines.
+- Fix a warning on a invalid comparison.
+
 irccd 4.0.3 2023-02-08
 ======================
 
--- a/lib/irccd/subst.c	Thu Mar 09 12:40:47 2023 +0100
+++ b/lib/irccd/subst.c	Thu Mar 09 12:45:22 2023 +0100
@@ -139,15 +139,13 @@
 static void
 attributes_parse(const char *key, struct attributes *attrs)
 {
-	char attributes[64] = {0};
+	char attributes[64] = {0}, *p;
 
 	memset(attrs, 0, sizeof (*attrs));
 	sscanf(key, "%15[^,],%15[^,],%63s", attrs->fg, attrs->bg, attributes);
 
 	for (char *attr = attributes; *attr; ) {
-		char *p = strchr(attr, ',');
-
-		if (p)
+		if ((p = strchr(attr, ',')))
 			*p = 0;
 
 		irc_util_strlcpy(attrs->attrs[attrs->attrsz++], attr, sizeof (attrs->attrs[0]));
@@ -252,7 +250,8 @@
 
 	attributes_parse(key, &attrs);
 
-	if (attrs.fg[0] || attrs.attrs[0]) {
+	/* At least a foreground or a font attribute is present. */
+	if (attrs.fg[0] || attrs.attrs[0][0]) {
 		if (ccat(out, outsz, '\x03') < 0)
 			return -1;