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:
parent
4779adcb50
commit
48709d9c4a
5 changed files with 10 additions and 8 deletions
2
client.c
2
client.c
|
@ -2030,7 +2030,7 @@ get_source_name(IPAddr *ip_addr, char *buf, int size)
|
|||
|
||||
/* Make sure the name is printable */
|
||||
for (i = 0; i < size && buf[i] != '\0'; i++) {
|
||||
if (!isgraph(buf[i]))
|
||||
if (!isgraph((unsigned char)buf[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ compare_total_hits(Record *x, Record *y)
|
|||
static Record *
|
||||
get_record(IPAddr *ip)
|
||||
{
|
||||
uint32_t last_hit, oldest_hit = 0;
|
||||
uint32_t last_hit = 0, oldest_hit = 0;
|
||||
Record *record, *oldest_record;
|
||||
unsigned int first, i, j;
|
||||
|
||||
|
|
|
@ -671,7 +671,7 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
|
|||
|
||||
/* Make sure the name is at least printable and has no spaces */
|
||||
for (i = 0; name[i] != '\0'; i++) {
|
||||
if (!isgraph(name[i]))
|
||||
if (!isgraph((unsigned char)name[i]))
|
||||
return NSR_InvalidName;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ process_response(NKC_Instance inst)
|
|||
inst->server_name[length] = '\0';
|
||||
|
||||
/* Make sure the name is printable and has no spaces */
|
||||
for (i = 0; i < length && isgraph(inst->server_name[i]); i++)
|
||||
for (i = 0; i < length && isgraph((unsigned char)inst->server_name[i]); i++)
|
||||
;
|
||||
if (i != length) {
|
||||
DEBUG_LOG("Invalid server name");
|
||||
|
|
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue