From 467336a84e94195a6832a07def2c2a8a42a659c8 Mon Sep 17 00:00:00 2001 From: Hubert Tarasiuk Date: Sun, 24 May 2015 13:29:45 +0200 Subject: [PATCH 1/9] Const-qualify buffer when writing to fd. * src/connect.c: add const qualifier in sock_write, fd_write. * src/connect.h: add const qualifier in fd_write declaration and in transport_implementation struct. * src/gnutls.c: add const qualifier in wgnutls_write. --- src/connect.c | 4 ++-- src/connect.h | 4 ++-- src/gnutls.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/connect.c b/src/connect.c index 024b231..45eb57f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -764,7 +764,7 @@ sock_read (int fd, char *buf, int bufsize) } static int -sock_write (int fd, char *buf, int bufsize) +sock_write (int fd, const char *buf, int bufsize) { int res; do @@ -947,7 +947,7 @@ fd_peek (int fd, char *buf, int bufsize, double timeout) TIMEOUT. */ int -fd_write (int fd, char *buf, int bufsize, double timeout) +fd_write (int fd, const char *buf, int bufsize, double timeout) { int res; struct transport_info *info; diff --git a/src/connect.h b/src/connect.h index 9b08848..5ea2616 100644 --- a/src/connect.h +++ b/src/connect.h @@ -65,7 +65,7 @@ bool test_socket_open (int); struct transport_implementation { int (*reader) (int, char *, int, void *); - int (*writer) (int, char *, int, void *); + int (*writer) (int, const char *, int, void *); int (*poller) (int, double, int, void *); int (*peeker) (int, char *, int, void *); const char *(*errstr) (int, void *); @@ -75,7 +75,7 @@ struct transport_implementation { void fd_register_transport (int, struct transport_implementation *, void *); void *fd_transport_context (int); int fd_read (int, char *, int, double); -int fd_write (int, char *, int, double); +int fd_write (int, const char *, int, double); int fd_peek (int, char *, int, double); const char *fd_errstr (int); void fd_close (int); diff --git a/src/gnutls.c b/src/gnutls.c index be04342..250d7fb 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -326,7 +326,7 @@ wgnutls_read (int fd, char *buf, int bufsize, void *arg) } static int -wgnutls_write (int fd _GL_UNUSED, char *buf, int bufsize, void *arg) +wgnutls_write (int fd _GL_UNUSED, const char *buf, int bufsize, void *arg) { int ret; struct wgnutls_transport_context *ctx = arg; -- 2.4.1