Commit 53b7a318 authored by Pekka Pessi's avatar Pekka Pessi

msg, sip, sdp, soa, su: removed warnings on sign comparisons.

darcs-hash:20060926170105-65a35-431042f6cdd570e3c45072366fd41f6706f733c4.gz
parent f588e38b
......@@ -69,13 +69,13 @@ msg_time_t msg_now(void)
/* ====================================================================== */
static char const days_per_months[12] =
static unsigned char const days_per_months[12] =
{
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
/** Offset of first day of the month with formula day = 30 * month + offset. */
static char const first_day_offset[12] =
static signed char const first_day_offset[12] =
{
0, 1, -1, 0, 0, 1, 1, 2, 3, 3, 4, 4
};
......
......@@ -98,8 +98,7 @@ msg_mclass_t *msg_mclass_clone(msg_mclass_t const *old, int newsize, int empty)
newsize = old->mc_hash_size;
if (newsize < old->mc_hash_used ||
newsize > USHRT_MAX / sizeof(msg_header_t *)) {
(unsigned)newsize > USHRT_MAX / sizeof(msg_header_t *)) {
errno = EINVAL;
return NULL;
}
......
......@@ -1490,7 +1490,7 @@ issize_t msg_object_e(char b[], isize_t size, msg_pub_t const *mo, int flags)
n = msg_header_e(b, size, h, flags);
if (n < 0)
return -1;
if (n < size)
if ((size_t)n < size)
b += n, size -= n;
else
b = NULL, size = 0;
......@@ -1552,7 +1552,8 @@ issize_t msg_random_token(char token[], isize_t tlen,
uint32_t random = 0, rword;
uint8_t rbyte;
uint8_t const *rmem = rmemp;
ssize_t i, n;
size_t i;
ssize_t n;
static char const token_chars[32] =
/* Create aesthetically pleasing raNDom capS LooK */
......
......@@ -62,14 +62,15 @@ const unsigned sdp_struct_align_ = sizeof(void *) - STRUCT_ALIGN_;
#define STRUCT_DUP(p, dst, src) \
ASSERT_STRUCT_ALIGN(p); assert(*(int*)(src) >= sizeof(*src)); \
((*(int*)(src) >= sizeof(*src) ? (dst = memcpy((p), (src), sizeof(*src))) : \
(dst = memcpy((p), (src), *(int*)(src))), \
ASSERT_STRUCT_ALIGN(p); assert(*(int*)(src) >= (int)sizeof(*src)); \
((*(int*)(src) >= (int)sizeof(*src) \
? (dst = memcpy((p), (src), sizeof(*src))) \
: (dst = memcpy((p), (src), *(int*)(src))), \
memset((p)+*(int*)(src), 0, sizeof(*src) - *(int*)(src))), \
((p) += sizeof(*src)))
#define STRUCT_DUP2(p, dst, src) \
ASSERT_STRUCT_ALIGN(p); assert(*(int*)(src) >= sizeof(*src)); \
ASSERT_STRUCT_ALIGN(p); assert(*(int*)(src) >= (int)sizeof(*src)); \
(dst = memcpy((p), (src), *(int*)(src)), ((p) += *(int*)(src)))
#define STR_DUP(p, dst, src, m) \
......
......@@ -697,7 +697,7 @@ static void sdp_printf(sdp_printer_t *p, const char *fmt, ...)
n = vsnprintf(p->pr_buffer + p->pr_used, p->pr_bsiz - p->pr_used, fmt, ap);
va_end(ap);
if (n > -1 && n < p->pr_bsiz - p->pr_used) {
if (n > -1 && (size_t)n < p->pr_bsiz - p->pr_used) {
p->pr_used += n;
break;
}
......
......@@ -1002,12 +1002,12 @@ issize_t sip_call_id_d(su_home_t *home,
issize_t sip_call_id_e(char b[], isize_t bsiz, sip_header_t const *h, int flags)
{
issize_t n = strlen(h->sh_call_id->i_id);
size_t n = strlen(h->sh_call_id->i_id);
if (bsiz > n)
strcpy(b, h->sh_call_id->i_id);
return n;
return (issize_t)n;
}
/** Extra size of a #sip_call_id_t object. */
......
......@@ -249,7 +249,7 @@ char const * const sip_method_names[] = {
char const *sip_method_name(sip_method_t method, char const *name)
{
const size_t N = sizeof(sip_method_names)/sizeof(sip_method_names[0]);
if (method > 0 && method <= N)
if (method > 0 && (size_t)method <= N)
return sip_method_names[method];
else if (method == 0)
return name;
......
......@@ -399,7 +399,7 @@ char *sip_header_as_string(su_home_t *home, sip_header_t *h)
len = sip_header_field_e(s, sizeof(s), h, 0);
if (len >= 0 && len < sizeof(s))
if (len >= 0 && (size_t)len < sizeof(s))
return su_strdup(home, s);
if (len == -1)
......
......@@ -90,8 +90,8 @@ static int soa_set_sdp(soa_session_t *ss,
/* ======================================================================== */
#define SOA_VALID_ACTIONS(a) \
((a)->sizeof_soa_session_actions >= sizeof (*actions) && \
(a)->sizeof_soa_session >= sizeof(soa_session_t) && \
((a)->sizeof_soa_session_actions >= (int)sizeof (*actions) && \
(a)->sizeof_soa_session >= (int)sizeof(soa_session_t) && \
(a)->soa_name != NULL && \
(a)->soa_init != NULL && \
(a)->soa_deinit != NULL && \
......@@ -415,8 +415,8 @@ int soa_base_set_params(soa_session_t *ss, tagi_t const *tags)
hold = ss->ss_hold;
media_address = ss->ss_address;
rtp_select = ss->ss_rtp_select;
rtp_sort = ss->ss_rtp_sort;
rtp_select = (int)ss->ss_rtp_select;
rtp_sort = (int)ss->ss_rtp_sort;
rtp_mismatch = ss->ss_rtp_mismatch;
srtp_enable = ss->ss_srtp_enable;
......@@ -485,9 +485,9 @@ int soa_base_set_params(soa_session_t *ss, tagi_t const *tags)
af = ss->ss_af;
if (rtp_select < SOA_RTP_SELECT_SINGLE || rtp_select > SOA_RTP_SELECT_ALL)
rtp_select = ss->ss_rtp_select;
rtp_select = (int)ss->ss_rtp_select;
if (rtp_sort < SOA_RTP_SORT_DEFAULT || rtp_sort > SOA_RTP_SORT_REMOTE)
rtp_select = ss->ss_rtp_select;
rtp_sort = (int)ss->ss_rtp_sort;
rtp_mismatch = rtp_mismatch != 0;
srtp_enable = srtp_enable != 0;
......@@ -496,8 +496,8 @@ int soa_base_set_params(soa_session_t *ss, tagi_t const *tags)
change_session
= af != ss->ss_af
|| rtp_select != ss->ss_rtp_select
|| rtp_sort != ss->ss_rtp_sort
|| rtp_select != (int)ss->ss_rtp_select
|| rtp_sort != (int)ss->ss_rtp_sort
|| rtp_mismatch != (int)ss->ss_rtp_mismatch
|| srtp_enable != (int)ss->ss_srtp_enable
|| srtp_confidentiality != (int)ss->ss_srtp_confidentiality
......@@ -591,8 +591,8 @@ int soa_base_get_params(soa_session_t const *ss, tagi_t *tags)
SOATAG_ADDRESS(ss->ss_address),
SOATAG_HOLD(ss->ss_hold),
SOATAG_RTP_SELECT(ss->ss_rtp_select),
SOATAG_RTP_SORT(ss->ss_rtp_sort),
SOATAG_RTP_SELECT((int)ss->ss_rtp_select),
SOATAG_RTP_SORT((int)ss->ss_rtp_sort),
SOATAG_RTP_MISMATCH(ss->ss_rtp_mismatch),
SOATAG_SRTP_ENABLE(ss->ss_srtp_enable),
......@@ -866,7 +866,7 @@ int soa_get_user_sdp(soa_session_t const *ss,
int soa_get_user_version(soa_session_t const *ss)
{
assert(ss != NULL);
return ss ? ss->ss_user_version : -1;
return ss ? (int)ss->ss_user_version : -1;
}
int soa_set_user_sdp(soa_session_t *ss,
......
......@@ -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 : (unsigned)0)
!= (sm->m_mode & sdp_sendonly))
if (((rm->m_mode & sdp_recvonly) ? sdp_sendonly : 0)
!= (sdp_mode_t)(sm->m_mode & 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 : (unsigned)0)
!= (sm->m_mode & sdp_sendonly))
if (((rm->m_mode & sdp_recvonly) ? sdp_sendonly : 0)
!= (sdp_mode_t)(sm->m_mode & sdp_sendonly))
return 1;
}
......
......@@ -434,7 +434,7 @@ void sres_cache_clean(sres_cache_t *cache, time_t now)
sres_rr_hash_entry_t *e;
while ((e = cache->cache_hash->ht_table[i]) != NULL) {
if (now - e->rr_received <= e->rr->sr_ttl)
if ((uint32_t)(now - e->rr_received) <= e->rr->sr_ttl)
break;
sres_htable_remove(cache->cache_hash, e);
......
......@@ -1116,7 +1116,7 @@ int stun_discovery_get_address(stun_discovery_t *sd,
void *addr,
socklen_t *return_addrlen)
{
int siz;
socklen_t siz;
enter;
......
......@@ -396,7 +396,7 @@ void *sub_alloc(su_home_t *home,
{
void *data, *preload = NULL;
assert (size < (1L << SIZEBITS));
assert (size < (1UL << SIZEBITS));
if (sub == NULL || 3 * sub->sub_used > 2 * sub->sub_n) {
/* Resize the hash table */
......
......@@ -1170,14 +1170,15 @@ int su_port_wait_events(su_port_t *self, su_duration_t tout)
#if HAVE_POLL
/* poll() can return events for multiple wait objects */
if (self->sup_multishot) {
for (; i < n; i++) {
if (waits[i].revents) {
root = self->sup_wait_roots[i];
self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
&waits[i],
self->sup_wait_args[i]);
unsigned j;
for (j = (unsigned)i; j < n; i++) {
if (waits[j].revents) {
root = self->sup_wait_roots[j];
self->sup_wait_cbs[j](root ? su_root_magic(root) : NULL,
&waits[j],
self->sup_wait_args[j]);
events++;
/* Callback function used su_register()/su_unregister() */
/* Callback function used su_register()/su_deregister() */
if (version != self->sup_registers)
break;
}
......
......@@ -76,10 +76,10 @@ char *su_vsprintf(su_home_t *home, char const *fmt, va_list ap)
n = vsnprintf(s, sizeof(s), fmt, aq);
va_end(aq);
if (n >= 0 && n + 1 < sizeof(s))
if (n >= 0 && (size_t)n + 1 < sizeof(s))
return su_strdup(home, s);
len = n > 0 ? n + 1 : 2 * sizeof(s);
len = n > 0 ? (size_t)n + 1 : 2 * sizeof(s);
for (rv = su_alloc(home, len);
rv;
......@@ -87,10 +87,10 @@ char *su_vsprintf(su_home_t *home, char const *fmt, va_list ap)
va_copy(aq, ap);
n = vsnprintf(rv, len, fmt, aq);
va_end(aq);
if (n > -1 && n < len)
if (n > -1 && (size_t)n < len)
break;
if (n > -1) /* glibc >2.1 */
len = n + 1;
len = (size_t)n + 1;
else /* glibc 2.0 */
len *= 2;
......
......@@ -58,7 +58,7 @@ void tl_print(FILE *f, char const *title, tagi_t const lst[])
n = t_snprintf(lst, buffer, sizeof(buffer));
if (n + 1 < sizeof(buffer)) {
if (n + 1 < (int)sizeof(buffer)) {
if (n > 0 && buffer[n - 1] == '\n')
fmt = " %s";
}
......
......@@ -139,7 +139,7 @@ int t_snprintf(tagi_t const *t, char b[], size_t size)
if (n < 0)
return n;
if (n > size)
if ((size_t)n > size)
size = n;
if (tt->tt_snprintf)
......@@ -150,7 +150,7 @@ int t_snprintf(tagi_t const *t, char b[], size_t size)
if (m < 0)
return m;
if (m == 0 && n < size)
if (m == 0 && (size_t)n < size)
b[--n] = '\0';
return n + m;
......@@ -195,7 +195,7 @@ size_t tl_tmove(tagi_t *dst, size_t size,
tagi->t_tag = t_tag, tagi->t_value = t_value;
for (;;) {
assert((char *)&dst[n] - (char *)dst < size);
assert((size_t)((char *)&dst[n] - (char *)dst) < size);
if (n < N)
dst[n] = *tagi;
n++;
......
......@@ -186,7 +186,7 @@ static void init(void)
static
void init_node(void)
{
int i;
size_t i;
#if HAVE_GETIFADDRS && HAVE_SOCKADDR_LL
struct ifaddrs *ifa, *results;
......
......@@ -218,22 +218,23 @@ int su_wait(su_wait_t waits[], unsigned n, su_duration_t timeout)
#elif SU_HAVE_POLL
for (;;) {
unsigned j;
int i = poll(waits, n, timeout);
if (i == 0)
return SU_WAIT_TIMEOUT;
if (i > 0) {
for (i = 0; i < n; i++) {
if (waits[i].revents)
return i;
for (j = 0; j < n; i++) {
if (waits[j].revents)
return (int)j;
}
}
if (errno == EINTR)
continue;
return i;
return -1;
}
#endif
}
......
......@@ -3576,8 +3576,8 @@ void tport_send_queue(tport_t *self)
{
msg_t *msg;
msg_iovec_t *iov;
size_t i, total, iovused;
ssize_t n;
size_t i, iovused;
ssize_t n, total;
unsigned short qhead = self->tp_qhead, N = self->tp_params->tpp_qsize;
su_time_t now;
......
......@@ -83,7 +83,7 @@
|| u >= '\177' \
|| (u < 64 ? (m32 & (1 << (63 - u))) \
: (u < 96 ? (m64 & (1 << (95 - u))) \
: /*u < 128*/ (m96 & (1 << (127 - u))))))
: /*u < 128*/ (m96 & (1 << (127 - u))))) != 0)
#define MASKS_WITH_RESERVED(reserved, m32, m64, m96) \
if (reserved == NULL) { \
......@@ -1785,27 +1785,28 @@ int url_sanitize(url_t *url)
static
void canon_update(su_md5_t *md5, char const *s, size_t n, char const *allow)
{
char const *s0 = s, *b = s;
size_t i, j;
for (;*s && s - s0 < n; s++) {
for (i = 0, j = 0; i < n && s[i]; i++) {
char c;
if (*s == '%' && IS_HEX(s[1]) && IS_HEX(s[2]) && s - s0 + 2 < n) {
if (s[i] == '%' && i + 2 < n && IS_HEX(s[i+1]) && IS_HEX(s[i+2])) {
#define UNHEX(a) (a - (a >= 'a' ? 'a' - 10 : (a >= 'A' ? 'A' - 10 : '0')))
c = (UNHEX(s[1]) << 4) | UNHEX(s[2]);
c = (UNHEX(s[i+1]) << 4) | UNHEX(s[i+2]);
#undef UNHEX
if (c != '%' && c > ' ' && c < '\177' &&
(!strchr(EXCLUDED, c) || strchr(allow, c))) {
if (b != s)
su_md5_iupdate(md5, b, s - b);
if (i != j)
su_md5_iupdate(md5, s + j, i - j);
su_md5_iupdate(md5, &c, 1);
b = s + 3;
j = i + 3;
}
s += 2;
i += 2;
}
}
if (b != s)
su_md5_iupdate(md5, b, s - b);
if (i != j)
su_md5_iupdate(md5, s + j, i - j);
}
/** Update MD5 sum with url-string contents */
......
......@@ -102,9 +102,9 @@ tagi_t *urltag_dup(tagi_t *dst, tagi_t const *src, void **bb)
#define IS_EXCLUDED(u) \
(u <= ' ' \
|| u >= '\177' \
|| (u < 64 ? (0xb400000a & (1 << (63 - u))) \
: (u < 96 ? (0x0000001e & (1 << (95 - u))) \
: /*u < 128*/ (0x8000001d & (1 << (127 - u))))))
|| (u < 64 ? (0xb400000aU & (1 << (63 - u))) \
: (u < 96 ? (0x0000001eU & (1 << (95 - u))) \
: /*u < 128*/ (0x8000001dU & (1 << (127 - u))))) != 0)
/** Tag function used to convert a string to a URL tag value.
*
......
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