fnet.c

Simple C networking library
git clone git://git.finwo.net/lib/fnet.c
Log | Files | Refs | README

commit a94234c72fa7968ef51d960d2f35980edb226340
parent aa34b030ee03b31a751e164c7ea5b6131be8ac40
Author: Yersa Nordman <yersa@finwo.nl>
Date:   Fri,  4 Aug 2023 20:13:47 +0200

Fixed compilation warnings

Diffstat:
Msrc/fnet.c | 6+++---
Mtest.c | 5+++--
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/fnet.c b/src/fnet.c @@ -368,7 +368,7 @@ struct fnet_t * fnet_connect(const char *address, uint16_t port, const struct fn } conn->ext.status = FNET_STATUS_CONNECTED; - return conn; + return (struct fnet_t *)conn; } FNET_RETURNCODE fnet_process(const struct fnet_t *connection) { @@ -412,7 +412,7 @@ FNET_RETURNCODE fnet_process(const struct fnet_t *connection) { } rbuf->len = n; if (rbuf->len == 0) { - fnet_close(conn); + fnet_close((struct fnet_t *)conn); break; } if (conn->ext.onData) { @@ -601,7 +601,7 @@ FNET_RETURNCODE fnet_free(struct fnet_t *connection) { if (conn->prev) ((struct fnet_internal_t *)(conn->prev))->next = conn->next; if (conn == connections) connections = conn->next; - fnet_close(conn); + fnet_close((struct fnet_t *)conn); if (conn->fds) free(conn->fds); if (conn->epev) free(conn->epev); diff --git a/test.c b/test.c @@ -1,5 +1,6 @@ #include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -10,7 +11,7 @@ void onClose(struct fnet_ev *ev) { } void onData(struct fnet_ev *ev) { - printf("Data(%d): %.*s\n", ev->buffer->len, (int)(ev->buffer->len), ev->buffer->data); + printf("Data(%ld): %.*s\n", ev->buffer->len, (int)(ev->buffer->len), ev->buffer->data); // Simple echo if it was an accepted connection if (ev->connection->status & FNET_STATUS_ACCEPTED) { @@ -26,7 +27,7 @@ void onConnect(struct fnet_ev *ev) { } void onTick(struct fnet_ev *ev) { - const char *data = "Hello world!"; + char *data = "Hello world!"; int cnt = *((int*)ev->udata); fnet_write(ev->connection, &((struct buf){