[PATCH 44/65] strncmp -> strcmp + code-style

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 24 Aug 2014 23:29:24 +0000

---
 ii.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/ii.c b/ii.c
index 387e1f5..00eac4b 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -317,8 +317,8 @@ tokenize(char **result, size_t reslen, char *str, int delim) {
 
 static void
 channel_print(Channel *c, const char *buf) {
-	time_t t = time(NULL);
 	FILE *fp = NULL;
+	time_t t = time(NULL);
 
 	if(!(fp = fopen(c->outpath, "a")))
 		return;
_AT_@ -452,9 +452,9 @@ proc_server_cmd(int fd, char *buf) {
 
 	tokenize(&argv[TOK_CMD], TOK_LAST - TOK_CMD, cmd, ' ');
 
-	if(!argv[TOK_CMD] || !strncmp("PONG", argv[TOK_CMD], 5)) {
+	if(!argv[TOK_CMD] || !strcmp("PONG", argv[TOK_CMD])) {
 		return;
-	} else if(!strncmp("PING", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("PING", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "PONG %s\r\n", argv[TOK_TEXT]);
 		writestr(fd, msg);
 		return;
_AT_@ -465,49 +465,49 @@ proc_server_cmd(int fd, char *buf) {
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
 		channel_print(channelmaster, msg);
 		return;
-	} else if(!strncmp("ERROR", argv[TOK_CMD], 6))
+	} else if(!strcmp("ERROR", argv[TOK_CMD]))
 		snprintf(msg, sizeof(msg), "-!- error %s",
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "unknown");
-	else if(!strncmp("JOIN", argv[TOK_CMD], 5)) {
+	else if(!strcmp("JOIN", argv[TOK_CMD])) {
 		if (argv[TOK_TEXT] != NULL)
 			argv[TOK_CHAN] = argv[TOK_TEXT];
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has joined %s",
 				argv[TOK_NICKSRV],argv[TOK_USER], argv[TOK_CHAN]);
-	} else if(!strncmp("PART", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("PART", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has left %s",
 				argv[TOK_NICKSRV], argv[TOK_USER], argv[TOK_CHAN]);
 		/* if user itself leaves, don't write to channel (don't reopen channel). */
 		if(!strcmp(argv[TOK_NICKSRV], nick))
 			return;
-	} else if(!strncmp("MODE", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("MODE", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s changed mode/%s -> %s %s",
 				argv[TOK_NICKSRV],
 				argv[TOK_CHAN] ? argv[TOK_CHAN] : "",
 				argv[TOK_ARG]  ? argv[TOK_ARG] : "",
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strncmp("QUIT", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("QUIT", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s(%s) has quit \"%s\"",
 				argv[TOK_NICKSRV], argv[TOK_USER],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strncmp("NICK", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("NICK", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s changed nick to %s",
 				argv[TOK_NICKSRV], argv[TOK_TEXT]);
-	} else if(!strncmp("TOPIC", argv[TOK_CMD], 6)) {
+	} else if(!strcmp("TOPIC", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s changed topic to \"%s\"",
 				argv[TOK_NICKSRV],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strncmp("KICK", argv[TOK_CMD], 5)) {
+	} else if(!strcmp("KICK", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- %s kicked %s (\"%s\")",
 				argv[TOK_NICKSRV], argv[TOK_ARG],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strncmp("NOTICE", argv[TOK_CMD], 7)) {
+	} else if(!strcmp("NOTICE", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "-!- \"%s\")",
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
-	} else if(!strncmp("PRIVMSG", argv[TOK_CMD], 8)) {
+	} else if(!strcmp("PRIVMSG", argv[TOK_CMD])) {
 		snprintf(msg, sizeof(msg), "<%s> %s", argv[TOK_NICKSRV],
 				argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
 	}
-	if(!argv[TOK_CHAN] || !strncmp(argv[TOK_CHAN], nick, strlen(nick))) /* TODO: dont use strncmp? its wrong? */
+	if(!argv[TOK_CHAN] || !strcmp(argv[TOK_CHAN], nick))
 		channel = argv[TOK_NICKSRV];
 	else
 		channel = argv[TOK_CHAN];
_AT_@ -558,10 +558,10 @@ handle_server_output(int ircfd) {
 static void
 run(int ircfd, const char *host) {
 	Channel *c;
-	int r, maxfd;
 	fd_set rd;
 	struct timeval tv;
 	char ping_msg[IRC_MSG_MAX];
+	int r, maxfd;
 
 	snprintf(ping_msg, sizeof(ping_msg), "PING %s\r\n", host);
 	for(;;) {
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0045-fix-signed-unsigned-type-warning.patch"
Content-Disposition: attachment;
 filename="0045-fix-signed-unsigned-type-warning.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST