Fix a large number of signed - unsigned comparison warnings.
MFC after: 1 week
This commit is contained in:
parent
2bdde973dd
commit
51d6ddb5d1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=194096
@ -569,7 +569,8 @@ fill_configuration_defaults(struct configuration *config)
|
||||
void
|
||||
destroy_configuration(struct configuration *config)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
TRACE_IN(destroy_configuration);
|
||||
assert(config != NULL);
|
||||
free(config->pidfile_path);
|
||||
|
@ -140,7 +140,7 @@ on_mp_read_session_request_read2(struct query_state *qstate)
|
||||
result = qstate->read_func(qstate, c_mp_rs_request->entry,
|
||||
c_mp_rs_request->entry_length);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
LOG_ERR_3("on_mp_read_session_request_read2",
|
||||
"read failed");
|
||||
TRACE_OUT(on_mp_read_session_request_read2);
|
||||
@ -463,7 +463,7 @@ on_mp_read_session_read_response_write1(struct query_state *qstate)
|
||||
if (read_response->error_code == 0) {
|
||||
result += qstate->write_func(qstate, &read_response->data_size,
|
||||
sizeof(size_t));
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_mp_read_session_read_response_write1);
|
||||
LOG_ERR_3("on_mp_read_session_read_response_write1",
|
||||
"write failed");
|
||||
@ -473,7 +473,7 @@ on_mp_read_session_read_response_write1(struct query_state *qstate)
|
||||
qstate->kevent_watermark = read_response->data_size;
|
||||
qstate->process_func = on_mp_read_session_read_response_write2;
|
||||
} else {
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
LOG_ERR_3("on_mp_read_session_read_response_write1",
|
||||
"write failed");
|
||||
TRACE_OUT(on_mp_read_session_read_response_write1);
|
||||
@ -499,7 +499,7 @@ on_mp_read_session_read_response_write2(struct query_state *qstate)
|
||||
&qstate->response);
|
||||
result = qstate->write_func(qstate, read_response->data,
|
||||
read_response->data_size);
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
LOG_ERR_3("on_mp_read_session_read_response_write2",
|
||||
"write failed");
|
||||
TRACE_OUT(on_mp_read_session_read_response_write2);
|
||||
|
@ -145,7 +145,7 @@ on_mp_write_session_request_read2(struct query_state *qstate)
|
||||
result = qstate->read_func(qstate, c_mp_ws_request->entry,
|
||||
c_mp_ws_request->entry_length);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
LOG_ERR_3("on_mp_write_session_request_read2",
|
||||
"read failed");
|
||||
TRACE_OUT(on_mp_write_session_request_read2);
|
||||
@ -397,7 +397,7 @@ on_mp_write_session_write_request_read2(struct query_state *qstate)
|
||||
result = qstate->read_func(qstate, write_request->data,
|
||||
write_request->data_size);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result < 0 || (size_t)result != qstate->kevent_watermark) {
|
||||
LOG_ERR_3("on_mp_write_session_write_request_read2",
|
||||
"read failed");
|
||||
TRACE_OUT(on_mp_write_session_write_request_read2);
|
||||
|
@ -316,9 +316,9 @@ process_socket_event(struct kevent *event_data, struct runtime_env *env,
|
||||
* operations. It also does the actual socket IO operations.
|
||||
*/
|
||||
if (((qstate->use_alternate_io == 0) &&
|
||||
(qstate->kevent_watermark <= event_data->data)) ||
|
||||
(qstate->kevent_watermark <= (size_t)event_data->data)) ||
|
||||
((qstate->use_alternate_io != 0) &&
|
||||
(qstate->io_buffer_watermark <= event_data->data))) {
|
||||
(qstate->io_buffer_watermark <= (size_t)event_data->data))) {
|
||||
if (qstate->use_alternate_io != 0) {
|
||||
switch (qstate->io_buffer_filter) {
|
||||
case EVFILT_READ:
|
||||
@ -500,7 +500,7 @@ processing_loop(cache the_cache, struct runtime_env *env,
|
||||
struct kevent *event_data;
|
||||
event_data = &eventlist[0];
|
||||
|
||||
if (event_data->ident == env->sockfd) {
|
||||
if ((int)event_data->ident == env->sockfd) {
|
||||
for (i = 0; i < event_data->data; ++i)
|
||||
accept_connection(event_data, env, config);
|
||||
|
||||
|
@ -72,9 +72,10 @@ safe_write(struct nscd_connection_ *connection, const void *data,
|
||||
nevents = kevent(connection->write_queue, NULL, 0, &eventlist,
|
||||
1, &timeout);
|
||||
if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) {
|
||||
s_result = write(connection->sockfd, data + result,
|
||||
eventlist.data < data_size - result ?
|
||||
eventlist.data : data_size - result);
|
||||
s_result = write(connection->sockfd,
|
||||
(char *)data + result,
|
||||
(size_t)eventlist.data < data_size - result ?
|
||||
(size_t)eventlist.data : data_size - result);
|
||||
if (s_result == -1)
|
||||
return (-1);
|
||||
else
|
||||
@ -108,9 +109,10 @@ safe_read(struct nscd_connection_ *connection, void *data, size_t data_size)
|
||||
nevents = kevent(connection->read_queue, NULL, 0, &eventlist, 1,
|
||||
&timeout);
|
||||
if ((nevents == 1) && (eventlist.filter == EVFILT_READ)) {
|
||||
s_result = read(connection->sockfd, data + result,
|
||||
eventlist.data <= data_size - result ? eventlist.data :
|
||||
data_size - result);
|
||||
s_result = read(connection->sockfd,
|
||||
(char *)data + result,
|
||||
(size_t)eventlist.data <= data_size - result ?
|
||||
(size_t)eventlist.data : data_size - result);
|
||||
if (s_result == -1)
|
||||
return (-1);
|
||||
else
|
||||
|
@ -379,7 +379,7 @@ on_write_request_read2(struct query_state *qstate)
|
||||
result += qstate->read_func(qstate, write_request->data,
|
||||
write_request->data_size);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_write_request_read2);
|
||||
return (-1);
|
||||
}
|
||||
@ -643,7 +643,7 @@ on_read_request_read2(struct query_state *qstate)
|
||||
read_request->cache_key + qstate->eid_str_length,
|
||||
read_request->cache_key_size);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_read_request_read2);
|
||||
return (-1);
|
||||
}
|
||||
@ -839,7 +839,7 @@ on_read_response_write1(struct query_state *qstate)
|
||||
if (read_response->error_code == 0) {
|
||||
result += qstate->write_func(qstate, &read_response->data_size,
|
||||
sizeof(size_t));
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_read_response_write1);
|
||||
return (-1);
|
||||
}
|
||||
@ -847,7 +847,7 @@ on_read_response_write1(struct query_state *qstate)
|
||||
qstate->kevent_watermark = read_response->data_size;
|
||||
qstate->process_func = on_read_response_write2;
|
||||
} else {
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_read_response_write1);
|
||||
return (-1);
|
||||
}
|
||||
@ -871,7 +871,7 @@ on_read_response_write2(struct query_state *qstate)
|
||||
if (read_response->data_size > 0) {
|
||||
result = qstate->write_func(qstate, read_response->data,
|
||||
read_response->data_size);
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_read_response_write2);
|
||||
return (-1);
|
||||
}
|
||||
@ -957,7 +957,7 @@ on_transform_request_read2(struct query_state *qstate)
|
||||
result = qstate->read_func(qstate, transform_request->entry,
|
||||
transform_request->entry_length);
|
||||
|
||||
if (result != qstate->kevent_watermark) {
|
||||
if (result != (ssize_t)qstate->kevent_watermark) {
|
||||
TRACE_OUT(on_transform_request_read2);
|
||||
return (-1);
|
||||
}
|
||||
@ -1103,23 +1103,26 @@ check_query_eids(struct query_state *qstate)
|
||||
ssize_t
|
||||
query_io_buffer_read(struct query_state *qstate, void *buf, size_t nbytes)
|
||||
{
|
||||
size_t remaining;
|
||||
ssize_t result;
|
||||
|
||||
TRACE_IN(query_io_buffer_read);
|
||||
if ((qstate->io_buffer_size == 0) || (qstate->io_buffer == NULL))
|
||||
return (-1);
|
||||
|
||||
if (nbytes < qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p)
|
||||
assert(qstate->io_buffer_p <=
|
||||
qstate->io_buffer + qstate->io_buffer_size);
|
||||
remaining = qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p;
|
||||
if (nbytes < remaining)
|
||||
result = nbytes;
|
||||
else
|
||||
result = qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p;
|
||||
result = remaining;
|
||||
|
||||
memcpy(buf, qstate->io_buffer_p, result);
|
||||
qstate->io_buffer_p += result;
|
||||
|
||||
if (qstate->io_buffer_p == qstate->io_buffer + qstate->io_buffer_size) {
|
||||
if (remaining == 0) {
|
||||
free(qstate->io_buffer);
|
||||
qstate->io_buffer = NULL;
|
||||
|
||||
@ -1139,23 +1142,26 @@ ssize_t
|
||||
query_io_buffer_write(struct query_state *qstate, const void *buf,
|
||||
size_t nbytes)
|
||||
{
|
||||
size_t remaining;
|
||||
ssize_t result;
|
||||
|
||||
TRACE_IN(query_io_buffer_write);
|
||||
if ((qstate->io_buffer_size == 0) || (qstate->io_buffer == NULL))
|
||||
return (-1);
|
||||
|
||||
if (nbytes < qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p)
|
||||
assert(qstate->io_buffer_p <=
|
||||
qstate->io_buffer + qstate->io_buffer_size);
|
||||
remaining = qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p;
|
||||
if (nbytes < remaining)
|
||||
result = nbytes;
|
||||
else
|
||||
result = qstate->io_buffer + qstate->io_buffer_size -
|
||||
qstate->io_buffer_p;
|
||||
result = remaining;
|
||||
|
||||
memcpy(qstate->io_buffer_p, buf, result);
|
||||
qstate->io_buffer_p += result;
|
||||
|
||||
if (qstate->io_buffer_p == qstate->io_buffer + qstate->io_buffer_size) {
|
||||
if (remaining == 0) {
|
||||
qstate->use_alternate_io = 1;
|
||||
qstate->io_buffer_p = qstate->io_buffer;
|
||||
|
||||
@ -1182,7 +1188,7 @@ query_socket_read(struct query_state *qstate, void *buf, size_t nbytes)
|
||||
}
|
||||
|
||||
result = read(qstate->sockfd, buf, nbytes);
|
||||
if ((result == -1) || (result < nbytes))
|
||||
if (result < 0 || (size_t)result < nbytes)
|
||||
qstate->socket_failed = 1;
|
||||
|
||||
TRACE_OUT(query_socket_read);
|
||||
@ -1204,7 +1210,7 @@ query_socket_write(struct query_state *qstate, const void *buf, size_t nbytes)
|
||||
}
|
||||
|
||||
result = write(qstate->sockfd, buf, nbytes);
|
||||
if ((result == -1) || (result < nbytes))
|
||||
if (result < 0 || (size_t)result < nbytes)
|
||||
qstate->socket_failed = 1;
|
||||
|
||||
TRACE_OUT(query_socket_write);
|
||||
|
Loading…
Reference in New Issue
Block a user