mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:45:07 -05:00
fix compiler warnings
Fix -Wchar-subscripts warnings on NetBSD and warnings about pointer aliasing and uninitialized values with an older compiler.
This commit is contained in:
10
socket.c
10
socket.c
@@ -884,14 +884,16 @@ process_header(struct msghdr *msg, int msg_length, int sock_fd, int flags,
|
||||
|
||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
|
||||
if (!(flags & SCK_FLAG_MSG_DESCRIPTOR) || cmsg->cmsg_len != CMSG_LEN(sizeof (int))) {
|
||||
unsigned int i;
|
||||
int i, fd;
|
||||
|
||||
DEBUG_LOG("Unexpected SCM_RIGHTS");
|
||||
for (i = 0; CMSG_LEN((i + 1) * sizeof (int)) <= cmsg->cmsg_len; i++)
|
||||
close(((int *)CMSG_DATA(cmsg))[i]);
|
||||
for (i = 0; CMSG_LEN((i + 1) * sizeof (int)) <= cmsg->cmsg_len; i++) {
|
||||
memcpy(&fd, (char *)CMSG_DATA(cmsg) + i * sizeof (int), sizeof (fd));
|
||||
close(fd);
|
||||
}
|
||||
r = 0;
|
||||
} else {
|
||||
message->descriptor = *(int *)CMSG_DATA(cmsg);
|
||||
memcpy(&message->descriptor, CMSG_DATA(cmsg), sizeof (message->descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user