Commit 178b9275 authored by Pekka Pessi's avatar Pekka Pessi

su-glib, http, iptsec, tport, nta, nth, nua: removed sign comparison warnings.

darcs-hash:20060926193056-65a35-cf8f5793ec0faba314657ee41bacd15c4a31e8ec.gz
parent 0e1c5dd5
......@@ -570,7 +570,7 @@ int su_source_register(su_port_t *self,
if (n >= self->sup_size_waits) {
/* Reallocate size arrays */
int size;
unsigned size;
unsigned *indices;
su_wait_t *waits;
su_wakeup_f *wait_cbs;
......@@ -777,7 +777,7 @@ int su_source_deregister(su_port_t *self, int i)
I = self->sup_max_index;
indices = self->sup_indices;
assert(i < I + 1);
assert((unsigned)i < I + 1);
n = indices[i - 1];
......@@ -807,7 +807,7 @@ int su_source_deregister(su_port_t *self, int i)
indices[i - 1] = UINT_MAX;
if (i == I)
if ((unsigned)i == I)
self->sup_max_index--;
su_wait_destroy(wait);
......@@ -893,9 +893,9 @@ int su_source_eventmask(su_port_t *self, int index, int socket, int events)
assert(self);
assert(SU_SOURCE_OWN_THREAD(self));
assert(index <= self->sup_max_index);
assert(0 < index && (unsigned)index <= self->sup_max_index);
if (index <= 0 || index > self->sup_max_index)
if (index <= 0 || (unsigned)index > self->sup_max_index)
return -1;
n = self->sup_indices[index - 1];
......
......@@ -416,7 +416,7 @@ char const http_method_name_connect[] = "CONNECT";
char const *http_method_name(http_method_t method, char const *name)
{
if (method > 0 && method < sizeof(methods)/sizeof(methods[0]))
if (method > 0 && (size_t)method < sizeof(methods)/sizeof(methods[0]))
return methods[method];
else if (method == 0)
return name;
......
......@@ -152,7 +152,7 @@ int auth_struct_copy(void *dst, void const *src, isize_t s_size)
if (d_size < 0)
return -1;
if (d_size > s_size) {
if ((size_t)d_size > s_size) {
memcpy(dst, src, s_size);
memset((char *)dst + s_size, 0, d_size - s_size);
}
......
......@@ -70,7 +70,7 @@ issize_t auth_digest_challenge_get(su_home_t *home,
ac->ac_size = sizeof(ac);
assert(ac0);
assert(ac0->ac_size >= sizeof(*ac));
assert(ac0->ac_size >= (int) sizeof(*ac));
if (ac0 == NULL || params == NULL)
return -1;
......@@ -145,7 +145,7 @@ issize_t auth_digest_response_get(su_home_t *home,
ar->ar_size = sizeof(ar);
assert(ar0); assert(params); assert(ar0->ar_size >= sizeof(ar));
assert(ar0); assert(params); assert(ar0->ar_size >= (int) sizeof(ar));
if (ar0 == NULL || params == NULL)
return -1;
......
......@@ -1441,7 +1441,7 @@ int auth_validate_digest_nonce(auth_mod_t *am,
static
void auth_md5_hmac_key(auth_mod_t *am)
{
int i;
size_t i;
uint8_t ipad[SU_MD5_DIGEST_SIZE];
uint8_t opad[SU_MD5_DIGEST_SIZE];
......
......@@ -4943,7 +4943,7 @@ incoming_recv(nta_incoming_t *irq, msg_t *msg, sip_t *sip, tport_t *tport)
* Send 100 trying to non-invite if at least half of T2 has expired
* since the transaction was created.
*/
su_duration(agent_now(irq->irq_agent), irq->irq_received) * 2 >
su_duration(agent_now(irq->irq_agent), irq->irq_received) * 2U >
irq->irq_agent->sa_t2) {
SU_DEBUG_5(("nta: re-received %s request, sending 100 Trying\n",
sip->sip_request->rq_method_name));
......@@ -5683,8 +5683,8 @@ int incoming_timer(nta_agent_t *sa, su_duration_t now)
incoming_retransmit_reply(irq, irq->irq_tport);
if (2 * irq->irq_interval < sa->sa_t2)
incoming_set_timer(irq, 2 * irq->irq_interval); /* G */
if (2U * irq->irq_interval < sa->sa_t2)
incoming_set_timer(irq, 2U * irq->irq_interval); /* G */
else
incoming_set_timer(irq, sa->sa_t2); /* G */
}
......@@ -7371,9 +7371,9 @@ int outgoing_timer(nta_agent_t *sa, su_duration_t now)
outgoing_retransmit(orq);
if (2 * orq->orq_interval < sa->sa_t2 ||
orq->orq_method == sip_method_invite)
outgoing_set_timer(orq, 2 * orq->orq_interval);
if (orq->orq_method == sip_method_invite ||
2U * orq->orq_interval < sa->sa_t2)
outgoing_set_timer(orq, 2U * orq->orq_interval);
else
outgoing_set_timer(orq, sa->sa_t2);
......
......@@ -82,7 +82,7 @@ enum { HE_TIMER = 1000 };
/** @c http_flag telling that this message is internally generated. */
#define NTH_INTERNAL_MSG (1<<16)
HTABLE_DECLARE(hc_htable, hct, nth_client_t);
HTABLE_DECLARE_WITH(hc_htable, hct, nth_client_t, uintptr_t, size_t);
struct nth_engine_s {
su_home_t he_home[1];
......@@ -238,10 +238,11 @@ static void he_tp_error(nth_engine_t * he,
tport_t * tport, int errcode, char const *remote);
static int hc_recv(nth_client_t * hc, msg_t *msg, http_t * http);
HTABLE_PROTOS(hc_htable, hct, nth_client_t);
HTABLE_PROTOS_WITH(hc_htable, hct, nth_client_t, uintptr_t, size_t);
#define HTABLE_HASH_CLIENT(hc) ((hash_value_t)(uintptr_t)(hc)->hc_tport)
HTABLE_BODIES(hc_htable, hct, nth_client_t, HTABLE_HASH_CLIENT);
#define HTABLE_HASH_CLIENT(hc) ((uintptr_t)(hc)->hc_tport)
HTABLE_BODIES_WITH(hc_htable, hct, nth_client_t, HTABLE_HASH_CLIENT,
uintptr_t, size_t);
static url_string_t const *hc_request_complete(nth_client_t * hc,
msg_t *msg, http_t * http,
......@@ -307,7 +308,7 @@ nth_engine_t *nth_engine_create(su_root_t *root,
void nth_engine_destroy(nth_engine_t * he)
{
if (he) {
int i;
size_t i;
hc_htable_t *hct = he->he_clients;
for (i = 0; i < hct->hct_size; i++)
......
......@@ -377,7 +377,8 @@ void nua_dialog_log_usage(nua_owner_t *own, nua_dialog_state_t *ds)
if (SU_LOG->log_level >= 3) {
char buffer[160];
int l = 0, n, N = sizeof buffer;
size_t l = 0, N = sizeof buffer;
ssize_t n;
buffer[0] = '\0';
......@@ -390,7 +391,7 @@ void nua_dialog_log_usage(nua_owner_t *own, nua_dialog_state_t *ds)
n = sip_event_e(buffer + l, N - l, h, 0);
if (n == -1)
break;
l += n;
l += (size_t)n;
if (du->du_next && l + 2 < sizeof(buffer)) {
strcpy(buffer + l, ", ");
l += 2;
......
......@@ -84,10 +84,6 @@ typedef struct event_s event_t;
#define NONE ((void *)-1)
enum {
nua_i_none = -1 /** Event never sent to application */
};
enum nh_kind {
nh_has_nothing,
nh_has_invite,
......
......@@ -853,7 +853,8 @@ static int response_to_keepalive_options(outbound_t *ob,
}
if (binding_check <= 1 && ob->ob_registered && ob->ob_keepalive.validating) {
int failed = 0, loglevel = 3;
int failed = 0;
unsigned loglevel = 3;
if (challenged > 0 && credentials > 0) {
keepalive_options_with_registration_probe(ob);
......
......@@ -152,6 +152,10 @@ typedef enum nua_event_e {
compatibility! */
nua_i_network_changed, /**< Local IP(v6) address has changed */
/* Event used by stack internally */
nua_i_none
} nua_event_t;
typedef struct event_s {
......
......@@ -761,8 +761,8 @@ int soa_sdp_reject_is_needed(sdp_session_t const *session,
}
else {
/* Mode bits do not match */
if (((rm->m_mode & sdp_recvonly) ? sdp_sendonly : 0)
!= (sdp_mode_t)(sm->m_mode & sdp_sendonly))
if (((rm->m_mode & sdp_recvonly) == sdp_recvonly)
!= ((sm->m_mode & sdp_sendonly) == sdp_sendonly))
return 1;
}
}
......@@ -839,8 +839,8 @@ int soa_sdp_mode_set_is_needed(sdp_session_t const *session,
if (rm) {
/* Mode bits do not match */
if (((rm->m_mode & sdp_recvonly) ? sdp_sendonly : 0)
!= (sdp_mode_t)(sm->m_mode & sdp_sendonly))
if (((rm->m_mode & sdp_recvonly) == sdp_recvonly)
!= ((sm->m_mode & sdp_sendonly) == sdp_sendonly))
return 1;
}
......
......@@ -212,7 +212,7 @@ int test_params(struct context *ctx)
int af;
char const *address;
char const *hold;
unsigned rtp_select, rtp_sort;
int rtp_select, rtp_sort;
int rtp_mismatch;
int srtp_enable, srtp_confidentiality, srtp_integrity;
soa_session_t *a = ctx->a, *b = ctx->b;
......
......@@ -2670,7 +2670,7 @@ int stun_atoaddr(su_home_t *home,
host = in;
}
else {
assert(port - in < strlen(in) + 1);
assert((size_t)(port - in) < strlen(in) + 1);
memcpy(tmp, in, port - in);
tmp[port - in] = 0;
host = tmp;
......
......@@ -337,7 +337,7 @@ static int
tport_resolve(tport_t *self, msg_t *msg, tp_name_t const *tpn),
tport_send_error(tport_t *, msg_t *, tp_name_t const *),
tport_queue(tport_t *self, msg_t *msg),
tport_queue_rest(tport_t *self, msg_t *msg, msg_iovec_t iov[], ssize_t iovused),
tport_queue_rest(tport_t *self, msg_t *msg, msg_iovec_t iov[], size_t iovused),
tport_pending_error(tport_t *self, su_sockaddr_t const *dst, int error),
tport_pending_errmsg(tport_t *self, msg_t *msg, int error);
......@@ -370,7 +370,7 @@ static tport_primary_t *tport_listen(tport_master_t *mr,
tagi_t *tags);
static void tport_zap_primary(tport_primary_t *);
static char *localipname(int pf, char *buf, int bufsiz);
static char *localipname(int pf, char *buf, size_t bufsiz);
static int getprotohints(su_addrinfo_t *hints,
char const *proto, int flags);
static void tport_send_queue(tport_t *self);
......@@ -870,7 +870,8 @@ tport_t *tport_base_connect(tport_primary_t *pri,
int index = 0;
int events = SU_WAIT_IN | SU_WAIT_ERR;
int err, errlevel = 3;
int err;
unsigned errlevel = 3;
char buf[TPORT_HOSTPORTSIZE];
char const *what;
......@@ -1894,8 +1895,6 @@ int tport_addrinfo_copy(su_addrinfo_t *dst, void *addr, socklen_t addrlen,
*/
void tport_close(tport_t *self)
{
int i;
SU_DEBUG_5(("%s(%p): " TPN_FORMAT "\n", "tport_close", self,
TPN_ARGS(self->tp_name)));
......@@ -1922,7 +1921,7 @@ void tport_close(tport_t *self)
/* Zap the queued messages */
if (self->tp_queue) {
int N = self->tp_params->tpp_qsize;
unsigned short i, N = self->tp_params->tpp_qsize;
for (i = 0; i < N; i++) {
if (self->tp_queue[i])
msg_ref_destroy(self->tp_queue[i]), self->tp_queue[i] = NULL;
......@@ -1972,7 +1971,7 @@ int tport_shutdown(tport_t *self, int how)
self->tp_send_close = 2;
tport_set_events(self, 0, SU_WAIT_OUT);
if (self->tp_queue && self->tp_queue[self->tp_qhead]) {
int i, N = self->tp_params->tpp_qsize;
unsigned short i, N = self->tp_params->tpp_qsize;
for (i = 0; i < N; i++) {
if (self->tp_queue[i]) {
tport_pending_errmsg(self, self->tp_queue[i], EPIPE);
......@@ -2025,7 +2024,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
if (msg &&
tp->tp_params->tpp_timeout < INT_MAX &&
tp->tp_params->tpp_timeout < ts - (int)tp->tp_time &&
(int)tp->tp_params->tpp_timeout < ts - (int)tp->tp_time &&
!msg_is_streaming(msg)) {
SU_DEBUG_5(("tport_tick(%p): incomplete message idle for %d ms\n",
tp, ts - (int)tp->tp_time));
......@@ -2044,7 +2043,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
if (!closed &&
!(tp->tp_params->tpp_idle > 0
&& tp->tp_params->tpp_idle < ts - (int)tp->tp_time)) {
&& (int)tp->tp_params->tpp_idle < ts - (int)tp->tp_time)) {
continue;
}
......@@ -2223,7 +2222,7 @@ int getprotohints(su_addrinfo_t *hints,
* []-quoted).
*/
static
char *localipname(int pf, char *buf, int bufsiz)
char *localipname(int pf, char *buf, size_t bufsiz)
{
su_localinfo_t *li = NULL, hints[1] = {{ LI_NUMERIC | LI_CANONNAME }};
size_t n;
......@@ -2832,7 +2831,7 @@ ssize_t tport_recv_iovec(tport_t const *self,
int exact)
{
msg_t *msg = *in_out_msg;
ssize_t veclen;
ssize_t i, veclen;
int fresh;
if (N == 0)
......@@ -2880,8 +2879,9 @@ ssize_t tport_recv_iovec(tport_t const *self,
__func__, self,
msg, self->tp_protoname, self->tp_host, self->tp_port,
N, veclen));
for (N = 0; veclen > 1 && N < veclen; N++) {
SU_DEBUG_7(("\tiovec["MOD_ZU"] = %lu bytes\n", N, (LU)iovec[N].mv_len));
for (i = 0; veclen > 1 && i < veclen; i++) {
SU_DEBUG_7(("\tiovec[%lu] = %lu bytes\n", (LU)i, (LU)iovec[i].mv_len));
}
return veclen;
......@@ -3122,8 +3122,8 @@ int tport_send_msg(tport_t *self, msg_t *msg,
struct sigcomp_compartment *cc)
{
msg_iovec_t *iov, auto_iov[40];
size_t iovlen, iovused, i, total;
ssize_t n;
size_t iovlen, iovused, i, total, n;
ssize_t nerror;
int sdwn_after, close_after;
su_time_t now;
su_addrinfo_t *ai;
......@@ -3159,11 +3159,13 @@ int tport_send_msg(tport_t *self, msg_t *msg,
self->tp_time = su_time_ms(now = su_now());
n = tport_vsend(self, msg, tpn, iov, iovused, cc);
SU_DEBUG_9(("tport_vsend returned "MOD_ZD"\n", n));
nerror = tport_vsend(self, msg, tpn, iov, iovused, cc);
SU_DEBUG_9(("tport_vsend returned "MOD_ZD"\n", nerror));
if (n < 0)
return n;
if (nerror == -1)
return -1;
n = (size_t)nerror;
self->tp_unsent = NULL, self->tp_unsentlen = 0;
......@@ -3173,11 +3175,11 @@ int tport_send_msg(tport_t *self, msg_t *msg,
}
for (i = 0, total = 0; i < iovused; i++) {
if (total + iov[i].mv_len > n) {
if (total + (size_t)iov[i].mv_len > n) {
if (tport_is_connection_oriented(self)) {
iov[i].mv_len -= (su_ioveclen_t)(n - total);
iov[i].mv_base = (char *)iov[i].mv_base + (n - total);
if (tport_queue_rest(self, msg, &iov[i], (ssize_t)(iovused - i)) >= 0)
if (tport_queue_rest(self, msg, &iov[i], iovused - i) >= 0)
return n;
}
else {
......@@ -3322,7 +3324,7 @@ static
int tport_queue_rest(tport_t *self,
msg_t *msg,
msg_iovec_t iov[],
ssize_t iovused)
size_t iovused)
{
size_t iovlen = self->tp_iovlen;
......@@ -3407,13 +3409,12 @@ int tport_tqueue(tport_t *self, msg_t *msg,
}
/** Return number of queued messages. */
int tport_queuelen(tport_t const *self)
isize_t tport_queuelen(tport_t const *self)
{
int retval = 0;
isize_t retval = 0;
if (self && self->tp_queue) {
unsigned short i;
unsigned short N = self->tp_params->tpp_qsize;
unsigned short i, N = self->tp_params->tpp_qsize;
for (i = self->tp_qhead; self->tp_queue[i]; i = (i + 1) % N)
retval++;
......@@ -3466,7 +3467,7 @@ int tport_queue(tport_t *self, msg_t *msg)
int tport_tqsend(tport_t *self, msg_t *msg, msg_t *next,
tag_type_t tag, tag_value_t value, ...)
{
unsigned short qhead = self->tp_qhead;
unsigned short qhead;
ta_list ta;
int reuse, sdwn_after, close_after;
unsigned short N;
......@@ -3475,6 +3476,7 @@ int tport_tqsend(tport_t *self, msg_t *msg, msg_t *next,
if (self == NULL)
return -1;
qhead = self->tp_qhead;
N = self->tp_params->tpp_qsize;
reuse = self->tp_reusable;
sdwn_after = 0;
......@@ -3576,8 +3578,7 @@ void tport_send_queue(tport_t *self)
{
msg_t *msg;
msg_iovec_t *iov;
size_t i, iovused;
ssize_t n, total;
size_t i, iovused, n, total;
unsigned short qhead = self->tp_qhead, N = self->tp_params->tpp_qsize;
su_time_t now;
......@@ -3591,18 +3592,21 @@ void tport_send_queue(tport_t *self)
iovused = self->tp_unsentlen, self->tp_unsentlen = 0;
if (iov && iovused) {
n = tport_vsend(self, msg, self->tp_name, iov, iovused, NULL);
ssize_t e;
e = tport_vsend(self, msg, self->tp_name, iov, iovused, NULL);
if (n < 0) /* XXX */
if (e == -1) /* XXX */
return;
n = (size_t)e;
if (n > 0 && self->tp_master->mr_log && self->tp_slogged != msg) {
tport_log_msg(self, msg, "send", "to", now);
self->tp_slogged = msg;
}
for (i = 0, total = 0; i < iovused; i++) {
if (total + iov[i].mv_len > n) {
if (total + (size_t)iov[i].mv_len > n) {
iov[i].mv_len -= (su_ioveclen_t)(n - total);
iov[i].mv_base = (char *)iov[i].mv_base + (n - total);
......@@ -3841,7 +3845,7 @@ int tport_release(tport_t *self,
{
tport_pending_t *pending;
if (self == NULL || msg == NULL || pendd <= 0 || pendd > self->tp_plen)
if (self == NULL || msg == NULL || pendd <= 0 || pendd > (int)self->tp_plen)
return su_seterrno(EINVAL), -1;
pending = self->tp_pending + (pendd - 1);
......
......@@ -310,7 +310,7 @@ struct tport_vtable
char const *vtp_name;
enum tport_via vtp_public;
int vtp_pri_size; /* Size of primary tport */
size_t vtp_pri_size; /* Size of primary tport */
int (*vtp_init_primary)(tport_primary_t *pri,
tp_name_t tpn[1],
su_addrinfo_t *ai, tagi_t const *,
......@@ -320,7 +320,7 @@ struct tport_vtable
tport_t *(*vtp_connect)(tport_primary_t *pri, su_addrinfo_t *ai,
tp_name_t const *tpn);
int vtp_secondary_size; /* Size of secondary tport */
size_t vtp_secondary_size; /* Size of secondary tport */
int (*vtp_init_secondary)(tport_t *, int socket, int accepted,
char const **return_reason);
......
......@@ -275,7 +275,7 @@ int tport_plug_in_stun_server(tport_stun_server_vtable_t const *vtable)
if (!vtable)
return 0;
if (vtable->vst_size <= sizeof *vtable)
if (vtable->vst_size <= (int)sizeof *vtable)
return su_seterrno(EINVAL);
if (!vtable->vst_create ||
......
......@@ -440,10 +440,10 @@ tls_t *tls_init_client(tls_t *master, int sock)
static char *tls_strdup(char const *s)
{
if (s) {
int len = strlen(s);
char *d = malloc(len + 1);
size_t len = strlen(s) + 1;
char *d = malloc(len);
if (d)
memcpy(d, s, len + 1);
memcpy(d, s, len);
return d;
}
return NULL;
......@@ -726,7 +726,7 @@ int tls_want_write(tls_t *tls, int events)
if (tls && (events & tls->write_events)) {
int ret;
void *buf = tls->write_buffer;
int size = tls->write_buffer_len;
size_t size = tls->write_buffer_len;
tls->write_events = 0;
......
......@@ -407,8 +407,8 @@ ssize_t tport_tls_send(tport_t const *self,
tport_tls_primary_t *tlspri = (tport_tls_primary_t *)self->tp_pri;
tport_tls_t *tlstp = (tport_tls_t *)self;
enum { TLSBUFSIZE = 2048 };
size_t i, j, m, size = 0;
ssize_t n;
size_t i, j, n, m, size = 0;
ssize_t nerror;
int oldmask, mask;
if (tlstp->tlstp_context == NULL) {
......@@ -427,7 +427,7 @@ ssize_t tport_tls_send(tport_t const *self,
for (i = 0; i < iovlen; i = j) {
#if 0
n = tls_write(tlstp->tlstp_context,
nerror = tls_write(tlstp->tlstp_context,
iov[i].siv_base,
m = iov[i].siv_len);
j = i + 1;
......@@ -458,13 +458,14 @@ ssize_t tport_tls_send(tport_t const *self,
else
iov[j].siv_base = buf, iov[j].siv_len = m;
n = tls_write(tlstp->tlstp_context, buf, m);
nerror = tls_write(tlstp->tlstp_context, buf, m);
#endif
SU_DEBUG_9(("tport_tls_writevec: vec %p %p %lu ("MOD_ZD")\n",
tlstp->tlstp_context, iov[i].siv_base, (LU)iov[i].siv_len, n));
tlstp->tlstp_context, iov[i].siv_base, (LU)iov[i].siv_len,
nerror));
if (n < 0) {
if (nerror == -1) {
int err = su_errno();
if (su_is_blocking(err))
break;
......@@ -472,6 +473,7 @@ ssize_t tport_tls_send(tport_t const *self,
return -1;
}
n = (size_t)nerror;
size += n;
/* Return if the write buffer is full for now */
......
......@@ -190,7 +190,7 @@ static void tport_check_trunc(tport_t *tp, su_addrinfo_t *ai)
n = su_recvfrom(tp->tp_socket, buffer, sizeof buffer, MSG_TRUNC,
(void *)&su, &sulen);
if (n > sizeof buffer) {
if (n > (ssize_t)sizeof buffer) {
tp->tp_trunc = 1;
return;
}
......@@ -213,7 +213,7 @@ static void tport_check_trunc(tport_t *tp, su_addrinfo_t *ai)
int tport_recv_dgram(tport_t *self)
{
msg_t *msg;
int n, veclen;
ssize_t n, veclen;
su_addrinfo_t *ai;
su_sockaddr_t *from;
socklen_t fromlen;
......@@ -222,7 +222,7 @@ int tport_recv_dgram(tport_t *self)
/* Simulate packet loss */
if (self->tp_params->tpp_drop &&
su_randint(0, 1000) < self->tp_params->tpp_drop) {
(unsigned)su_randint(0, 1000) < self->tp_params->tpp_drop) {
su_recv(self->tp_socket, sample, 1, 0);
SU_DEBUG_3(("tport(%p): simulated packet loss!\n", self));
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