]> PatchyGit - patchyircd.git/commitdiff
fix remaining c++ warnings (initialization)
authorEgor <egor@patchysicp.xyz>
Tue, 21 Jan 2025 07:31:19 +0000 (09:31 +0200)
committerEgor <egor@patchysicp.xyz>
Tue, 21 Jan 2025 07:31:19 +0000 (09:31 +0200)
src/irc.c
src/netpoll.c

index 3799814..f82b200 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -5,9 +5,9 @@
 
 struct dynarr databuf;
 
-map_t client_map = {0};
-map_t channel_map = {0};
-map_t autojoin = {0};
+map_t client_map = {};
+map_t channel_map = {};
+map_t autojoin = {};
 
 const char *hostname = IRCDHOSTNAME;
 void sendbuf(struct client_data *client) {
index 4c7abc3..9ace612 100644 (file)
@@ -13,7 +13,7 @@ typedef struct net_pollfd net_pollfd_tabent_t;
 #endif
 
 #define NETPOLL_MAXFDS 1024
-static net_pollfd_tabent_t fds[NETPOLL_MAXFDS] = {0};
+static net_pollfd_tabent_t fds[NETPOLL_MAXFDS] = {};
 static int nfds = 0;
 
 #if defined(NETPOLL_USE_SELECT)
@@ -85,7 +85,7 @@ int net_poll_get(struct net_pollfd *out)
        return ev;
 }
 #elif defined(NETPOLL_USE_POLL)
-static struct pollfd pollfds[NETPOLL_MAXFDS] = {0};
+static struct pollfd pollfds[NETPOLL_MAXFDS] = {};
 static int lastptr = 0;
 void net_poll_init(void)
 {
@@ -110,7 +110,11 @@ static void net_poll_del_impl(int i)
 }
 static void net_poll_reg_impl(int i, int ev)
 {
-       pollfds[i].events = (ev & NETPOLL_IN ? POLLIN : 0) | (ev & NETPOLL_OUT ? POLLOUT : 0);
+       pollfds[i].events = 0;
+       if (ev & NETPOLL_IN)
+               pollfds[i].events = POLLIN;
+       if (ev & NETPOLL_OUT)
+               pollfds[i].events = POLLOUT;
 }
 int net_poll_begin(void)
 {
@@ -140,10 +144,10 @@ int net_poll_get(struct net_pollfd *out)
 #elif defined(NETPOLL_USE_EPOLL)
 #include <sys/epoll.h>
 static int epollfd = -1;
-static struct epoll_event events[256] = {0};
+static struct epoll_event events[256] = {};
 static int nevents = 0;
 static int lastptr = 0;
-static struct net_pollfd fdsbuf[NETPOLL_MAXFDS] = {0};
+static struct net_pollfd fdsbuf[NETPOLL_MAXFDS] = {};
 void net_poll_init(void)
 {
        for (int i = 0; i < NETPOLL_MAXFDS; i++)
@@ -161,7 +165,7 @@ void net_poll_fini(void)
 }
 static void net_poll_add_impl(int i)
 {
-       struct epoll_event e = { .data = { .ptr = fds[i] }};
+       struct epoll_event e = { .events = 0, .data = { .ptr = fds[i] }};
        if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i]->fd, &e) == -1) {
                perror("epoll_ctl(EPOLL_CTL_ADD)");
                abort();
@@ -185,8 +189,11 @@ static void net_poll_del_impl(int i)
 }
 static void net_poll_reg_impl(int i, int ev)
 {
-       struct epoll_event e = { .data = { .ptr = fds[i] }};
-       e.events = (ev & NETPOLL_IN ? EPOLLIN : 0) | (ev & NETPOLL_OUT ? EPOLLOUT : 0);
+       struct epoll_event e = { .events = 0, .data = { .ptr = fds[i] }};
+       if (ev & NETPOLL_IN)
+               e.events = EPOLLIN;
+       if (ev & NETPOLL_OUT)
+               e.events = EPOLLOUT;
        if (epoll_ctl(epollfd, EPOLL_CTL_MOD, fds[i]->fd, &e) == -1) {
                perror("epoll_ctl(EPOLL_CTL_MOD)");
                abort();