Commit f9863401 authored by Michael Jerris's avatar Michael Jerris

fix safe to fix msvc 2005 level 3 warnings with /w64 by changing many types of...

fix safe to fix msvc 2005 level 3 warnings with /w64 by changing many types of variables internal to fuctions, to be more strongly typed to function prototypes and returns

darcs-hash:20060910073404-16063-6395b472c0c75b26c4bdd35bef7bccb2b8e9257b.gz
parent 9611ae3d
......@@ -154,7 +154,7 @@ static issize_t cookie_scanner(char *s)
/* get value */
if (*s == '"') {
int qlen = span_quoted(s);
isize_t qlen = span_quoted(s);
if (!qlen)
return -1;
s += qlen;
......@@ -226,7 +226,7 @@ issize_t http_cookie_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
/** Calculate extra storage used by Cookie header field */
isize_t http_cookie_dup_xtra(msg_header_t const *h, isize_t offset)
{
int rv = offset;
isize_t rv = offset;
http_cookie_t const *c = (http_cookie_t *)h;
MSG_PARAMS_SIZE(rv, c->c_params);
......@@ -443,7 +443,7 @@ issize_t http_set_cookie_e(char b[], isize_t bsiz, msg_header_t const *h, int fl
/** Calculate extra storage used by Set-Cookie header field */
isize_t http_set_cookie_dup_xtra(msg_header_t const *h, isize_t offset)
{
int rv = offset;
isize_t rv = offset;
http_set_cookie_t const *sc = (http_set_cookie_t *)h;
MSG_PARAMS_SIZE(rv, sc->sc_params);
......
......@@ -84,7 +84,7 @@ issize_t http_extract_chunk(msg_t *, http_t *, char b[], isize_t bsiz, int eos);
issize_t http_extract_body(msg_t *msg, http_t *http, char b[], isize_t bsiz, int eos)
{
issize_t m = 0;
unsigned body_len;
size_t body_len;
int flags = http->http_flags;
......@@ -326,7 +326,7 @@ int http_version_d(char **ss, char const **ver)
result = http_version_0_9;
} else {
/* Version consists of one or two tokens, separated by / */
int l1 = 0, l2 = 0, n;
size_t l1 = 0, l2 = 0, n;
result = s;
......
......@@ -91,7 +91,7 @@ isize_t base64_d(char buf[], isize_t bsiz, char const *b64s)
decode[i] = B64NOP;
for (i = 0; i < 64; i++) {
decode[code[i]] = i;
decode[code[i]] = (unsigned char)i;
}
decode['='] = B64EOF;
decode['\0'] = B64EOF;
......
......@@ -720,7 +720,7 @@ int auc_digest_authorization(auth_client_t *ca,
unsigned nc = ++cda->cda_ncount;
char *uri = url_as_string(home, url);
void const *data = body ? body->pl_data : "";
int dlen = body ? body->pl_len : 0;
usize_t dlen = body ? body->pl_len : 0;
msg_header_t *h;
auth_hexmd5_t sessionkey, response;
......
......@@ -509,7 +509,7 @@ void auth_method_basic(auth_mod_t *am,
auth_challenger_t const *ach)
{
char *userpass, buffer[128];
int n, upsize;
size_t n, upsize;
char *pass;
auth_passwd_t *apw;
......
......@@ -54,7 +54,7 @@
static inline
size_t msg_params_copy_xtra(msg_param_t const pp[], size_t offset)
{
int n = msg_params_count(pp);
size_t n = msg_params_count(pp);
if (n) {
MSG_STRUCT_SIZE_ALIGN(offset);
offset += MSG_PARAMS_NUM(n + 1) * sizeof(pp[0]);
......@@ -68,7 +68,7 @@ char *msg_params_copy(char *b, size_t size,
msg_param_t **dst,
msg_param_t const src[])
{
int n = msg_params_count(src);
size_t n = msg_params_count(src);
if (n) {
MSG_STRUCT_ALIGN(b);
......
......@@ -471,7 +471,7 @@ issize_t msg_recv_buffer(msg_t *msg, void **return_buffer)
msg_payload_t *pl;
for (pl = msg->m_chunk; pl; pl = pl->pl_next) {
unsigned n = MSG_CHUNK_AVAIL(pl);
size_t n = MSG_CHUNK_AVAIL(pl);
if (n) {
*return_buffer = MSG_CHUNK_BUFFER(pl);
return n;
......@@ -554,7 +554,7 @@ isize_t msg_recv_commit(msg_t *msg, usize_t n, int eos)
msg_t *msg_next(msg_t *msg)
{
msg_t *next;
unsigned n;
usize_t n;
if (msg && msg->m_next) {
next = msg->m_next;
......@@ -1300,7 +1300,7 @@ issize_t msg_extract_payload(msg_t *msg, msg_pub_t *mo,
if (msg_get_flags(msg, MSG_FLG_CHUNKING)) {
/* Application supports chunking, use multiple chunks for payload */
unsigned current, rest;
usize_t current, rest;
current = msg->m_buffer->mb_size - msg->m_buffer->mb_used;
rest = body_len - current;
......
......@@ -194,7 +194,7 @@ size_t msgobjtag_xtra(tagi_t const *t, size_t offset)
{
msg_header_t const *h;
msg_pub_t const *mo;
int rv;
size_t rv;
assert(t);
......
......@@ -1216,7 +1216,7 @@ nea_event_t *nea_event_tcreate(nea_server_t *nes,
tag_type_t tag, tag_value_t value, ...)
{
nea_event_t *ev, **pev;
int len = strlen(name);
size_t len = strlen(name);
ta_list ta;
/* Find a matching event */
......
......@@ -1871,7 +1871,7 @@ int nta_tpn_by_url(su_home_t *home,
url_string_t const *us)
{
url_t url[1];
int n;
isize_t n;
char *b;
n = url_xtra(us->us_url);
......@@ -2264,7 +2264,7 @@ int agent_check_request_via(nta_agent_t *agent,
return -1;
if (strcasecmp(hostport, v->v_host)) {
int rlen;
size_t rlen;
/* Add the "received" field */
memcpy(received, "received=", receivedlen);
......@@ -8476,7 +8476,8 @@ int outgoing_make_srv_query(nta_outgoing_t *orq)
su_home_t *home = msg_home(orq->orq_request);
struct sipdns_query *sq;
char const *host;
int i, hlen;
int i;
size_t hlen;
sr->sr_use_srv = 0;
......@@ -8485,7 +8486,7 @@ int outgoing_make_srv_query(nta_outgoing_t *orq)
for (i = 0; sr->sr_tports[i]; i++) {
char const *prefix = sr->sr_tports[i]->prefix;
int plen = strlen(prefix);
size_t plen = strlen(prefix);
sq = su_zalloc(home, (sizeof *sq) + plen + hlen);
if (sq) {
......@@ -8598,7 +8599,8 @@ void outgoing_answer_naptr(sres_context_t *orq,
sres_query_t *q,
sres_record_t *answers[])
{
int i, j, order = -1, rlen;
int i, j, order = -1;
size_t rlen;
su_home_t *home = msg_home(orq->orq_request);
nta_agent_t *agent = orq->orq_agent;
struct sipdns_resolver *sr = orq->orq_resolver;
......@@ -8763,7 +8765,8 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
struct sipdns_resolver *sr = orq->orq_resolver;
su_home_t *home = msg_home(orq->orq_request);
struct sipdns_query *sq0, *sq, *selected = NULL, **tail = &selected, **at;
int i, tlen;
int i;
size_t tlen;
sr->sr_query = NULL;
......
......@@ -72,7 +72,7 @@ sip_payload_t *sl_read_payload(su_home_t *home, char const *fname)
sip_payload_t *sl_fread_payload(su_home_t *home, FILE *f)
{
sip_payload_t *pl;
int n;
size_t n;
char *buf;
char const *who;
size_t used, size;
......
......@@ -267,8 +267,8 @@ void sl_payload_log(su_log_t *log, int level,
log = su_log_default;
while (s < end && *s != '\0') {
int n = strncspn(s, end - s, "\r\n");
int crlf = strnspn(s + n, end - s - n, "\r\n");
size_t n = strncspn(s, end - s, "\r\n");
size_t crlf = strnspn(s + n, end - s - n, "\r\n");
if (n < 70) {
memcpy(line, s, n);
line[n] = '\0';
......
......@@ -228,7 +228,7 @@ int sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
int sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const *pl)
{
char *s = pl->pl_data, *end = pl->pl_data + pl->pl_len;
int n, crlf = 1, total = 0;
size_t n, total = 0, crlf = 1;
while (s < end && *s != '\0') {
n = strncspn(s, end - s, "\r\n");
......
......@@ -901,7 +901,7 @@ int nth_request_treply(nth_request_t *req,
if (http->http_payload && !http->http_content_length) {
http_content_length_t *l;
http_payload_t *pl;
unsigned len = 0;
usize_t len = 0;
for (pl = http->http_payload; pl; pl = pl->pl_next)
len += pl->pl_len;
......
......@@ -266,7 +266,7 @@ int outbound_set_options(outbound_t *ob,
#define MATCH(v) (len == sizeof(#v) - 1 && strncasecmp(#v, s, len) == 0)
for (s = options; s && s[0]; ) {
int len = span_token(s);
size_t len = span_token(s);
int value = 1;
if (len > 3 && strncasecmp(s, "no-", 3) == 0)
......
......@@ -431,7 +431,7 @@ sdp_media_t *sdp_media_dup_ex(su_home_t *home,
static
int origin_xtra(sdp_origin_t const *o)
{
int rv = sizeof(*o);
size_t rv = sizeof(*o);
STR_XTRA(rv, o->o_username);
PTR_XTRA(rv, o->o_address, connection_xtra);
return rv;
......@@ -456,7 +456,7 @@ sdp_origin_t *origin_dup(char **pp, sdp_origin_t const *src)
static
int connection_xtra(sdp_connection_t const *c)
{
int rv = sizeof(*c);
size_t rv = sizeof(*c);
STR_XTRA(rv, c->c_address);
return rv;
}
......@@ -479,7 +479,7 @@ sdp_connection_t *connection_dup(char **pp, sdp_connection_t const *src)
int bandwidth_xtra(sdp_bandwidth_t const *b)
{
int rv = sizeof(*b);
size_t rv = sizeof(*b);
STR_XTRA(rv, b->b_modifier_name);
return rv;
}
......@@ -503,7 +503,7 @@ sdp_bandwidth_t *bandwidth_dup(char **pp, sdp_bandwidth_t const *src)
int time_xtra(sdp_time_t const *t)
{
int rv = sizeof(*t);
size_t rv = sizeof(*t);
PTR_XTRA(rv, t->t_repeat, repeat_xtra);
PTR_XTRA(rv, t->t_zone, zone_xtra);
return rv;
......@@ -569,7 +569,7 @@ sdp_zone_t *zone_dup(char **pp, sdp_zone_t const *src)
int key_xtra(sdp_key_t const *k)
{
int rv = sizeof(*k);
size_t rv = sizeof(*k);
STR_XTRA(rv, k->k_method_name);
STR_XTRA(rv, k->k_material);
return rv;
......@@ -594,7 +594,7 @@ sdp_key_t *key_dup(char **pp, sdp_key_t const *src)
int attribute_xtra(sdp_attribute_t const *a)
{
int rv = sizeof(*a);
size_t rv = sizeof(*a);
STR_XTRA(rv, a->a_name);
STR_XTRA(rv, a->a_value);
return rv;
......@@ -620,7 +620,7 @@ sdp_attribute_t *attribute_dup(char **pp, sdp_attribute_t const *src)
int media_xtra(sdp_media_t const *m)
{
int rv = sizeof(*m);
size_t rv = sizeof(*m);
STR_XTRA(rv, m->m_type_name);
STR_XTRA(rv, m->m_proto_name);
......@@ -748,7 +748,7 @@ sdp_media_t *media_dup_ex(char **pp,
static
int media_xtra_all(sdp_media_t const *m)
{
int rv = 0;
size_t rv = 0;
for (; m; m = m->m_next) {
rv += STRUCT_ALIGN(rv);
......@@ -782,7 +782,7 @@ sdp_media_t *media_dup_all(char **pp,
int list_xtra(sdp_list_t const *l)
{
int rv = sizeof(*l);
size_t rv = sizeof(*l);
rv += strlen(l->l_text) + 1;
return rv;
}
......@@ -805,7 +805,7 @@ sdp_list_t *list_dup(char **pp, sdp_list_t const *src)
int rtpmap_xtra(sdp_rtpmap_t const *rm)
{
int rv = sizeof(*rm);
size_t rv = sizeof(*rm);
STR_XTRA(rv, rm->rm_encoding);
STR_XTRA(rv, rm->rm_params);
STR_XTRA(rv, rm->rm_fmtp);
......@@ -835,7 +835,7 @@ static
int list_xtra_all(xtra_f *xtra,
void const *v)
{
int rv = 0;
size_t rv = 0;
sdp_list_t const *l;
for (l = v; l; l = l->l_next) {
......@@ -897,7 +897,7 @@ sdp_XXX_t *XXX_dup(char **pp, sdp_XXX_t const *src)
static
int session_xtra(sdp_session_t const *sdp)
{
int rv = sizeof(*sdp);
size_t rv = sizeof(*sdp);
PTR_XTRA(rv, sdp->sdp_origin, origin_xtra);
STR_XTRA(rv, sdp->sdp_subject);
......@@ -968,7 +968,7 @@ sdp_session_t *sdp_session_dup(su_home_t *h, sdp_session_t const *sdp)
static
int session_without_media_xtra(sdp_session_t const *sdp)
{
int rv = sizeof(*sdp);
size_t rv = sizeof(*sdp);
PTR_XTRA(rv, sdp->sdp_origin, origin_xtra);
STR_XTRA(rv, sdp->sdp_subject);
......@@ -1080,7 +1080,7 @@ int sdptag_session_snprintf(tagi_t const *t, char b[], size_t size)
{
sdp_session_t const *sdp;
sdp_printer_t *print;
int retval;
size_t retval;
assert(t);
......
......@@ -705,7 +705,7 @@ static void sdp_printf(sdp_printer_t *p, const char *fmt, ...)
}
else if (p->pr_may_realloc) {
char *buffer;
int size;
size_t size;
if (p->pr_bsiz < SDP_BLOCK)
size = SDP_BLOCK;
else
......
......@@ -981,7 +981,7 @@ 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)
{
int n = strlen(h->sh_call_id->i_id);
issize_t n = strlen(h->sh_call_id->i_id);
if (bsiz > n)
strcpy(b, h->sh_call_id->i_id);
......@@ -1044,7 +1044,7 @@ char *sip_call_id_dup_one(sip_header_t *dst, sip_header_t const *src,
sip_call_id_t *sip_call_id_create(su_home_t *home, char const *domain)
{
sip_call_id_t *i;
int xtra = su_guid_strlen + 1 + (domain ? strlen(domain) + 1 : 0);
size_t xtra = su_guid_strlen + 1 + (domain ? strlen(domain) + 1 : 0);
i = sip_header_alloc(home, sip_call_id_class, xtra)->sh_call_id;
......
......@@ -504,7 +504,7 @@ int sip_complete_message(msg_t *msg)
{
sip_t *sip = sip_object(msg);
su_home_t *home = msg_home(msg);
unsigned len = 0;
usize_t len = 0;
if (sip == NULL)
return -1;
......
......@@ -336,7 +336,8 @@ int sip_contact_accept(sip_contact_t const *m,
int *return_error)
{
char const *cap, *acc;
unsigned i, S, N, eq;
unsigned i, S, N;
size_t eq;
if (!return_N) return_N = &N;
if (!return_S) return_S = &S;
......
......@@ -132,7 +132,7 @@ tagi_t *siptag_filter(tagi_t *dst,
return dst;
stub[0].t_tag = tt;
stub[0].t_value = (long)h;
stub[0].t_value = (tag_value_t)h;
src = stub; sctt = tt;
}
......
......@@ -366,7 +366,7 @@ issize_t sip_header_field_d(su_home_t *home, sip_header_t *h, char *s, isize_t s
assert(SIP_HDR_TEST(h));
if (h && s && s[slen] == '\0') {
int n = span_lws(s);
isize_t n = span_lws(s);
s += n; slen -= n;
for (n = slen - 1; n >= 0 && IS_LWS(s[n]); n--)
......
......@@ -764,7 +764,8 @@ char *stun_determine_ip_address(int family)
char *local_ip_address;
su_localinfo_t *li = NULL, hints[1] = {{ LI_CANONNAME|LI_NUMERIC }};
int error, address_size;
int error;
size_t address_size;
struct sockaddr_in *sa = NULL;
su_sockaddr_t *temp;
......
......@@ -141,7 +141,7 @@ su_md5_update(su_md5_t *ctx,
t = ctx->bits[0];
if ((ctx->bits[0] = (t + ((uint32_t)len << 3)) & 0xffffffff) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
ctx->bits[1] += (uint32_t)(len >> 29);
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
......@@ -210,7 +210,7 @@ su_md5_iupdate(su_md5_t *ctx,
t = ctx->bits[0];
if ((ctx->bits[0] = (t + ((uint32_t)len << 3)) & 0xffffffff) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
ctx->bits[1] += (uint32_t)(len >> 29);
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
......@@ -222,7 +222,7 @@ su_md5_iupdate(su_md5_t *ctx,
t = sizeof(ctx->in) - t;
if (len < t) {
mem_i_cpy(p, buf, len);
mem_i_cpy(p, buf, (uint32_t)len);
return;
}
mem_i_cpy(p, buf, t);
......@@ -240,7 +240,7 @@ su_md5_iupdate(su_md5_t *ctx,
}
/* Handle any remaining bytes of data. */
mem_i_cpy(ctx->in, buf, len);
mem_i_cpy(ctx->in, buf, (uint32_t)len);
}
/** Update MD5 context with contents of string.
......
......@@ -578,7 +578,7 @@ static inline
su_strlst_t *
su_strlst_split0(su_strlst_t *l, char *str, char const *sep)
{
int n = sep ? strlen(sep) : 0;
size_t n = sep ? strlen(sep) : 0;
char *s;
if (n > 0) {
......
......@@ -231,7 +231,7 @@ int su_vector_empty(su_vector_t *vector)
*/
int su_vector_append(su_vector_t *vector, void *item)
{
unsigned index = vector->v_len;
size_t index = vector->v_len;
if (vector && su_vector_make_place(vector, index)) {
vector->v_list[index] = item;
......
......@@ -685,9 +685,9 @@ int tport_bind_socket(int socket,
char const **return_culprit)
{
su_sockaddr_t *su = (su_sockaddr_t *)ai->ai_addr;
socklen_t sulen = ai->ai_addrlen;
socklen_t sulen = (socklen_t)(ai->ai_addrlen);
if (bind(socket, ai->ai_addr, ai->ai_addrlen) == -1) {
if (bind(socket, ai->ai_addr, sulen) == -1) {
return *return_culprit = "bind", -1;
}
......@@ -921,7 +921,7 @@ tport_t *tport_base_connect(tport_primary_t *pri,
if (tport_setname(self, tpn->tpn_proto, real_ai, tpn->tpn_canon) == -1)
TPORT_CONNECT_ERROR(su_errno(), tport_setname);
if (connect(s, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) {
if (connect(s, ai->ai_addr, (socklen_t)(ai->ai_addrlen)) == SOCKET_ERROR) {
err = su_errno();
if (err != EINPROGRESS && err != EAGAIN && err != EWOULDBLOCK)
TPORT_CONNECT_ERROR(err, connect);
......
......@@ -163,7 +163,7 @@ void tport_dump_iovec(tport_t const *self, msg_t *msg,
fputs(stamp, mr->mr_dump_file);
for (i = 0; i < iovused && n > 0; i++) {
int len = iov[i].mv_len;
size_t len = iov[i].mv_len;
if (len > n)
len = n;
fwrite(iov[i].mv_base, len, 1, mr->mr_dump_file);
......
......@@ -237,7 +237,7 @@ int tport_recv_stream(tport_t *self)
msg = self->tp_msg;
msg_set_address(msg, self->tp_addr, self->tp_addrlen);
msg_set_address(msg, self->tp_addr, (socklen_t)(self->tp_addrlen));
n = su_vrecv(self->tp_socket, iovec, veclen, 0, NULL, NULL);
if (n == SOCKET_ERROR)
......
......@@ -237,7 +237,7 @@ int tport_recv_dgram(tport_t *self)
msg = self->tp_msg;
ai = msg_addrinfo(msg);
from = (su_sockaddr_t *)ai->ai_addr, fromlen = ai->ai_addrlen;
from = (su_sockaddr_t *)ai->ai_addr, fromlen = (socklen_t)(ai->ai_addrlen);
n = su_vrecv(self->tp_socket, iovec, veclen, 0, from, &fromlen);
......
......@@ -1116,7 +1116,7 @@ issize_t url_dup(char *buf, isize_t bufsize, url_t *dst, url_t const *src)
url_t *url_hdup(su_home_t *home, url_t const *src)
{
if (src) {
int len = sizeof(*src) + url_xtra(src), actual;
isize_t len = sizeof(*src) + url_xtra(src), actual;
url_t *dst = su_alloc(home, len);
if (dst) {
actual = url_dup((char *)(dst + 1), len - sizeof(*src), dst, src);
......
......@@ -92,7 +92,7 @@ tagi_t *urltag_dup(tagi_t *dst, tagi_t const *src, void **bb)
url_dup(b + sizeof(*d), xtra, d, url);
dst->t_tag = src->t_tag;
dst->t_value = (long)d;
dst->t_value = (tag_value_t)d;
*bb = b + sizeof(*d) + xtra;
}
......
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