Commits

Serge A. Zaitsev  committed f5d1768

some very minor changes after static code analyzing with splint

  • Participants
  • Parent commits a06c87b

Comments (0)

Files changed (2)

 
 static char *prompt() {
 	static char prompt_buf[32];
-	snprintf(prompt_buf, sizeof(prompt_buf), "[%s] > ", channel);
+	(void) snprintf(prompt_buf, sizeof(prompt_buf), "[%s] > ", channel);
 	return prompt_buf;
 }
 
 	struct passwd *passwd;
 
 	passwd = getpwuid(getuid());
-	return passwd->pw_name;
+	if (passwd == NULL) {
+		return "johndoe";
+	} else {
+		return passwd->pw_name;
+	}
 }
 
 /* Print final message and exit */
 	va_list ap;
 
 	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
+	(void) vfprintf(stderr, fmt, ap);
 	va_end(ap);
 	if (fmt[strlen(fmt) - 1] == ':')
 		fprintf(stderr," errno=%d (%s)", errno, strerror(errno));
 		if (r == 0)
 			break; /* successfully connected */
 
-		close(fd);
+		(void) close(fd);
 	}
 
 	free(ai);
 
 	saved_point = rl_point;
 	saved_line = rl_copy_text(0, rl_end);
-	rl_set_prompt("");
+	(void) rl_set_prompt("");
 	rl_replace_line("", 0);
 	rl_redisplay();
 
 	va_start(ap, fmt);
-	vfprintf(stdout, fmt, ap);
+	(void) vfprintf(stdout, fmt, ap);
 	va_end(ap);
 	fprintf(stdout, "\n");
 
-	rl_set_prompt(prompt());
+	(void) rl_set_prompt(prompt());
 	rl_replace_line(saved_line, 0);
 	rl_point = saved_point;
 	rl_redisplay();
 	char *usr = "";
 	char *arg;
 	char *msg;
-	char *c;
 
 	if (resp[0] == ':') {
 		char *c;
 		if (id == 1) { 
 			/* first response from server: try to authenicate
 			 * and join channel */
-			if (auth_nickserv && password != NULL) {
+			if (auth_nickserv != 0 && password != NULL) {
 				irc_send("PRIVMSG NickServ :IDENTIFY %s", password);
 			}
 			if (script != NULL) {
 		}
 		server_message(usr, cmd, arg, msg);
 	}
+	return 0;
 }
 
 /* TODO: Parse user input and process it */
 	char *s;
 	if (req[0] == ':') {
 		c = &req[1];
-		if (*c && (*(c+1) == '\0' ||isspace(*(c+1)))) {
+		if (*c != '\0' && (*(c+1) == '\0' ||isspace(*(c+1)))) {
 			char cmd = *c;
 			while (*c && isspace(*++c)); s = c;
 			switch (cmd) {
 						strncpy(channel, s, sizeof(channel));
 					break;
 				case 'l':
-					while (*c && !isspace(*++c)); *c++ = '\0';
+					while (*c != '\0' && !isspace(*++c)); *c++ = '\0';
 					if (*s == '\0')
 						s = channel; /* leave the default channel */
 					if (*c == '\0')
 		your_message(channel, channel, req);
 		irc_send("PRIVMSG %s :%s", channel, req);
 	}
+	return 0;
 }
 
 static void rl_handler(char* c) {}
 
 	/* prepare readline: set handler for CRLF, enable async mode */
 	rl_callback_handler_install(prompt(), rl_handler);
-	rl_bind_key('\n', rl_newline_handler);
-	rl_bind_key('\r', rl_newline_handler);
+	rl_bind_key((int) '\n', rl_newline_handler);
+	rl_bind_key((int) '\r', rl_newline_handler);
 	rl_erase_empty_line = 1;
 
 	if (nick == NULL) {
 		nick = whoami();
 	}
 
-	if(auth_nickserv == 0 && password) {
+	if(auth_nickserv == 0 && password != 0) {
 		irc_send("PASS %s", password);
 	}
 	irc_send("NICK %s", nick);