changeset 1174:41fdadaa33b3

irccd: fix compiler warning
author David Demelier <markand@malikania.fr>
date Thu, 06 Oct 2022 13:55:57 +0200
parents 18e92d7f859f
children 11496b42f39e
files lib/irccd/subst.c
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lib/irccd/subst.c	Wed Sep 28 15:26:10 2022 +0200
+++ b/lib/irccd/subst.c	Thu Oct 06 13:55:57 2022 +0200
@@ -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,7 @@
 
 	attributes_parse(key, &attrs);
 
-	if (attrs.fg[0] || attrs.attrs[0]) {
+	if (attrs.fg[0] || attrs.attrsz) {
 		if (ccat(out, outsz, '\x03') < 0)
 			return -1;