1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-12-21 23:28:52 -05:00

Fixed compile error with -Wshadow. Fixed const cast.

This commit is contained in:
Tatsuhiro Tsujikawa 2012-05-20 17:40:29 +09:00
parent 6f066d7f64
commit b06fa25ad2
3 changed files with 28 additions and 27 deletions

View File

@ -68,12 +68,12 @@ int spdylay_client_cert_vector_init(spdylay_client_cert_vector *certvec,
certvec->size = certvec->capacity = size; certvec->size = certvec->capacity = size;
certvec->last_slot = 0; certvec->last_slot = 0;
if(certvec->capacity) { if(certvec->capacity) {
size_t size = sizeof(spdylay_origin*)*certvec->capacity; size_t vec_size = sizeof(spdylay_origin*)*certvec->capacity;
certvec->vector = malloc(size); certvec->vector = malloc(vec_size);
if(certvec->vector == NULL) { if(certvec->vector == NULL) {
return SPDYLAY_ERR_NOMEM; return SPDYLAY_ERR_NOMEM;
} }
memset(certvec->vector, 0, size); memset(certvec->vector, 0, vec_size);
} else { } else {
certvec->vector = NULL; certvec->vector = NULL;
} }

View File

@ -195,11 +195,11 @@ int spdylay_frame_unpack_nv_check_name(uint8_t *buf, size_t buflen,
{ {
uint32_t n; uint32_t n;
size_t i; size_t i;
const uint8_t **index; const uint8_t **idx;
n = spdylay_frame_get_nv_len(in, len_size); n = spdylay_frame_get_nv_len(in, len_size);
assert(n*sizeof(char*) <= buflen); assert(n*sizeof(char*) <= buflen);
in += len_size; in += len_size;
index = (const uint8_t**)buf; idx = (const uint8_t**)buf;
for(i = 0; i < n; ++i) { for(i = 0; i < n; ++i) {
uint32_t len; uint32_t len;
size_t j; size_t j;
@ -207,7 +207,7 @@ int spdylay_frame_unpack_nv_check_name(uint8_t *buf, size_t buflen,
if(len == 0) { if(len == 0) {
return SPDYLAY_ERR_INVALID_HEADER_BLOCK; return SPDYLAY_ERR_INVALID_HEADER_BLOCK;
} }
*index++ = in; *idx++ = in;
in += len_size; in += len_size;
for(j = 0; j < len; ++j) { for(j = 0; j < len; ++j) {
unsigned char c = in[j]; unsigned char c = in[j];
@ -225,11 +225,11 @@ int spdylay_frame_unpack_nv_check_name(uint8_t *buf, size_t buflen,
len_size == 2 ? len_size == 2 ?
spdylay_length_prefix_str_compar2 : spdylay_length_prefix_str_compar2 :
spdylay_length_prefix_str_compar4); spdylay_length_prefix_str_compar4);
index = (const uint8_t**)buf; idx = (const uint8_t**)buf;
len1 = spdylay_frame_get_nv_len(*index, len_size); len1 = spdylay_frame_get_nv_len(*idx, len_size);
for(i = 1; i < n; ++i) { for(i = 1; i < n; ++i) {
len2 = spdylay_frame_get_nv_len(*(index+i), len_size); len2 = spdylay_frame_get_nv_len(*(idx+i), len_size);
if(len1 == len2 && memcmp(*(index+i-1)+len_size, *(index+i)+len_size, if(len1 == len2 && memcmp(*(idx+i-1)+len_size, *(idx+i)+len_size,
len1) == 0) { len1) == 0) {
return SPDYLAY_ERR_INVALID_HEADER_BLOCK; return SPDYLAY_ERR_INVALID_HEADER_BLOCK;
} }
@ -245,7 +245,7 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
size_t nvlen, buflen; size_t nvlen, buflen;
int r; int r;
size_t i; size_t i;
char *buf, **index, *data; char *buf, **idx, *data;
uint32_t n; uint32_t n;
int invalid_header_block = 0; int invalid_header_block = 0;
r = spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, in, inlen, len_size); r = spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, in, inlen, len_size);
@ -265,7 +265,7 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
free(buf); free(buf);
return r; return r;
} }
index = (char**)buf; idx = (char**)buf;
data = buf+(nvlen*2+1)*sizeof(char*); data = buf+(nvlen*2+1)*sizeof(char*);
n = spdylay_frame_get_nv_len(in, len_size); n = spdylay_frame_get_nv_len(in, len_size);
in += len_size; in += len_size;
@ -289,8 +289,8 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
for(stop = data+len; data != stop; ++data) { for(stop = data+len; data != stop; ++data) {
if(*data == '\0') { if(*data == '\0') {
*index++ = name; *idx++ = name;
*index++ = val; *idx++ = val;
if(val == data) { if(val == data) {
invalid_header_block = 1; invalid_header_block = 1;
} }
@ -301,11 +301,11 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
++data; ++data;
in += len; in += len;
*index++ = name; *idx++ = name;
*index++ = val; *idx++ = val;
} }
*index = NULL; *idx = NULL;
assert((size_t)((char*)index - buf) == (nvlen*2)*sizeof(char*)); assert((size_t)((char*)idx - buf) == (nvlen*2)*sizeof(char*));
*nv_ptr = (char**)buf; *nv_ptr = (char**)buf;
return invalid_header_block ? SPDYLAY_ERR_INVALID_HEADER_BLOCK : 0; return invalid_header_block ? SPDYLAY_ERR_INVALID_HEADER_BLOCK : 0;
} }
@ -406,7 +406,7 @@ char** spdylay_frame_nv_copy(const char **nv)
{ {
int i; int i;
char *buf; char *buf;
char **index, *data; char **idx, *data;
size_t buflen = 0; size_t buflen = 0;
for(i = 0; nv[i]; ++i) { for(i = 0; nv[i]; ++i) {
buflen += strlen(nv[i])+1; buflen += strlen(nv[i])+1;
@ -416,16 +416,16 @@ char** spdylay_frame_nv_copy(const char **nv)
if(buf == NULL) { if(buf == NULL) {
return NULL; return NULL;
} }
index = (char**)buf; idx = (char**)buf;
data = buf+(i+1)*sizeof(char*); data = buf+(i+1)*sizeof(char*);
for(i = 0; nv[i]; ++i) { for(i = 0; nv[i]; ++i) {
size_t len = strlen(nv[i])+1; size_t len = strlen(nv[i])+1;
memcpy(data, nv[i], len); memcpy(data, nv[i], len);
*index++ = data; *idx++ = data;
data += len; data += len;
} }
*index = NULL; *idx = NULL;
return (char**)buf; return (char**)buf;
} }
@ -465,7 +465,7 @@ char** spdylay_frame_nv_norm_copy(const char **nv)
} }
/* Table to translate SPDY/3 header names to SPDY/2. */ /* Table to translate SPDY/3 header names to SPDY/2. */
static char *spdylay_nv_3to2[] = { static const char *spdylay_nv_3to2[] = {
":host", "host", ":host", "host",
":method", "method", ":method", "method",
":path", "url", ":path", "url",
@ -481,7 +481,7 @@ void spdylay_frame_nv_3to2(char **nv)
for(i = 0; nv[i]; i += 2) { for(i = 0; nv[i]; i += 2) {
for(j = 0; spdylay_nv_3to2[j]; j += 2) { for(j = 0; spdylay_nv_3to2[j]; j += 2) {
if(strcmp(nv[i], spdylay_nv_3to2[j]) == 0) { if(strcmp(nv[i], spdylay_nv_3to2[j]) == 0) {
nv[i] = spdylay_nv_3to2[j+1]; nv[i] = (char*)spdylay_nv_3to2[j+1];
break; break;
} }
} }
@ -494,7 +494,7 @@ void spdylay_frame_nv_2to3(char **nv)
for(i = 0; nv[i]; i += 2) { for(i = 0; nv[i]; i += 2) {
for(j = 0; spdylay_nv_3to2[j]; j += 2) { for(j = 0; spdylay_nv_3to2[j]; j += 2) {
if(strcmp(nv[i], spdylay_nv_3to2[j+1]) == 0) { if(strcmp(nv[i], spdylay_nv_3to2[j+1]) == 0) {
nv[i] = spdylay_nv_3to2[j]; nv[i] = (char*)spdylay_nv_3to2[j];
break; break;
} }
} }

View File

@ -1375,11 +1375,12 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
data_frame->stream_id) != 0) { data_frame->stream_id) != 0) {
spdylay_active_outbound_item_reset(&session->aob); spdylay_active_outbound_item_reset(&session->aob);
} else { } else {
spdylay_outbound_item* item = spdylay_session_get_next_ob_item(session); spdylay_outbound_item* next_item;
next_item = spdylay_session_get_next_ob_item(session);
/* If priority of this stream is higher or equal to other stream /* If priority of this stream is higher or equal to other stream
waiting at the top of the queue, we continue to send this waiting at the top of the queue, we continue to send this
data. */ data. */
if(item == NULL || session->aob.item->pri <= item->pri) { if(next_item == NULL || session->aob.item->pri <= next_item->pri) {
size_t next_readmax; size_t next_readmax;
spdylay_stream *stream; spdylay_stream *stream;
stream = spdylay_session_get_stream(session, data_frame->stream_id); stream = spdylay_session_get_stream(session, data_frame->stream_id);