Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion authd/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ lookup_hostname(const char *ip, DNSCB callback, void *data)
void
cancel_query(struct dns_query *query)
{
query->callback = query->data = NULL;
query->callback = NULL;
query->data = NULL;
}

/* Callback from gethost_byname_type */
Expand Down Expand Up @@ -240,6 +241,7 @@ handle_resolve_dns(int parc, char *parv[])
{
case '6':
aftype = AF_INET6;
// fallthrough
case '4':
if(!lookup_ip(record, aftype, submit_dns_answer, id))
submit_dns_answer(NULL, false, qtype, NULL);
Expand Down
13 changes: 10 additions & 3 deletions bandb/bantool.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,17 @@ main(int argc, char *argv[])
fprintf(stdout, "* Allowing duplicate bans...\n");

/* checking for our files to import or export */
for(i = 0; i < LAST_BANDB_TYPE; i++)
for (i = 0; i < LAST_BANDB_TYPE; i++)
{
if (snprintf(conf, sizeof(conf), "%s/%s.conf%s",
etc, bandb_table[i], bandb_suffix[i]) >= sizeof(conf)) {
int written = snprintf(conf, sizeof(conf), "%s/%s.conf%s",
etc, bandb_table[i], bandb_suffix[i]);
if (written < 0)
{
fprintf(stderr, "* Error: Failed to generate config filename\n");
exit(EXIT_FAILURE);
}

if ((unsigned int)written >= sizeof(conf)) {
fprintf(stderr, "* Error: Config filename too long\n");
exit(EXIT_FAILURE);
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/m_webirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
if (parc >= 6)
{
const char *s;
for (s = parv[5]; s != NULL; (s = strchr(s, ' ')) && s++)
for (s = parv[5]; s != NULL; (void)((s = strchr(s, ' ')) && s++))
{
if (!ircncmp(s, "secure", 6) && (s[6] == '=' || s[6] == ' ' || s[6] == '\0'))
secure = 1;
Expand Down
2 changes: 1 addition & 1 deletion extensions/tag_message_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ generate_msgid(char *buf, size_t len, struct Client *source_p, const char *targe
*/
char *encoded = NULL;
if (target != NULL)
encoded = rb_base64_encode(target, strlen(target));
encoded = (char *)rb_base64_encode((const unsigned char *)target, strlen(target));

snprintf(buf, len, "1%010d%03d%06d%s%s",
(unsigned)prev_ts, prev_ms, ctr, source_p->id, encoded == NULL ? "" : encoded);
Expand Down
2 changes: 1 addition & 1 deletion include/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ int iter_comm_channels_step(rb_dlink_node *pos1, rb_dlink_node *pos2,
#define ITER_COMM_CHANNELS(pos1, pos2, head1, head2, ms1, ms2, chptr) \
for ((pos1) = (head1), (pos2) = (head2); \
iter_comm_channels_step((pos1), (pos2), &(ms1), &(ms2), &(chptr)); \
(ms1) && ((pos1) = (pos1)->next), (ms2) && ((pos2) = (pos2)->next))
(void)((ms1) && ((pos1) = (pos1)->next)), (void)((ms2) && ((pos2) = (pos2)->next)))


extern rb_dlink_list global_channel_list;
Expand Down
1 change: 0 additions & 1 deletion include/ircd.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ extern int testing_conf;
extern struct ev_entry *check_splitmode_ev;

extern bool ircd_ssl_ok;
extern bool ircd_zlib_ok;
extern int maxconnections;

void ircd_shutdown(const char *reason) __attribute__((noreturn));
Expand Down
23 changes: 3 additions & 20 deletions include/s_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,16 @@
#include "send.h"
#include "snomask.h"

#ifdef __GNUC__
#define ss_assert(expr) ( \
((expr)) || ( \
ilog(L_MAIN, \
"file: %s line: %d (%s): Assertion failed: (%s)", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) || (\
__FILE__, __LINE__, __func__, #expr), 0) || (\
sendto_realops_snomask(SNO_GENERAL, L_ALL, \
"file: %s line: %d (%s): Assertion failed: (%s)", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) \
__FILE__, __LINE__, __func__, #expr), 0) \
)
#else
#define ss_assert(expr) ( \
((expr)) || ( \
ilog(L_MAIN, \
"file: %s line: %d: Assertion failed: (%s)", \
__FILE__, __LINE__, #expr), 0) || ( \
sendto_realops_snomask(SNO_GENERAL, L_ALL, \
"file: %s line: %d: Assertion failed: (%s)" \
__FILE__, __LINE__, #expr), 0) \
)
#endif

/* evaluates to true if assertion fails */
#ifdef SOFT_ASSERT
#define s_assert(expr) (!ss_assert(expr))
#else
#define s_assert(expr) (assert(ss_assert(expr)), 0)
#endif
#define s_assert(expr) assert(ss_assert(expr))

#endif /* INCLUDED_s_assert_h */
2 changes: 1 addition & 1 deletion include/s_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern void introduce_client(struct Client *client_p, struct Client *source_p,
extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user,
const char *host, int newts, const char *format, ...);

extern int user_modes[256];
extern unsigned int user_modes[256];
extern unsigned int find_umode_slot(void);
extern void construct_umodebuf(void);

Expand Down
8 changes: 4 additions & 4 deletions ircd/batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ allocate_batch_message(struct MsgBuf *msg)
char *c;
struct BatchMessage *copy = rb_malloc(sizeof(struct BatchMessage));

for (int i = 0; i < msg->n_tags; i++)
for (size_t i = 0; i < msg->n_tags; i++)
{
len += strlen(msg->tags[i].key) + 1;
len += strlen(msg->tags[i].value) + 1;
}

for (int i = 0; i < msg->n_para; i++)
for (size_t i = 0; i < msg->n_para; i++)
{
len += strlen(msg->para[i]) + 1;
}
Expand All @@ -147,7 +147,7 @@ allocate_batch_message(struct MsgBuf *msg)

copy->msg.n_tags = msg->n_tags;
copy->msg.tagslen = msg->tagslen;
for (int i = 0; i < msg->n_tags; i++)
for (size_t i = 0; i < msg->n_tags; i++)
{
strcpy(c, msg->tags[i].key);
copy->msg.tags[i].key = c;
Expand All @@ -159,7 +159,7 @@ allocate_batch_message(struct MsgBuf *msg)
}

copy->msg.n_para = msg->n_para;
for (int i = 0; i < msg->n_para; i++)
for (size_t i = 0; i < msg->n_para; i++)
{
strcpy(c, msg->para[i]);
copy->msg.para[i] = c;
Expand Down
2 changes: 1 addition & 1 deletion ircd/chmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,

mbuf = modebuf;

for (ml = parv[0]; *ml != 0 && ms - modesets < ARRAY_SIZE(modesets); ml++)
for (ml = parv[0]; *ml != 0 && (size_t)(ms - modesets) < ARRAY_SIZE(modesets); ml++)
{
c = *ml;
switch (c)
Expand Down
21 changes: 3 additions & 18 deletions ircd/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1976,24 +1976,9 @@ free_user(struct User *user, struct Client *client_p)
/*
* sanity check
*/
if(user->refcnt < 0 || user->invited.head || user->channel.head)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"* %p user (%s!%s@%s) %p %p %p %lu %d *",
client_p,
client_p ? client_p->
name : "<noname>",
client_p->username,
client_p->host,
user,
user->invited.head,
user->channel.head,
rb_dlink_list_length(&user->channel),
user->refcnt);
s_assert(!user->refcnt);
s_assert(!user->invited.head);
s_assert(!user->channel.head);
}
s_assert(!user->refcnt);
s_assert(!user->invited.head);
s_assert(!user->channel.head);

rb_bh_free(user_heap, user);
}
Expand Down
8 changes: 4 additions & 4 deletions ircd/client_tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include "client_tags.h"

static struct client_tag_support supported_client_tags[MAX_CLIENT_TAGS];
static int num_client_tags = 0;
static int max_client_tags = MAX_CLIENT_TAGS;
static unsigned int num_client_tags = 0;
static unsigned int max_client_tags = MAX_CLIENT_TAGS;

int
add_client_tag(const char *name)
Expand All @@ -51,7 +51,7 @@ add_client_tag(const char *name)
void
remove_client_tag(const char *name)
{
for (int index = 0; index < num_client_tags; index++)
for (unsigned int index = 0; index < num_client_tags; index++)
{
if (!strcmp(supported_client_tags[index].name, name)) {
if (index < num_client_tags - 1)
Expand All @@ -68,7 +68,7 @@ format_client_tags(char *dst, size_t dst_sz, const char *individual_fmt, const c
size_t start = 0;
size_t join_len = strlen(join_sep);
*dst = 0;
for (size_t index = 0; index < num_client_tags; index++) {
for (unsigned int index = 0; index < num_client_tags; index++) {
if (start >= dst_sz)
break;

Expand Down
1 change: 0 additions & 1 deletion ircd/ircd.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ bool kline_queued = false;
bool server_state_foreground = false;
bool opers_see_all_users = false;
bool ircd_ssl_ok = false;
bool ircd_zlib_ok = true;

int testing_conf = 0;
time_t startup_time;
Expand Down
4 changes: 2 additions & 2 deletions ircd/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "s_assert.h"
#include "logger.h"

static rb_dlink_list listener_list = {};
static rb_dlink_list listener_list;
static int accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, void *data);
static void accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t addrlen, void *data);
static SSL_OPEN_CB accept_sslcallback;
Expand Down Expand Up @@ -230,7 +230,7 @@ find_listener(struct rb_sockaddr_storage *addr, int sctp)
if (listener->sctp != sctp)
continue;

for (int i = 0; i < ARRAY_SIZE(listener->addr); i++) {
for (size_t i = 0; i < ARRAY_SIZE(listener->addr); i++) {
if (GET_SS_FAMILY(&addr[i]) != GET_SS_FAMILY(&listener->addr[i]))
goto next;

Expand Down
16 changes: 8 additions & 8 deletions ircd/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int match(const char *mask, const char *name)
for (n_tmp = n; *n && irctolower(*n) != irctolower(*m); n++);
}
}
/* and fall through */
// fallthrough
default:
if (!*n)
return (*m != '\0' ? 0 : 1);
Expand Down Expand Up @@ -198,7 +198,7 @@ int mask_match(const char *mask_, const char *name)
for (n_tmp = n; *n && irctolower(*n) != irctolower(*m); n++);
}
}
/* and fall through */
// fallthrough
default:
if (!*n)
return (*m != '\0' ? 0 : 1);
Expand Down Expand Up @@ -624,8 +624,8 @@ int ircncmp(const void *s1, const void *s2, int n)
void matchset_for_client(struct Client *who, struct matchset *m)
{
bool hide_ip = IsIPSpoof(who) || (!ConfigChannel.ip_bans_through_vhost && IsDynSpoof(who));
unsigned hostn = 0;
unsigned ipn = 0;
unsigned int hostn = 0;
unsigned int ipn = 0;

struct sockaddr_in ip4;

Expand Down Expand Up @@ -659,11 +659,11 @@ void matchset_for_client(struct Client *who, struct matchset *m)
ipn++;
}

for (int i = hostn; i < ARRAY_SIZE(m->host); i++)
for (size_t i = hostn; i < ARRAY_SIZE(m->host); i++)
{
m->host[i][0] = '\0';
}
for (int i = ipn; i < ARRAY_SIZE(m->ip); i++)
for (size_t i = ipn; i < ARRAY_SIZE(m->ip); i++)
{
m->ip[i][0] = '\0';
}
Expand All @@ -678,14 +678,14 @@ bool client_matches_mask(struct Client *who, const char *mask)

bool matches_mask(const struct matchset *m, const char *mask)
{
for (int i = 0; i < ARRAY_SIZE(m->host); i++)
for (size_t i = 0; i < ARRAY_SIZE(m->host); i++)
{
if (m->host[i][0] == '\0')
break;
if (match(mask, m->host[i]))
return true;
}
for (int i = 0; i < ARRAY_SIZE(m->ip); i++)
for (size_t i = 0; i < ARRAY_SIZE(m->ip); i++)
{
if (m->ip[i][0] == '\0')
break;
Expand Down
4 changes: 2 additions & 2 deletions ircd/newconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ static char *listener_address[2];
static int
conf_begin_listen(struct TopConf *tc)
{
for (int i = 0; i < ARRAY_SIZE(listener_address); i++) {
for (size_t i = 0; i < ARRAY_SIZE(listener_address); i++) {
rb_free(listener_address[i]);
listener_address[i] = NULL;
}
Expand All @@ -894,7 +894,7 @@ conf_begin_listen(struct TopConf *tc)
static int
conf_end_listen(struct TopConf *tc)
{
for (int i = 0; i < ARRAY_SIZE(listener_address); i++) {
for (size_t i = 0; i < ARRAY_SIZE(listener_address); i++) {
rb_free(listener_address[i]);
listener_address[i] = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion ircd/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ read_packet(rb_fde_t * F, void *data)

/* Check to make sure we're not flooding */
if(!IsAnyServer(client_p) &&
(rb_linebuf_alloclen(&client_p->localClient->buf_recvq) + client_p->localClient->pending_batch_lines > ConfigFileEntry.client_flood_max_lines))
(rb_linebuf_alloclen(&client_p->localClient->buf_recvq) + (int)client_p->localClient->pending_batch_lines > ConfigFileEntry.client_flood_max_lines))
{
if(!(ConfigFileEntry.no_oper_flood && IsOperGeneral(client_p)))
{
Expand Down
6 changes: 2 additions & 4 deletions ircd/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,9 @@ do_numeric(int numeric, struct Client *client_p, struct Client *source_p, struct
if(parc > 1)
{
char *t = buffer; /* Current position within the buffer */
int i;
int tl; /* current length of presently being built string in t */
for (i = 2; i < (parc - 1); i++)
for (size_t i = 2; i < (parc - 1); i++)
{
tl = sprintf(t, " %s", parv[i]);
int tl = sprintf(t, " %s", parv[i]);
t += tl;
}
sprintf(t, " :%s", parv[parc - 1]);
Expand Down
3 changes: 1 addition & 2 deletions ircd/s_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,7 @@ attach_conf(struct Client *client_p, struct ConfItem *aconf)
if(IsIllegal(aconf))
return (NOT_AUTHORISED);

if(s_assert(ClassPtr(aconf)))
return (NOT_AUTHORISED);
s_assert(ClassPtr(aconf));

if(!add_ip_limit(client_p, aconf))
return (TOO_MANY_LOCAL);
Expand Down
4 changes: 2 additions & 2 deletions ircd/s_serv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
if(server_p == NULL)
return 0;

for (int i = 0; i < ARRAY_SIZE(sa_connect); i++) {
for (size_t i = 0; i < ARRAY_SIZE(sa_connect); i++) {
SET_SS_FAMILY(&sa_connect[i], AF_UNSPEC);
SET_SS_FAMILY(&sa_bind[i], AF_UNSPEC);
}
Expand Down Expand Up @@ -1158,7 +1158,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
SetConnecting(client_p);
rb_dlinkAddTail(client_p, &client_p->node, &global_client_list);

for (int i = 0; i < ARRAY_SIZE(sa_connect); i++) {
for (size_t i = 0; i < ARRAY_SIZE(sa_connect); i++) {
if (GET_SS_FAMILY(&sa_bind[i]) == AF_UNSPEC) {
if (GET_SS_FAMILY(&sa_connect[i]) == GET_SS_FAMILY(&ServerInfo.bind4))
sa_bind[i] = ServerInfo.bind4;
Expand Down
4 changes: 2 additions & 2 deletions ircd/s_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void user_welcome(struct Client *source_p);
char umodebuf[128];

static int orphaned_umodes = 0;
int user_modes[256] = {
unsigned int user_modes[256] = {
/* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0F */
/* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x1F */
/* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x2F */
Expand Down Expand Up @@ -1567,7 +1567,7 @@ construct_umodebuf(void)
{
int i;
char *ptr = umodebuf;
static int prev_user_modes[128];
static unsigned int prev_user_modes[128];

*ptr = '\0';

Expand Down
Loading
Loading