Commit 0e391e57 by Daniel Lezcano

fix compilation warnings

Fix the following warnings: console.c: In function ‘console_handler’: console.c:252: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result console.c:254: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result conf.c: In function ‘instanciate_veth’: conf.c:1130: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result conf.c:1135: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result conf.c: In function ‘instanciate_macvlan’: conf.c:1206: warning: ignoring return value of ‘mktemp’, declared with attribute warn_unused_result af_unix.c: In function ‘lxc_af_unix_send_fd’: af_unix.c:124: warning: dereferencing type-punned pointer will break strict-aliasing rules af_unix.c: In function ‘lxc_af_unix_recv_fd’: af_unix.c:169: warning: dereferencing type-punned pointer will break strict-aliasing rules af_unix.c: In function ‘lxc_af_unix_send_credential’: af_unix.c:195: warning: dereferencing type-punned pointer will break strict-aliasing rules af_unix.c: In function ‘lxc_af_unix_rcv_credential’: af_unix.c:237: warning: dereferencing type-punned pointer will break strict-aliasing rules Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 196f1d54
......@@ -113,6 +113,7 @@ int lxc_af_unix_send_fd(int fd, int sendfd, void *data, size_t size)
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
char buf[1];
int *val;
msg.msg_control = cmsgbuf;
msg.msg_controllen = sizeof(cmsgbuf);
......@@ -121,7 +122,8 @@ int lxc_af_unix_send_fd(int fd, int sendfd, void *data, size_t size)
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
*((int *) CMSG_DATA(cmsg)) = sendfd;
val = (int *)(CMSG_DATA(cmsg));
*val = sendfd;
msg.msg_name = NULL;
msg.msg_namelen = 0;
......@@ -141,7 +143,7 @@ int lxc_af_unix_recv_fd(int fd, int *recvfd, void *data, size_t size)
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
char buf[1];
int ret;
int ret, *val;
msg.msg_name = NULL;
msg.msg_namelen = 0;
......@@ -166,7 +168,8 @@ int lxc_af_unix_recv_fd(int fd, int *recvfd, void *data, size_t size)
if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SCM_RIGHTS) {
*recvfd = *((int *) CMSG_DATA(cmsg));
val = (int *) CMSG_DATA(cmsg);
*recvfd = *val;
}
out:
return ret;
......@@ -192,7 +195,7 @@ int lxc_af_unix_send_credential(int fd, void *data, size_t size)
cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_CREDENTIALS;
*((struct ucred *) CMSG_DATA(cmsg)) = cred;
memcpy(CMSG_DATA(cmsg), &cred, sizeof(cred));
msg.msg_name = NULL;
msg.msg_namelen = 0;
......@@ -234,7 +237,7 @@ int lxc_af_unix_rcv_credential(int fd, void *data, size_t size)
if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)) &&
cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SCM_CREDENTIALS) {
cred = *((struct ucred *) CMSG_DATA(cmsg));
memcpy(&cred, CMSG_DATA(cmsg), sizeof(cred));
if (cred.uid && (cred.uid != getuid() || cred.gid != getgid())) {
INFO("message denied for '%d/%d'", cred.uid, cred.gid);
return -EACCES;
......
......@@ -1120,19 +1120,18 @@ struct lxc_conf *lxc_conf_init(void)
static int instanciate_veth(struct lxc_netdev *netdev)
{
char veth1buf[IFNAMSIZ], *veth1;
char veth2[IFNAMSIZ];
char veth2buf[IFNAMSIZ], *veth2;
int err;
if (netdev->priv.veth_attr.pair)
veth1 = netdev->priv.veth_attr.pair;
else {
snprintf(veth1buf, sizeof(veth1buf), "vethXXXXXX");
mktemp(veth1buf);
veth1 = veth1buf;
veth1 = mktemp(veth1buf);
}
snprintf(veth2, sizeof(veth2), "vethXXXXXX");
mktemp(veth2);
snprintf(veth2buf, sizeof(veth2buf), "vethXXXXXX");
veth2 = mktemp(veth2buf);
if (!strlen(veth1) || !strlen(veth2)) {
ERROR("failed to allocate a temporary name");
......@@ -1193,7 +1192,7 @@ out_delete:
static int instanciate_macvlan(struct lxc_netdev *netdev)
{
char peer[IFNAMSIZ];
char peerbuf[IFNAMSIZ], *peer;
int err;
if (!netdev->link) {
......@@ -1201,10 +1200,9 @@ static int instanciate_macvlan(struct lxc_netdev *netdev)
return -1;
}
snprintf(peer, sizeof(peer), "mcXXXXXX");
mktemp(peer);
snprintf(peerbuf, sizeof(peerbuf), "mcXXXXXX");
peer = mktemp(peerbuf);
if (!strlen(peer)) {
ERROR("failed to make a temporary name");
return -1;
......
......@@ -249,9 +249,9 @@ static int console_handler(int fd, void *data, struct lxc_epoll_descr *descr)
return 0;
if (console->peer == fd)
write(console->master, buf, r);
r = write(console->master, buf, r);
else
write(console->peer, buf, r);
r = write(console->peer, buf, r);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment