degesch: simplify a popular assertion

This commit is contained in:
Přemysl Eric Janouch 2018-01-08 21:43:18 +01:00
parent 682f90e989
commit 4627ee82dd
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 10 additions and 20 deletions

View File

@ -5975,8 +5975,7 @@ irc_get_buffer_for_message (struct server *s,
if (irc_is_channel (s, target))
{
struct channel *channel = str_map_find (&s->irc_channels, target);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
// This is weird
if (!channel)
@ -6489,8 +6488,7 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
// We've joined a new channel
if (!channel && irc_is_this_us (s, msg->prefix))
@ -6554,8 +6552,7 @@ irc_handle_kick (struct server *s, const struct irc_message *msg)
struct user *user = str_map_find (&s->irc_users, target);
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
// It would be weird for this to be false
if (user && channel)
@ -6609,8 +6606,7 @@ irc_handle_mode (struct server *s, const struct irc_message *msg)
{
struct channel *channel = str_map_find (&s->irc_channels, context);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, context);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
int flags = 0;
if (channel
@ -6821,8 +6817,7 @@ irc_handle_part (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
// It would be weird for this to be false
if (user && channel)
@ -7055,8 +7050,7 @@ irc_handle_topic (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
// It would be is weird for this to be false
if (channel)
@ -7388,8 +7382,7 @@ irc_handle_rpl_topic (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
if (channel)
{
@ -7411,8 +7404,7 @@ irc_handle_rpl_channelmodeis (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
if (channel)
{
@ -7449,8 +7441,7 @@ irc_handle_rpl_creationtime (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
if (buffer)
{
@ -7475,8 +7466,7 @@ irc_handle_rpl_topicwhotime (struct server *s, const struct irc_message *msg)
struct channel *channel = str_map_find (&s->irc_channels, channel_name);
struct buffer *buffer = str_map_find (&s->irc_buffer_map, channel_name);
hard_assert ((channel && buffer) ||
(channel && !buffer) || (!channel && !buffer));
hard_assert (channel || !buffer);
if (buffer)
{