Remove useless check for !nick from userhostbase callbacks

The userhostbase callback is always called with non-null nick.  Checking for
this is just noise which also sometimes results in odd compiler warnings.
This commit is contained in:
Kevin Easton
2015-06-24 23:20:53 +10:00
parent 05cf540a99
commit 28bd7a66b6
8 changed files with 53 additions and 57 deletions

View File

@@ -305,21 +305,19 @@ void userhost_unban(UserhostItem *stuff, char *nick1, char *args)
char *channel, *ip_str = NULL, *host = NULL; char *channel, *ip_str = NULL, *host = NULL;
int count = 0, old_server = from_server; int count = 0, old_server = from_server;
if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1))
{ {
if (nick1 && (whowas = check_whowas_nick_buffer(nick1, args, 0))) if ((whowas = check_whowas_nick_buffer(nick1, args, 0)))
{ {
malloc_sprintf(&host, "%s!%s", whowas->nicklist->nick, whowas->nicklist->host); malloc_sprintf(&host, "%s!%s", whowas->nicklist->nick, whowas->nicklist->host);
bitchsay("Using WhoWas info for unban of %s ", nick1); bitchsay("Using WhoWas info for unban of %s ", nick1);
n = whowas->nicklist; n = whowas->nicklist;
} }
else if (nick1) else
{ {
bitchsay("No match for the unban of %s on %s", nick1, args); bitchsay("No match for the unban of %s on %s", nick1, args);
return; return;
} }
if (!nick1)
return;
} }
else else
malloc_sprintf(&host, "%s!%s@%s",stuff->nick, stuff->user, stuff->host); malloc_sprintf(&host, "%s!%s@%s",stuff->nick, stuff->user, stuff->host);
@@ -371,9 +369,9 @@ void userhost_ban(UserhostItem *stuff, char *nick1, char *args)
fuck = !my_stricmp("FUCK", args); fuck = !my_stricmp("FUCK", args);
set_ignore = !my_stricmp("BKI", args); set_ignore = !my_stricmp("BKI", args);
if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1))
{ {
if (nick1 && channel && (whowas = check_whowas_nick_buffer(nick1, channel, 0))) if (channel && (whowas = check_whowas_nick_buffer(nick1, channel, 0)))
{ {
nick = whowas->nicklist->nick; nick = whowas->nicklist->nick;
user = m_strdup(clear_server_flags(whowas->nicklist->host)); user = m_strdup(clear_server_flags(whowas->nicklist->host));
@@ -382,7 +380,7 @@ void userhost_ban(UserhostItem *stuff, char *nick1, char *args)
bitchsay("Using WhoWas info for ban of %s ", nick1); bitchsay("Using WhoWas info for ban of %s ", nick1);
n = whowas->nicklist; n = whowas->nicklist;
} }
else if (nick1) else
{ {
bitchsay("No match for the %s of %s on %s", fuck ? "Fuck":"Ban", nick1, channel); bitchsay("No match for the %s of %s on %s", fuck ? "Fuck":"Ban", nick1, channel);
return; return;
@@ -406,7 +404,7 @@ void userhost_ban(UserhostItem *stuff, char *nick1, char *args)
c = lookup_channel(channel, from_server, 0); c = lookup_channel(channel, from_server, 0);
if (c && !n) if (c && !n)
n = find_nicklist_in_channellist(nick, c, 0); n = find_nicklist_in_channellist(nick, c, 0);
send_to_server("MODE %s %s %s %s", channel, on_chan ? ob : b, on_chan?nick:empty_string, ban_it(nick, user, host, (n && n->ip)?n->ip:NULL)); send_to_server("MODE %s %s %s %s", channel, on_chan ? ob : b, on_chan?nick:empty_string, ban_it(nick, user, host, n ? n->ip : NULL));
if (fuck) if (fuck)
{ {
malloc_sprintf(&str, "%s!*%s@%s %s 3 Auto-Shit", nick, user, host, channel); malloc_sprintf(&str, "%s!*%s@%s %s 3 Auto-Shit", nick, user, host, channel);

View File

@@ -241,7 +241,7 @@ int i;
void userhost_clink(UserhostItem *stuff, char *nick, char *args) void userhost_clink(UserhostItem *stuff, char *nick, char *args)
{ {
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
{ {
bitchsay("No information for %s found", nick); bitchsay("No information for %s found", nick);
return; return;
@@ -886,16 +886,15 @@ char buffer[IRCD_BUFFER_SIZE+1];
void invite_dcc_chat(UserhostItem *stuff, char *nick, char *args) void invite_dcc_chat(UserhostItem *stuff, char *nick, char *args)
{ {
char *id; char *id = next_arg(args, &args);
int idx = -1; int idx = atol(id);
id = next_arg(args, &args);
idx = atol(id); if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) {
{
if (check_dcc_socket(idx)) if (check_dcc_socket(idx))
dcc_printf(idx, "No such for user %s\n", nick); dcc_printf(idx, "No such for user %s\n", nick);
return; return;
} }
dcc_chat(NULL, nick); dcc_chat(NULL, nick);
send_to_server("NOTICE %s :You've been invited to a TwilightZone", nick); send_to_server("NOTICE %s :You've been invited to a TwilightZone", nick);
send_to_server("NOTICE %s :Please type .chat in dcc chat to start", nick); send_to_server("NOTICE %s :Please type .chat in dcc chat to start", nick);

View File

@@ -870,7 +870,7 @@ BUILT_IN_COMMAND(dcc_stat_comm)
void handle_dcc_chat(UserhostItem *stuff, char *nick, char *args) void handle_dcc_chat(UserhostItem *stuff, char *nick, char *args)
{ {
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || !strcmp(stuff->host, "<UNKNOWN>")) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || !strcmp(stuff->host, "<UNKNOWN>"))
{ {
bitchsay("No such nick %s", nick); bitchsay("No such nick %s", nick);
return; return;

View File

@@ -458,9 +458,10 @@ DCC_List *find_dcc_pending(char *nick, char *desc, char *othername, int type, in
void add_userhost_to_chat(UserhostItem *stuff, char *nick, char *args) void add_userhost_to_chat(UserhostItem *stuff, char *nick, char *args)
{ {
SocketList *Client = NULL; SocketList *Client = NULL;
DCC_int *n = NULL; DCC_int *n = NULL;
if (!stuff || !nick || !stuff->nick || !stuff->user || !stuff->host || !strcmp(stuff->user, "<UNKNOWN>"))
if (!stuff || !stuff->nick || !stuff->user || !stuff->host || !strcmp(stuff->user, "<UNKNOWN>"))
return; return;
if ((Client = find_dcc(nick, "chat", NULL, DCC_CHAT, 0, -1, -1))) if ((Client = find_dcc(nick, "chat", NULL, DCC_CHAT, 0, -1, -1)))
n = (DCC_int *)get_socketinfo(Client->is_read); n = (DCC_int *)get_socketinfo(Client->is_read);

View File

@@ -3078,17 +3078,16 @@ void userhost_nsl(UserhostItem *stuff, char *nick, char *args)
{ {
char *nsl = NULL; char *nsl = NULL;
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
{ {
say("No information for %s", nick); say("No information for %s", nick);
return; return;
} }
if(args) if (args)
{ {
nsl = LOCAL_COPY(args); next_arg(args, &nsl);
next_arg(nsl, &nsl);
} }
nsl = do_nslookup(stuff->host, stuff->nick, stuff->user, NULL, from_server, NULL, (nsl && *nsl) ? nsl : NULL); do_nslookup(stuff->host, stuff->nick, stuff->user, NULL, from_server, NULL, (nsl && *nsl) ? nsl : NULL);
} }
#endif #endif
@@ -3738,7 +3737,8 @@ void start_finger (UserhostItem *stuff, char *nick, char *args)
{ {
char *finger_userhost = NULL; char *finger_userhost = NULL;
char *str; char *str;
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
{ {
say("No information for %s", nick); say("No information for %s", nick);
return; return;
@@ -3819,16 +3819,15 @@ static int scan(char *remote_host, int low_port, int high_port, struct sockaddr_
void userhost_scanport(UserhostItem *stuff, char *nick, char *args) void userhost_scanport(UserhostItem *stuff, char *nick, char *args)
{ {
char *t; char *t;
int low_port = 0, int low_port = 0, high_port = 0;
high_port = 0; struct sockaddr_foobar *host; /* gee, and what's this one for? */
struct sockaddr_foobar *host; /* gee, and what's this one for? */
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
{ {
bitchsay("No such nick [%s] found", nick); bitchsay("No such nick [%s] found", nick);
return; return;
} }
next_arg(args, &args); next_arg(args, &args);
t = next_arg(args, &args); t = next_arg(args, &args);
low_port = atol(t); low_port = atol(t);
@@ -3892,9 +3891,9 @@ void userhost_ignore (UserhostItem *stuff, char *nick1, char *args)
WhowasList *whowas; WhowasList *whowas;
arg = next_arg(args, &args); arg = next_arg(args, &args);
if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1))
{ {
if ((whowas = check_whowas_nick_buffer(nick1, arg, 0))) if ((whowas = check_whowas_nick_buffer(nick1, arg, 0)))
{ {
bitchsay("Using WhoWas info for %s of %s ", arg, nick1); bitchsay("Using WhoWas info for %s of %s ", arg, nick1);
user = host; host = strchr(host, '@'); *host++ = 0; user = host; host = strchr(host, '@'); *host++ = 0;

View File

@@ -863,8 +863,9 @@ extern int use_nat_address;
void get_nat_address(UserhostItem *stuff, char *nick, char *args) void get_nat_address(UserhostItem *stuff, char *nick, char *args)
{ {
char *h; char *h;
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN"))
if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN"))
return; return;
if (isdigit((unsigned char)*stuff->host)) if (isdigit((unsigned char)*stuff->host))
h = stuff->host; h = stuff->host;

View File

@@ -490,9 +490,9 @@ static int norm = 0,
return ret; return ret;
} }
void whohas_nick (UserhostItem *stuff, char *nick, char *args) void whohas_nick(UserhostItem *stuff, char *nick, char *args)
{ {
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>")) if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>"))
return; return;
put_it("%s", convert_output_format("$G Your nick %R[%n$0%R]%n is owned by %W$1@$2", "%s %s %s", nick, stuff->user, stuff->host)); put_it("%s", convert_output_format("$G Your nick %R[%n$0%R]%n is owned by %W$1@$2", "%s %s %s", nick, stuff->user, stuff->host));
return; return;

View File

@@ -214,12 +214,11 @@ void prepare_addshit(UserhostItem *stuff, char *nick, char *args)
char listbuf[BIG_BUFFER_SIZE+1]; char listbuf[BIG_BUFFER_SIZE+1];
int thetype = 0, shit = 0; int thetype = 0, shit = 0;
if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) {
{ bitchsay("No such nick [%s] found", nick);
bitchsay("No such nick [%s] found", nick); return;
return; }
}
thetype = my_atol(args); thetype = my_atol(args);
next_arg(args, &args); next_arg(args, &args);
@@ -271,24 +270,23 @@ int count = 0;
void prepare_adduser(UserhostItem *stuff, char *nick, char *args) void prepare_adduser(UserhostItem *stuff, char *nick, char *args)
{ {
int thetype = 0; int thetype = 0;
unsigned long flags = 0; unsigned long flags = 0;
int ppp = 0; int ppp = 0;
UserList *uptr = NULL; UserList *uptr = NULL;
char *channels = NULL, char *channels = NULL,
*passwd = NULL, *passwd = NULL,
*p = NULL, *p = NULL,
*uh, *uh,
*e_host, *e_host,
*host; *host;
if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) {
{
bitchsay("No such nick [%s] found", nick); bitchsay("No such nick [%s] found", nick);
return; return;
} }
thetype = my_atol(args); thetype = my_atol(args);
next_arg(args, &args); next_arg(args, &args);