repo: ngircd
action: commit
revision: 
path_from: 
revision_from: 8df445316ad08d7bdc792aaa426f21ce706b443c:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit 8df445316ad08d7bdc792aaa426f21ce706b443c
Author: Florian Westphal 
Date:   Sat Apr 19 16:58:00 2008 +0200

    Channel_Mode: Remove duplicate code.

    Incidentially, this doesn't even change the
    generated code...

diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index d711bf34678c212152b26dd3d49df6b58ddfe0e5..
index ..3786e3994593c53aa41c4e3d067190a136a61ee1 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -280,7 +280,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
 	/* Handle channel and channel-user modes */

 	char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr;
-	bool ok, set, modeok = true, skiponce, use_servermode = false;
+	bool ok, set, modeok = true, skiponce, use_servermode = false, retval;
 	int mode_arg, arg_arg;
 	CLIENT *client;
 	long l;
@@ -519,37 +519,20 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )

 		if (client) {
 			/* Channel-User-Mode */
-			if (set) {
-				if (Channel_UserModeAdd(Channel, client, x[0])) {
-					strlcat(the_args, " ", sizeof(the_args));
-					strlcat(the_args, Client_ID(client), sizeof(the_args));
-					strlcat(the_modes, x, sizeof(the_modes));
-					Log(LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"",
-						Client_Mask(client), Channel_Name(Channel), Channel_UserModes(Channel, client));
-				}
-			} else {
-				if (Channel_UserModeDel(Channel, client, x[0])) {
-					strlcat(the_args, " ", sizeof(the_args));
-					strlcat(the_args, Client_ID(client), sizeof(the_args));
-					strlcat(the_modes, x, sizeof(the_modes));
-					Log(LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"",
-						Client_Mask(client), Channel_Name(Channel), Channel_UserModes(Channel, client));
-				}
+			retval = set ? Channel_UserModeAdd(Channel, client, x[0]) : Channel_UserModeDel(Channel, client, x[0]);
+			if (retval) {
+				strlcat(the_args, " ", sizeof(the_args));
+				strlcat(the_args, Client_ID(client), sizeof(the_args));
+				strlcat(the_modes, x, sizeof(the_modes));
+				Log(LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"",
+					Client_Mask(client), Channel_Name(Channel), Channel_UserModes(Channel, client));
 			}
 		} else {
 			/* Channel-Mode */
-			if (set) {
-				if (Channel_ModeAdd( Channel, x[0])) {
-					strlcat(the_modes, x, sizeof(the_modes));
-					Log(LOG_DEBUG, "Channel %s: Mode change, now \"%s\".", Channel_Name(Channel), Channel_Modes(Channel));
-				}
-			} else {
-				/* Channel-Mode */
-				if (Channel_ModeDel(Channel, x[0])) {
-					strlcat(the_modes, x, sizeof(the_modes));
-					Log(LOG_DEBUG, "Channel %s: Mode change, now \"%s\".",
-						Channel_Name(Channel), Channel_Modes(Channel));
-				}
+			retval = set ? Channel_ModeAdd(Channel, x[0]) : Channel_ModeDel(Channel, x[0]);
+			if (retval) {
+				strlcat(the_modes, x, sizeof(the_modes));
+				Log(LOG_DEBUG, "Channel %s: Mode change, now \"%s\".", Channel_Name(Channel), Channel_Modes(Channel));
 			}
 		}

-----END OF PAGE-----