From c2d6932774987366baf42a93461cd73c38f1113a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 26 Jan 2016 11:46:48 -0500 Subject: [PATCH] Enforce const-correctness in UNIX socket wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/common/sessiond-comm/inet.c | 4 ++-- src/common/sessiond-comm/inet.h | 4 ++-- src/common/sessiond-comm/inet6.c | 4 ++-- src/common/sessiond-comm/inet6.h | 4 ++-- src/common/sessiond-comm/sessiond-comm.h | 4 ++-- src/common/sessiond-comm/unix.c | 4 ++-- src/common/sessiond-comm/unix.h | 2 +- src/lib/lttng-ctl/lttng-ctl-helper.h | 4 ++-- src/lib/lttng-ctl/lttng-ctl.c | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index 35ce3b6b5..b870deef4 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -407,7 +407,7 @@ ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, * Return the size of sent data. */ LTTNG_HIDDEN -ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf, +ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags) { struct msghdr msg; @@ -416,7 +416,7 @@ ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf, memset(&msg, 0, sizeof(msg)); - iov[0].iov_base = buf; + iov[0].iov_base = (void *) buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; diff --git a/src/common/sessiond-comm/inet.h b/src/common/sessiond-comm/inet.h index 6a79c9106..03549fabd 100644 --- a/src/common/sessiond-comm/inet.h +++ b/src/common/sessiond-comm/inet.h @@ -57,8 +57,8 @@ extern int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog); extern ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags); -extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf, - size_t len, int flags); +extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, + const void *buf, size_t len, int flags); /* Initialize inet communication layer. */ extern void lttcomm_inet_init(void); diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index a29adad42..51d02ebb9 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -386,7 +386,7 @@ ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, * Return the size of sent data. */ LTTNG_HIDDEN -ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, +ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags) { struct msghdr msg; @@ -395,7 +395,7 @@ ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, memset(&msg, 0, sizeof(msg)); - iov[0].iov_base = buf; + iov[0].iov_base = (void *) buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; diff --git a/src/common/sessiond-comm/inet6.h b/src/common/sessiond-comm/inet6.h index 3af3be5be..5c2ed5371 100644 --- a/src/common/sessiond-comm/inet6.h +++ b/src/common/sessiond-comm/inet6.h @@ -38,7 +38,7 @@ extern int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog); extern ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags); -extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, - size_t len, int flags); +extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, + const void *buf, size_t len, int flags); #endif /* _LTTCOMM_INET6_H */ diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 4a204c02e..ec7d36ae5 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -218,8 +218,8 @@ struct lttcomm_proto_ops { int (*listen) (struct lttcomm_sock *sock, int backlog); ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len, int flags); - ssize_t (*sendmsg) (struct lttcomm_sock *sock, void *buf, size_t len, - int flags); + ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf, + size_t len, int flags); }; /* diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c index 5e0ba6281..8d2e03a5b 100644 --- a/src/common/sessiond-comm/unix.c +++ b/src/common/sessiond-comm/unix.c @@ -205,7 +205,7 @@ ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len) * Return the size of sent data. */ LTTNG_HIDDEN -ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len) +ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len) { struct msghdr msg; struct iovec iov[1]; @@ -213,7 +213,7 @@ ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len) memset(&msg, 0, sizeof(msg)); - iov[0].iov_base = buf; + iov[0].iov_base = (void *) buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; diff --git a/src/common/sessiond-comm/unix.h b/src/common/sessiond-comm/unix.h index 7ea05032f..24786b8fe 100644 --- a/src/common/sessiond-comm/unix.h +++ b/src/common/sessiond-comm/unix.h @@ -49,7 +49,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd); LTTNG_HIDDEN ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len); LTTNG_HIDDEN -ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len); +ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len); LTTNG_HIDDEN ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len); diff --git a/src/lib/lttng-ctl/lttng-ctl-helper.h b/src/lib/lttng-ctl/lttng-ctl-helper.h index 5f6d5c209..b7a28268c 100644 --- a/src/lib/lttng-ctl/lttng-ctl-helper.h +++ b/src/lib/lttng-ctl/lttng-ctl-helper.h @@ -35,14 +35,14 @@ void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src); /* - * Sends the lttcomm message to the session daemon and fills buf of the + * Sends the lttcomm message to the session daemon and fills buf if the * returned data is not NULL. * * Return the size of the received data on success or else a negative lttng * error code. If buf is NULL, 0 is returned on success. */ int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm, - void *vardata, size_t varlen, void **buf); + const void *vardata, size_t varlen, void **buf); /* * Use this if no variable length data needs to be sent. diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 03b74c0b7..14bb7b32d 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -150,7 +150,7 @@ end: * On success, returns the number of bytes sent (>=0) * On error, returns -1 */ -static int send_session_varlen(void *data, size_t len) +static int send_session_varlen(const void *data, size_t len) { int ret; @@ -400,7 +400,7 @@ static int disconnect_sessiond(void) */ LTTNG_HIDDEN int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm, - void *vardata, size_t varlen, void **buf) + const void *vardata, size_t varlen, void **buf) { int ret; size_t size; -- 2.34.1