Bug Summary

File:irc/core/irc-servers-setup.c
Location:line 112, column 3
Description:Value stored to 'nick' is never read

Annotated Source Code

1/*
2 irc-servers-setup.c : irssi
3
4 Copyright (C) 1999-2000 Timo Sirainen
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#include "module.h"
22#include "signals.h"
23#include "network.h"
24#include "servers-setup.h"
25#include "lib-config/iconfig.h"
26#include "settings.h"
27
28#include "irc-chatnets.h"
29#include "irc-servers-setup.h"
30#include "irc-servers.h"
31
32/* Fill information to connection from server setup record */
33static void sig_server_setup_fill_reconn(IRC_SERVER_CONNECT_REC *conn,
34 IRC_SERVER_SETUP_REC *sserver)
35{
36 if (!IS_IRC_SERVER_CONNECT(conn)(((IRC_SERVER_CONNECT_REC *) chat_protocol_check_cast(((SERVER_CONNECT_REC
*) module_check_cast(conn, __builtin_offsetof(SERVER_CONNECT_REC
, type), "SERVER CONNECT")), __builtin_offsetof(IRC_SERVER_CONNECT_REC
, chat_type), "IRC")) ? (!(0)) : (0))
||
37 !IS_IRC_SERVER_SETUP(sserver)(((IRC_SERVER_SETUP_REC *) chat_protocol_check_cast(((SERVER_SETUP_REC
*) module_check_cast(sserver, __builtin_offsetof(SERVER_SETUP_REC
, type), "SERVER SETUP")), __builtin_offsetof(IRC_SERVER_SETUP_REC
, chat_type), "IRC")) ? (!(0)) : (0))
)
38 return;
39
40 if (sserver->cmd_queue_speed > 0)
41 conn->cmd_queue_speed = sserver->cmd_queue_speed;
42 if (sserver->max_cmds_at_once > 0)
43 conn->max_cmds_at_once = sserver->max_cmds_at_once;
44 if (sserver->max_query_chans > 0)
45 conn->max_query_chans = sserver->max_query_chans;
46}
47
48static void sig_server_setup_fill_connect(IRC_SERVER_CONNECT_REC *conn)
49{
50 if (!IS_IRC_SERVER_CONNECT(conn)(((IRC_SERVER_CONNECT_REC *) chat_protocol_check_cast(((SERVER_CONNECT_REC
*) module_check_cast(conn, __builtin_offsetof(SERVER_CONNECT_REC
, type), "SERVER CONNECT")), __builtin_offsetof(IRC_SERVER_CONNECT_REC
, chat_type), "IRC")) ? (!(0)) : (0))
)
51 return;
52
53 conn->alternate_nick = *settings_get_str("alternate_nick") != '\0' ?
54 g_strdup(settings_get_str("alternate_nick")) : NULL((void *)0);
55 conn->usermode = g_strdup(settings_get_str("usermode"));
56}
57
58static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
59 IRC_CHATNET_REC *ircnet)
60{
61 if (!IS_IRC_SERVER_CONNECT(conn)(((IRC_SERVER_CONNECT_REC *) chat_protocol_check_cast(((SERVER_CONNECT_REC
*) module_check_cast(conn, __builtin_offsetof(SERVER_CONNECT_REC
, type), "SERVER CONNECT")), __builtin_offsetof(IRC_SERVER_CONNECT_REC
, chat_type), "IRC")) ? (!(0)) : (0))
)
62 return;
63 g_return_if_fail(IS_IRCNET(ircnet))do{ if ((((IRC_CHATNET_REC *) chat_protocol_check_cast(((CHATNET_REC
*) module_check_cast(ircnet, __builtin_offsetof(CHATNET_REC,
type), "CHATNET")), __builtin_offsetof(IRC_CHATNET_REC, chat_type
), "IRC")) ? (!(0)) : (0))) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "IS_IRCNET(ircnet)"); return
; }; }while (0)
;
64
65 if (ircnet->nick != NULL((void *)0)) g_free_and_null(conn->alternate_nick)do { if (conn->alternate_nick) { g_free(conn->alternate_nick
); (conn->alternate_nick) = ((void *)0); } } while (0)
;
66 if (ircnet->usermode != NULL((void *)0)) {
67 g_free_and_null(conn->usermode)do { if (conn->usermode) { g_free(conn->usermode); (conn
->usermode) = ((void *)0); } } while (0)
;
68 conn->usermode = g_strdup(ircnet->usermode);
69 }
70
71 if (ircnet->max_kicks > 0) conn->max_kicks = ircnet->max_kicks;
72 if (ircnet->max_msgs > 0) conn->max_msgs = ircnet->max_msgs;
73 if (ircnet->max_modes > 0) conn->max_modes = ircnet->max_modes;
74 if (ircnet->max_whois > 0) conn->max_whois = ircnet->max_whois;
75
76 if (ircnet->max_cmds_at_once > 0)
77 conn->max_cmds_at_once = ircnet->max_cmds_at_once;
78 if (ircnet->cmd_queue_speed > 0)
79 conn->cmd_queue_speed = ircnet->cmd_queue_speed;
80 if (ircnet->max_query_chans > 0)
81 conn->max_query_chans = ircnet->max_query_chans;
82}
83
84static void init_userinfo(void)
85{
86 const char *set, *nick, *user_name, *str;
87
88 /* check if nick/username/realname wasn't read from setup.. */
89 set = settings_get_str("real_name");
90 if (set == NULL((void *)0) || *set == '\0') {
91 str = g_getenv("IRCNAME");
92 settings_set_str("real_name",
93 str != NULL((void *)0) ? str : g_get_real_name());
94 }
95
96 /* username */
97 user_name = settings_get_str("user_name");
98 if (user_name == NULL((void *)0) || *user_name == '\0') {
99 str = g_getenv("IRCUSER");
100 settings_set_str("user_name",
101 str != NULL((void *)0) ? str : g_get_user_name());
102
103 user_name = settings_get_str("user_name");
104 }
105
106 /* nick */
107 nick = settings_get_str("nick");
108 if (nick == NULL((void *)0) || *nick == '\0') {
109 str = g_getenv("IRCNICK");
110 settings_set_str("nick", str != NULL((void *)0) ? str : user_name);
111
112 nick = settings_get_str("nick");
Value stored to 'nick' is never read
113 }
114
115 /* host name */
116 set = settings_get_str("hostname");
117 if (set == NULL((void *)0) || *set == '\0') {
118 str = g_getenv("IRCHOST");
119 if (str != NULL((void *)0))
120 settings_set_str("hostname", str);
121 }
122}
123
124static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)
125{
126 g_return_if_fail(rec != NULL)do{ if (rec != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "rec != NULL"); return; }
; }while (0)
;
127 g_return_if_fail(node != NULL)do{ if (node != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "node != NULL"); return;
}; }while (0)
;
128
129 if (!IS_IRC_SERVER_SETUP(rec)(((IRC_SERVER_SETUP_REC *) chat_protocol_check_cast(((SERVER_SETUP_REC
*) module_check_cast(rec, __builtin_offsetof(SERVER_SETUP_REC
, type), "SERVER SETUP")), __builtin_offsetof(IRC_SERVER_SETUP_REC
, chat_type), "IRC")) ? (!(0)) : (0))
)
130 return;
131
132 rec->max_cmds_at_once = config_node_get_int(node, "cmds_max_at_once", 0);
133 rec->cmd_queue_speed = config_node_get_int(node, "cmd_queue_speed", 0);
134 rec->max_query_chans = config_node_get_int(node, "max_query_chans", 0);
135}
136
137static void sig_server_setup_saved(IRC_SERVER_SETUP_REC *rec,
138 CONFIG_NODE *node)
139{
140 if (!IS_IRC_SERVER_SETUP(rec)(((IRC_SERVER_SETUP_REC *) chat_protocol_check_cast(((SERVER_SETUP_REC
*) module_check_cast(rec, __builtin_offsetof(SERVER_SETUP_REC
, type), "SERVER SETUP")), __builtin_offsetof(IRC_SERVER_SETUP_REC
, chat_type), "IRC")) ? (!(0)) : (0))
)
141 return;
142
143 if (rec->max_cmds_at_once > 0)
144 iconfig_node_set_int(node, "cmds_max_at_once", rec->max_cmds_at_once)config_node_set_int(mainconfig, node, "cmds_max_at_once", rec
->max_cmds_at_once)
;
145 if (rec->cmd_queue_speed > 0)
146 iconfig_node_set_int(node, "cmd_queue_speed", rec->cmd_queue_speed)config_node_set_int(mainconfig, node, "cmd_queue_speed", rec->
cmd_queue_speed)
;
147 if (rec->max_query_chans > 0)
148 iconfig_node_set_int(node, "max_query_chans", rec->max_query_chans)config_node_set_int(mainconfig, node, "max_query_chans", rec->
max_query_chans)
;
149}
150
151void irc_servers_setup_init(void)
152{
153 settings_add_bool("server", "skip_motd", FALSE)settings_add_bool_module("irc/core", "server", "skip_motd", (
0))
;
154 settings_add_str("server", "alternate_nick", "")settings_add_str_module("irc/core", "server", "alternate_nick"
, "")
;
155
156 init_userinfo();
157 signal_add("server setup fill reconn", (SIGNAL_FUNC) sig_server_setup_fill_reconn)signal_add_full("irc/core", 0, ("server setup fill reconn"), (
SIGNAL_FUNC) ((SIGNAL_FUNC) sig_server_setup_fill_reconn), ((
void *)0))
;
158 signal_add("server setup fill connect", (SIGNAL_FUNC) sig_server_setup_fill_connect)signal_add_full("irc/core", 0, ("server setup fill connect"),
(SIGNAL_FUNC) ((SIGNAL_FUNC) sig_server_setup_fill_connect),
((void *)0))
;
159 signal_add("server setup fill chatnet", (SIGNAL_FUNC) sig_server_setup_fill_chatnet)signal_add_full("irc/core", 0, ("server setup fill chatnet"),
(SIGNAL_FUNC) ((SIGNAL_FUNC) sig_server_setup_fill_chatnet),
((void *)0))
;
160 signal_add("server setup read", (SIGNAL_FUNC) sig_server_setup_read)signal_add_full("irc/core", 0, ("server setup read"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_setup_read), ((void *)0))
;
161 signal_add("server setup saved", (SIGNAL_FUNC) sig_server_setup_saved)signal_add_full("irc/core", 0, ("server setup saved"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_setup_saved), ((void *)0))
;
162}
163
164void irc_servers_setup_deinit(void)
165{
166 signal_remove("server setup fill reconn", (SIGNAL_FUNC) sig_server_setup_fill_reconn)signal_remove_full(("server setup fill reconn"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_setup_fill_reconn), ((void *)0))
;
167 signal_remove("server setup fill connect", (SIGNAL_FUNC) sig_server_setup_fill_connect)signal_remove_full(("server setup fill connect"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_setup_fill_connect), ((void *)0))
;
168 signal_remove("server setup fill chatnet", (SIGNAL_FUNC) sig_server_setup_fill_chatnet)signal_remove_full(("server setup fill chatnet"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_setup_fill_chatnet), ((void *)0))
;
169 signal_remove("server setup read", (SIGNAL_FUNC) sig_server_setup_read)signal_remove_full(("server setup read"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) sig_server_setup_read), ((void *)0))
;
170 signal_remove("server setup saved", (SIGNAL_FUNC) sig_server_setup_saved)signal_remove_full(("server setup saved"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) sig_server_setup_saved), ((void *)0))
;
171}