Or apply Github pull request: https://github.com/NetworkBlockDevice/nbd/pull/163 Thank you! :-) Lars "roker" R.
From ab441a70dc838ac20252fe40ffea39fe2a3ae670 Mon Sep 17 00:00:00 2001 From: "Lars H. Rohwedder" <RokerHRO@users.noreply.github.com> Date: Mon, 6 May 2024 21:19:15 +0200 Subject: [PATCH] buffer is 'const void*' in output functions, as in write(2), fwrite(3) etc. --- cliserv.c | 2 +- cliserv.h | 2 +- nbd-server.c | 6 +++--- nbdsrv.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cliserv.c b/cliserv.c index 46a790e..9341e60 100644 --- a/cliserv.c +++ b/cliserv.c @@ -139,7 +139,7 @@ int readit(int f, void *buf, size_t len) { * @param len the number of bytes to be written * @return 0 on success, or -1 if the socket was closed **/ -int writeit(int f, void *buf, size_t len) { +int writeit(int f, const void *buf, size_t len) { ssize_t res; while (len > 0) { DEBUG("+"); diff --git a/cliserv.h b/cliserv.h index 8a89c04..b8e7978 100644 --- a/cliserv.h +++ b/cliserv.h @@ -89,7 +89,7 @@ uint64_t ntohll(uint64_t a); #endif int readit(int f, void *buf, size_t len); -int writeit(int f, void *buf, size_t len); +int writeit(int f, const void *buf, size_t len); #define NBD_DEFAULT_PORT "10809" /* Port on which named exports are * served */ diff --git a/nbd-server.c b/nbd-server.c index 3749b74..c5294ac 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -301,7 +301,7 @@ struct generic_conf { }; #if HAVE_GNUTLS -static int writeit_tls(gnutls_session_t s, void *buf, size_t len) { +static int writeit_tls(gnutls_session_t s, const void *buf, size_t len) { _cleanup_g_free_ char *m = NULL; ssize_t res; while(len > 0) { @@ -345,7 +345,7 @@ static int socket_read_tls(CLIENT* client, void *buf, size_t len) { return readit_tls(*((gnutls_session_t*)client->tls_session), buf, len); } -static int socket_write_tls(CLIENT* client, void *buf, size_t len) { +static int socket_write_tls(CLIENT* client, const void *buf, size_t len) { return writeit_tls(*((gnutls_session_t*)client->tls_session), buf, len); } #endif // HAVE_GNUTLS @@ -354,7 +354,7 @@ static int socket_read_notls(CLIENT* client, void *buf, size_t len) { return readit(client->net, buf, len); } -static int socket_write_notls(CLIENT* client, void *buf, size_t len) { +static int socket_write_notls(CLIENT* client, const void *buf, size_t len) { return writeit(client->net, buf, len); } diff --git a/nbdsrv.h b/nbdsrv.h index 8aeec83..4590c86 100644 --- a/nbdsrv.h +++ b/nbdsrv.h @@ -78,7 +78,7 @@ typedef struct _client { void *tls_session; /**< TLS session context. Is NULL unless STARTTLS has been negotiated. */ int (*socket_read)(struct _client*, void* buf, size_t len); - int (*socket_write)(struct _client*, void* buf, size_t len); + int (*socket_write)(struct _client*, const void* buf, size_t len); void (*socket_closed)(struct _client*); } CLIENT; -- 2.39.2
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature