#include <assert.h>
#include <errno.h>
-#include <lttng/ust-comm.h>
+#include <ust-comm.h>
/*
* Human readable error message.
*/
ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
{
- struct msghdr msg = { 0 };
+ struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
+ memset(&msg, 0, sizeof(msg));
+
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
*/
ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len)
{
- struct msghdr msg = { 0 };
+ struct msghdr msg;
struct iovec iov[1];
ssize_t ret = -1;
+ memset(&msg, 0, sizeof(msg));
+
iov[0].iov_base = buf;
iov[0].iov_len = len;
msg.msg_iov = iov;
*/
ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd, size_t len)
{
- struct msghdr msg = { 0 };
+ struct msghdr msg;
struct cmsghdr *cmptr;
struct iovec iov[1];
ssize_t ret = -1;
unsigned int sizeof_fds = nb_fd * sizeof(int);
char tmp[CMSG_SPACE(sizeof_fds)];
+ memset(&msg, 0, sizeof(msg));
+
/*
* Note: the consumerd receiver only supports receiving one FD per
* message.
return -EINVAL;
}
if (lur->ret_code != USTCOMM_OK) {
- fprintf(stderr, "remote operation failed with code %d.\n",
- lur->ret_code);
+ /*
+ * Some errors are normal.. we should put this
+ * in a debug level message...
+ * fprintf(stderr, "remote operation failed with code %d.\n",
+ * lur->ret_code);
+ */
return lur->ret_code;
}
return 0;
int data_fd;
struct cmsghdr *cmsg;
char recv_fd[CMSG_SPACE(sizeof(int))];
- struct msghdr msg = { 0 };
+ struct msghdr msg;
union {
unsigned char vc[4];
int vi;
} tmp;
int i;
+ memset(&msg, 0, sizeof(msg));
+
/* Prepare to receive the structures */
iov[0].iov_base = &data_fd;
iov[0].iov_len = sizeof(data_fd);
goto end;
}
if (ret != sizeof(data_fd)) {
- fprintf(stderr, "Received %d bytes, expected %ld", ret, sizeof(data_fd));
+ fprintf(stderr, "Received %d bytes, expected %zd", ret, sizeof(data_fd));
goto end;
}
cmsg = CMSG_FIRSTHDR(&msg);
for (i = 0; i < sizeof(int); i++)
tmp.vc[i] = CMSG_DATA(cmsg)[i];
ret = tmp.vi;
- fprintf(stderr, "received fd %d\n", ret);
+ /*
+ * Useful for fd leak debug.
+ * fprintf(stderr, "received fd %d\n", ret);
+ */
end:
return ret;
}