From 4627ee82dd825690218317ab9e6a991c5afcfb42 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Mon, 8 Jan 2018 21:43:18 +0100 Subject: degesch: simplify a popular assertion --- degesch.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/degesch.c b/degesch.c index 74ce5e1..612722b 100644 --- a/degesch.c +++ b/degesch.c @@ -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) { -- cgit v1.2.3-70-g09d2