From 1dcbd3eb4da9002c9ed73b6a9f2423bdc3b8ffea Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 11 Feb 2018 17:09:43 -0300 Subject: irc.h: Add G_GNUC_PRINTF annotations to printf-like functions The change in root_commands.c is due to -Wformat-zero-length, which is bs but whatever. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47901 --- root_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 957c9518..1278126f 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1235,7 +1235,7 @@ static void cmd_plugins(irc_t *irc, char **cmd) } #endif - irc_rootmsg(irc, ""); + irc_rootmsg(irc, " "); gstr = g_string_new(NULL); prpls = get_protocols(); -- cgit v1.2.3 From 16ea00d7e84a05703e047fa010e2b0621104220b Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 11 Feb 2018 18:27:17 -0300 Subject: root_commands: Improve 'chat add' error/success messages This handles the most common error case with an obvious error message (channel already exists, join it, etc), and the rarer ones with vague but different wording. For those cases: - "Could not add chatroom." This wording is not present in this version anymore, likely means the channel already exists. - "Error creating channel for chatroom." irc_channel_new() failed but the channel doesn't exist already. This could be that some name validation failed, but this function already generates a suitable name. - "Error adding chatroom." irc_channel_new() succeeded, but one of the set_setstr() failed. There are account checks earlier, and the room setting is not normally validated at this point. Can't really imagine situations where these vague errors would still show up, but at least now you only get those for unknown cases. --- root_commands.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 1278126f..4988e382 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1341,13 +1341,19 @@ static void cmd_chat(irc_t *irc, char **cmd) set_setstr(&ic->set, "chat_type", "room") && set_setstr(&ic->set, "account", cmd[2]) && set_setstr(&ic->set, "room", room)) { - irc_rootmsg(irc, "Chatroom successfully added."); + irc_rootmsg(irc, "Chatroom successfully added, join with \002/join %s\002", channel); } else { if (ic) { irc_channel_free(ic); - } - irc_rootmsg(irc, "Could not add chatroom."); + irc_rootmsg(irc, "Error adding chatroom."); + } else if (irc_channel_by_name(irc, channel)) { + irc_rootmsg(irc, "A channel named `%s' already exists. " + "Join with \002/join %s\002 or see \002help channel\002 to modify it", + channel, channel); + } else { + irc_rootmsg(irc, "Error creating channel for chatroom."); + } } g_free(channel); } else if (g_strcasecmp(cmd[1], "list") == 0) { -- cgit v1.2.3 From a81e6a05515a4df80a52d8b5aa848646e73e66c6 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 19 Mar 2018 12:38:41 -0300 Subject: root_commands: Fix -Wformat-security errors Showed up in debian builds --- root_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index 4988e382..27ef16d2 100644 --- a/root_commands.c +++ b/root_commands.c @@ -440,7 +440,7 @@ static void cmd_account(irc_t *irc, char **cmd) if (prpl == NULL) { char *msg = explain_unknown_protocol(cmd[2]); irc_rootmsg(irc, "Unknown protocol"); - irc_rootmsg(irc, msg); + irc_rootmsg(irc, "%s", msg); g_free(msg); return; } @@ -594,7 +594,7 @@ static void cmd_account(irc_t *irc, char **cmd) char *proto = set_getstr(&a->set, "_protocol_name"); char *msg = explain_unknown_protocol(proto); irc_rootmsg(irc, "Unknown protocol `%s'", proto); - irc_rootmsg(irc, msg); + irc_rootmsg(irc, "%s", msg); g_free(msg); } else { account_on(irc->b, a); @@ -1056,7 +1056,7 @@ static void cmd_blist(irc_t *irc, char **cmd) } if (error) { - irc_rootmsg(irc, error->message); + irc_rootmsg(irc, "%s", error->message); g_error_free(error); } -- cgit v1.2.3