Skip to content

Commit

Permalink
buffer is 'const void*' in output functions, as in write(2), fwrite(3…
Browse files Browse the repository at this point in the history
…) etc.
  • Loading branch information
RokerHRO authored and yoe committed May 15, 2024
1 parent 22ba4a8 commit 4a4c3ad
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cliserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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("+");
Expand Down
2 changes: 1 addition & 1 deletion cliserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 5 additions & 5 deletions nbd-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -397,7 +397,7 @@ static inline void consume_len(CLIENT* c) {
consume(c, len, buf, sizeof(buf));
}

static void socket_write(CLIENT* client, void *buf, size_t len) {
static void socket_write(CLIENT* client, const void *buf, size_t len) {
g_assert(client->socket_write != NULL);
if(client->socket_write(client, buf, len)<0) {
g_assert(client->socket_closed != NULL);
Expand Down Expand Up @@ -1790,7 +1790,7 @@ void punch_hole(int fd, off_t off, off_t len) {
}
}

static void send_reply(CLIENT* client, uint32_t opt, uint32_t reply_type, ssize_t datasize, void* data) {
static void send_reply(CLIENT* client, uint32_t opt, uint32_t reply_type, ssize_t datasize, const void* data) {
struct {
uint64_t magic;
uint32_t opt;
Expand Down
2 changes: 1 addition & 1 deletion nbdsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4a4c3ad

Please sign in to comment.