]> PatchyGit - patchyircd.git/commitdiff
add warning flags for old style decls
authorEgor <egor@patchysicp.xyz>
Fri, 23 Aug 2024 05:37:27 +0000 (08:37 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 23 Aug 2024 05:37:27 +0000 (08:37 +0300)
15 files changed:
Makefile
config.example.mk
src/admin.c
src/crypt_blowfish.c
src/crypt_blowfish.h [new file with mode: 0644]
src/irc.c
src/irc.h
src/ircfmt.c
src/main.c
src/net.c
src/net.h
src/netpoll.c
src/passwd.c
src/util.c
src/util.h

index 83f14d6..5b193d6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,8 @@ HEADERS := \
        src/netsock.h    \
        src/passwd.h     \
        src/map.h        \
-       src/util.h
+       src/util.h       \
+       src/crypt_blowfish.h
 
 -include config.mk
 
index 846a327..ffb11da 100644 (file)
@@ -1,9 +1,11 @@
 HEADERS+=config.mk
 CC=clang
-CFLAGS=-Wall -Wextra -DHAS_TLS -DNETPOLL_USE_POLL -D_GNU_SOURCE
+WARNS=-Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
+#-Wmissing-variable-declarations
+CFLAGS=$(WARNS) -DHAS_TLS -DNETPOLL_USE_POLL -D_GNU_SOURCE
 LDLIBS=-ltls
 CC.w32=i686-w64-mingw32-gcc
-CFLAGS.w32=-Wall -Wextra -DNETPOLL_USE_SELECT
+CFLAGS.w32=$(WARNS) -DNETPOLL_USE_SELECT
 LDLIBS.w32=-lws2_32 -lbcrypt
 USE_MAP_DYNARR=1
 USE_LUA=1
index 4f4a56f..a0f20f2 100644 (file)
@@ -231,7 +231,6 @@ static int command_eval(lua_State *L)
 }
 static int fn_client_privmsg(lua_State *L)
 {
-       extern const char *hostname;
        struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client");
        const char *msg = luaL_checkstring(L, 2);
        msg_privmsg_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl);
@@ -239,7 +238,6 @@ static int fn_client_privmsg(lua_State *L)
 }
 static int fn_client_notice(lua_State *L)
 {
-       extern const char *hostname;
        struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client");
        const char *msg = luaL_checkstring(L, 2);
        msg_notice_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl);
index 7f21813..b586978 100644 (file)
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: MIT */
+#include "crypt_blowfish.h"
 /* Modified by Rich Felker in for inclusion in musl libc, based on
  * Solar Designer's second size-optimized version sent to the musl
  * mailing list. */
diff --git a/src/crypt_blowfish.h b/src/crypt_blowfish.h
new file mode 100644 (file)
index 0000000..fe0c2a0
--- /dev/null
@@ -0,0 +1 @@
+char *crypt_blowfish(const char *key, const char *setting, char *output);
index bd76c36..0dbe4ad 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -14,30 +14,29 @@ void sendbuf(struct client_data *client) {
        fprintf(stderr, "SERVER %"PRISocket": %.*s", client->FD, (int)databuf.len, (char*)databuf.buf);
        sendClient(client, databuf.buf, databuf.len);
 }
-void chanlog_time(time_t timestamp) {
-       extern FILE *fchanlog;
+static void chanlog_time(time_t timestamp) {
        if (fchanlog) {
                fprintf(fchanlog, "$%lu %.*s", (unsigned long)timestamp, (int)databuf.len, databuf.buf);
                fflush(fchanlog);
        }
 }
-void chanlog() {
+static void chanlog(void) {
        extern FILE *fchanlog;
        if (fchanlog) {
                fprintf(fchanlog, "%.*s", (int)databuf.len, databuf.buf);
                fflush(fchanlog);
        }
 }
-void sendbuf_chan_caps(struct channel *chan, unsigned positive, unsigned negative) {
+static void sendbuf_chan_caps(struct channel *chan, unsigned positive, unsigned negative) {
        struct client_data *cl;
        map_foreach(&chan->members, 0, &cl)
                if (!(~cl->caps & positive) && !(cl->caps & negative))
                        sendbuf(cl);
 }
-void sendbuf_chan(struct channel *chan) {
+static void sendbuf_chan(struct channel *chan) {
        sendbuf_chan_caps(chan, 0, 0);
 }
-void sendbuf_list_sans_self_caps(struct client_data *client, map_t *ls, int cookie, int positive, int negative) {
+static void sendbuf_list_sans_self_caps(struct client_data *client, map_t *ls, int cookie, int positive, int negative) {
        struct client_data *cl;
        map_foreach(ls, 0, &cl)
                if (client != cl) {
@@ -51,7 +50,7 @@ void sendbuf_list_sans_self_caps(struct client_data *client, map_t *ls, int cook
                                sendbuf(cl);
                }
 }
-void sendbuf_list_sans_self(struct client_data *client, map_t *ls, int cookie) {
+static void sendbuf_list_sans_self(struct client_data *client, map_t *ls, int cookie) {
        sendbuf_list_sans_self_caps(client, ls, cookie, 0, 0);
 }
 void sendbuf_monitor(const char *nick, int cookie, int positive, int negative)
@@ -69,7 +68,7 @@ void sendbuf_monitor(const char *nick, int cookie, int positive, int negative)
                                sendbuf(cl);
                }
 }
-int get_cookie() {
+static int get_cookie(void) {
        static int cookie = 0;
        if (++cookie == 0) {
                // handle overflow
@@ -80,7 +79,7 @@ int get_cookie() {
        }
        return cookie;
 }
-int sendbuf_visible_caps(struct client_data *client, int positive, int negative) {
+static int sendbuf_visible_caps(struct client_data *client, int positive, int negative) {
        int cookie = get_cookie();
        struct channel *chan;
        map_foreach(&client->channels, 0, &chan)
@@ -103,7 +102,7 @@ const char *format_umodes(struct client_data *cl) {
        *p++ = '\0';
        return umodes;
 }
-int match_list(struct client_data *cl, map_t *list)
+static int match_list(struct client_data *cl, map_t *list)
 {
        const char *key;
        map_foreach(list, &key, 0)
index c67286d..3786f32 100644 (file)
--- a/src/irc.h
+++ b/src/irc.h
@@ -7,6 +7,7 @@
 
 #define is_registered(cl) ((cl)->regstate == REG_REGISTERED)
 void sendbuf_monitor(const char *nick, int cookie, int positive, int negative);
+const char *format_umodes(struct client_data *cl);
 int parsePacket(struct client_data *client);
 int processPacket(struct client_data *client, char *source, char *command, int argc, char *args[]);
 void newUser(struct client_data *client);
@@ -25,4 +26,6 @@ void channel_kill(struct channel *chan);
 void channel_mode(struct client_data *client, struct channel *chan, char *args[]);
 void channel_topic(struct client_data *src, struct channel *chan, const char *topic, const char *who, time_t when);
 extern struct dynarr databuf;
+extern FILE *fchanlog;
+extern const char *hostname;
 #endif
index e40efc6..91db3ee 100644 (file)
@@ -1,8 +1,5 @@
 #include "ircfmt.h"
-extern struct dynarr databuf;
-extern const char *hostname;
-extern const char *format_umodes(struct client_data *cl);
-const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
+static const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
        if (!chan) return "";
        int o = is_chanop(chan, cl);
        int v = is_chanvoice(chan, cl);
index 02e6828..0d4bb29 100644 (file)
@@ -14,7 +14,7 @@ static void on_sigint(int signum)
        (void)signum;
        is_siginted = 1;
 }
-static void set_handler()
+static void set_handler(void)
 {
        struct sigaction sa;
        sa.sa_handler = on_sigint;
@@ -46,7 +46,7 @@ static BOOL WINAPI on_sigint(DWORD dwCtrlType)
                return FALSE;
        }
 }
-static void set_handler()
+static void set_handler(void)
 {
        SetConsoleCtrlHandler(on_sigint, TRUE);
 
@@ -88,7 +88,7 @@ struct listener {
        struct tls *ctx;
 };
 
-SOCKET create_listen_sock(const char *ip, const char *port)
+static SOCKET create_listen_sock(const char *ip, const char *port)
 {
        struct addrinfo hints, *res;
        memset(&hints, 0, sizeof(hints));
@@ -136,7 +136,7 @@ SOCKET create_listen_sock(const char *ip, const char *port)
        return sock;
 }
 
-void accept_from_sock(struct listener *listener)
+static void accept_from_sock(struct listener *listener)
 {
        for (;;) {
                struct sockaddr_storage addr;
@@ -213,7 +213,6 @@ void accept_from_sock(struct listener *listener)
                cl->peerport = port;
                if (cctx)
                        cl->umode |= UMODE_SECURE;
-               extern const char *hostname;
                if (is_local) {
                        cl->hostname = mystrdup(is_webirc ? "webirc" : is_onion ? "onion" : "localhost");
                        cl->umode |= UMODE_SECURE;
index 32d93e7..38daed2 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -3,7 +3,7 @@
 #include "ircfmt.h"
 #include "job.h"
 
-struct client_data *allocClient()
+struct client_data *allocClient(void)
 {
        return calloc(1, sizeof(struct client_data));
 }
index d339065..32d71ce 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -4,7 +4,7 @@
 
 void sendbuf(struct client_data *client);
 void sendbuf_visible(struct client_data *client);
-struct client_data *allocClient();
+struct client_data *allocClient(void);
 void update_poll_reg(struct client_data *cl);
 void killConnection(struct client_data *client, int byChoice);
 void killConnectionPart2(struct client_data *cl);
index 9203300..e784aac 100644 (file)
@@ -27,7 +27,7 @@ void net_poll_init(void)
 void net_poll_fini(void)
 {
 }
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
 {
        if (fds[i].fd >= FD_SETSIZE) {
                fprintf(stderr, "net_poll_add_impl: FD_SETSIZE limit\n");
@@ -36,12 +36,12 @@ void net_poll_add_impl(int i)
        if (lastptr >= i)
                lastptr++;
 }
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
 {
        if (lastptr > i)
                lastptr--;
 }
-void net_poll_reg_impl(int i, int ev)
+static void net_poll_reg_impl(int i, int ev)
 {
        if (ev & NETPOLL_IN)
                FD_SET(fds[i].fd, &readfds);
@@ -93,7 +93,7 @@ void net_poll_init(void)
 void net_poll_fini(void)
 {
 }
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
 {
        memmove(pollfds+i+1, pollfds+i, sizeof(pollfds[0])*(nfds-1-i));
        pollfds[i].fd = fds[i].fd;
@@ -102,13 +102,13 @@ void net_poll_add_impl(int i)
        if (lastptr >= i)
                lastptr++;
 }
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
 {
        memmove(pollfds+i, pollfds+i+1, sizeof(pollfds[0])*(nfds-(i+1)));
        if (lastptr > i)
                lastptr--;
 }
-void net_poll_reg_impl(int i, int ev)
+static void net_poll_reg_impl(int i, int ev)
 {
        pollfds[i].events = (ev & NETPOLL_IN ? POLLIN : 0) | (ev & NETPOLL_OUT ? POLLOUT : 0);
 }
@@ -159,7 +159,7 @@ void net_poll_fini(void)
        close(epollfd);
        epollfd = -1;
 }
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
 {
        struct epoll_event e = { .data.ptr = fds[i] };
        if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i]->fd, &e) == -1) {
@@ -167,7 +167,7 @@ void net_poll_add_impl(int i)
                abort();
        }
 }
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
 {
        /* prevent leaked references */
        struct epoll_event *p, *q;
@@ -183,7 +183,7 @@ void net_poll_del_impl(int i)
                abort();
        }
 }
-void net_poll_reg_impl(int i, int ev)
+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);
index 81354f2..62e9375 100644 (file)
@@ -6,7 +6,8 @@
 #else
 #include <bcrypt.h>
 #endif
-char *crypt_blowfish(const char *key, const char *setting, char *output);
+#include "passwd.h"
+#include "crypt_blowfish.h"
 char *password_crypt(const char *key, const char *setting)
 {
        static char output[128];
index bd14969..25df345 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
-void append_strn(struct dynarr *d, const char *s, int len){
+static void append_strn(struct dynarr *d, const char *s, int len){
        if (d->len + len > d->cap){
                while (d->len + len > d->cap)
                        d->cap *= 2;
@@ -85,7 +85,7 @@ char *mystrdup(const char *s) {
 }
 
 static time_t faketime = 0;
-time_t get_time() {
+time_t get_time(void) {
        return faketime ? faketime : time(NULL);
 }
 void set_time(time_t t) {
index e42520d..66c1e57 100644 (file)
@@ -24,7 +24,7 @@ void stringlower(char *s);
 #endif
 #define strcpy_lit(a, b) memcpy((a), (b), sizeof(b))
 char *mystrdup(const char *s);
-time_t get_time();
+time_t get_time(void);
 void set_time(time_t t);
 int irc_glob(const char *key, const char *mask);
 const char *getdatafile(const char *fn);