From a58996a6569aaa9aa369dde3de138ebf584baa17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Gomez?= <bip@kyoshiro.org>
Date: Mon, 10 Jan 2022 19:30:56 +0100
Subject: [PATCH 24/24] sanitize: pragma ignore "passing argument X of ....
 with different width due to prototype" for array_get()?

---
 src/irc.c | 30 ++++++++++++++++++++++++++++++
 src/log.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/src/irc.c b/src/irc.c
index 5979bd0..9b25e96 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -1104,8 +1104,13 @@ void irc_add_channel_info(struct link_server *ircs, const char *chan,
 		const char *key)
 {
 	struct chan_info *ci;
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (!ischannel(*chan))
 		return;
+#pragma GCC diagnostic pop
 
 	ci = hash_get(&LINK(ircs)->chan_infos, chan);
 	if (!ci) {
@@ -1290,6 +1295,10 @@ static void irc_copy_cli(struct link_client *src, struct link_client *dest,
 		return;
 	}
 
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (ischannel(*irc_line_elem(line, 1)) || LINK(src) != LINK(dest)) {
 		assert(!line->origin);
 		line->origin = LINK(src)->l_server->nick;
@@ -1299,6 +1308,7 @@ static void irc_copy_cli(struct link_client *src, struct link_client *dest,
 		free(str);
 		return;
 	}
+#pragma GCC diagnostic pop
 
 	/* LINK(src) == LINK(dest) */
 	size_t len = strlen(irc_line_elem(line, 2)) + 6;
@@ -1508,10 +1518,15 @@ static int irc_353(struct link_server *server, struct line *line)
 		long int ovmask = 0;
 		/* some ircds (e.g. unreal) may display several flags for the
                    same nick */
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 		while ((index = bip_get_index(server->prefixes, *names))) {
 			ovmask |= 1 << index;
 			names++;
 		}
+#pragma GCC diagnostic pop
 		eon = names;
 		while (*eon && *eon != ' ')
 			eon++;
@@ -1681,11 +1696,16 @@ static void irc_user_mode(struct link_server *server, struct line *line)
 		else if (*mode == '+')
 			add = 1;
 		else {
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 			if (add) {
 				mode_add_letter_uniq(server, *mode);
 			} else {
 				mode_remove_letter(server, *mode);
 			}
+#pragma GCC diagnostic pop
 		}
 	}
 }
@@ -1715,8 +1735,13 @@ static int irc_mode(struct link_server *server, struct line *line)
 		return OK_COPY;
 	}
 
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (!ischannel(irc_line_elem(line, 1)[0]))
 		return ERR_PROTOCOL;
+#pragma GCC diagnostic pop
 
 	/* channel mode change */
 	channel = hash_get(&server->channels, irc_line_elem(line, 1));
@@ -1785,6 +1810,10 @@ static int irc_mode_channel(struct link_server *s, struct channel *channel,
 	long int ovmask;
 	int index;
 
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (*mode == 'k') {
 		if (add) {
 			channel->key = bip_strdup(
@@ -1808,6 +1837,7 @@ static int irc_mode_channel(struct link_server *s, struct channel *channel,
 			ovmask &= ~(1 << index);
 		hash_insert(&channel->ovmasks, nick, (void *)ovmask);
 	}
+#pragma GCC diagnostic pop
 	return OK_COPY;
 }
 
diff --git a/src/log.c b/src/log.c
index 43cac7b..86fe9e8 100644
--- a/src/log.c
+++ b/src/log.c
@@ -554,6 +554,10 @@ static void do_log_privmsg(log_t *logdata, const char *storage, int src,
 void log_privmsg(log_t *logdata, const char *ircmask, const char *destination,
 		const char *message)
 {
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (!ischannel(*destination)) {
 		char *nick = nick_from_ircmask(ircmask);
 		do_log_privmsg(logdata, nick, 0, ircmask, message);
@@ -561,6 +565,7 @@ void log_privmsg(log_t *logdata, const char *ircmask, const char *destination,
 	} else {
 		do_log_privmsg(logdata, destination, 0, ircmask, message);
 	}
+#pragma GCC diagnostic pop
 }
 
 void log_cli_privmsg(log_t *logdata, const char *ircmask,
@@ -574,6 +579,10 @@ void log_notice(log_t *logdata, const char *ircmask, const char *destination,
 {
 	if (!ircmask)
 		ircmask = P_IRCMASK;
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (!ischannel(*destination)) {
 		char *nick = nick_from_ircmask(ircmask);
 		do_log_privmsg(logdata, nick, 0, ircmask, message);
@@ -581,6 +590,7 @@ void log_notice(log_t *logdata, const char *ircmask, const char *destination,
 	} else {
 		do_log_privmsg(logdata, destination, 0, ircmask, message);
 	}
+#pragma GCC diagnostic pop
 }
 
 void log_cli_notice(log_t *logdata, const char *ircmask,
@@ -731,10 +741,15 @@ void log_reset_all(log_t *logdata)
 	for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
 			hash_it_next(&hi)) {
 		store = hash_it_item(&hi);
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 		if (ischannel(*hash_it_key(&hi)))
 			log_reset(store);
 		else
 			list_add_last(&drop, bip_strdup(hash_it_key(&hi)));
+#pragma GCC diagnostic pop
 	}
 
 	char *name;
@@ -751,8 +766,13 @@ void log_reset_store(log_t *log, const char *storename)
 	store = hash_get(&log->logfgs, storename);
 	if (store) {
 		log_reset(store);
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 		if (!ischannel(*storename))
 			log_drop(log, storename);
+#pragma GCC diagnostic pop
 	}
 }
 
@@ -925,10 +945,15 @@ char *log_beautify(log_t *logdata, const char *buf, const char *storename,
 		return _log_wrap(dest, buf);
 	p++;
 
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (out && !ischannel(*dest)) {
 		son = storename;
 		lon = strlen(storename);
 	}
+#pragma GCC diagnostic pop
 
 	som = p;
 	lom = strlen(p);
@@ -962,10 +987,15 @@ char *log_beautify(log_t *logdata, const char *buf, const char *storename,
 		strcpy(p, "ACTION ");
 		p += strlen("ACTION ");
 	}
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (out && !ischannel(*dest)) {
 		strcpy(p, PMSG_ARROW);
 		p += strlen(PMSG_ARROW);
 	}
+#pragma GCC diagnostic pop
 	if (logdata->user->backlog_timestamp != BLTSNone) {
 		memcpy(p, sots, lots);
 		p += lots;
@@ -1385,10 +1415,15 @@ list_t *backlog_lines(log_t *log, const char *bl, const char *cli_nick,
 	const char *dest;
 
 	ret = NULL;
+// TODO resolve this issue from array_get
+// passing argument X of .... with different width due to prototype
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtraditional-conversion"
 	if (ischannel(*bl))
 		dest = bl;
 	else
 		dest = cli_nick;
+#pragma GCC diagnostic pop
 
 	if (log_has_backlog(log, bl) || hours) {
 		if (hours == 0)
-- 
2.30.2

