Commit 4ea171ff authored by Monty's avatar Monty

Fixed compiler warnings from gcc and clang 5.0.1

parent 9bf479b0
......@@ -158,8 +158,8 @@ int auth_server(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *auth_info)
gss_buffer_desc client_name_buf, input, output;
char *client_name_str;
const char *user= 0;
size_t userlen;
int use_full_name;
size_t userlen= 0;
int use_full_name= 0;
/* server acquires credential */
major= gss_acquire_cred(&minor, service_name, GSS_C_INDEFINITE,
......@@ -244,7 +244,7 @@ int auth_server(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *auth_info)
&& userlen < client_name_buf.length
&& client_name_str[userlen] == '@'))
{
if (strncmp(client_name_str, user, userlen) == 0)
if (user && strncmp(client_name_str, user, userlen) == 0)
{
rc= CR_OK;
}
......
......@@ -52,7 +52,6 @@
/* DB static variables. */
/***********************************************************************/
extern int num_read, num_there, num_eq[2]; // Statistics
static const longlong M2G = 0x80000000;
char BINCOL::Endian = 'H';
/***********************************************************************/
......
......@@ -1214,7 +1214,7 @@ static void fsp_free_page(fil_space_t* space, page_no_t offset, mtr_t* mtr)
/* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */
buf_block_t* header = fsp_get_header(space, mtr);
buf_block_t* xdes;
buf_block_t* xdes= 0;
descr = xdes_get_descriptor_with_space_hdr(header, space, offset,
&xdes, mtr);
......@@ -1299,7 +1299,7 @@ static void fsp_free_extent(fil_space_t* space, page_no_t offset, mtr_t* mtr)
ut_ad(mtr_memo_contains(mtr, &space->latch, MTR_MEMO_X_LOCK));
buf_block_t *block= fsp_get_header(space, mtr);
buf_block_t *xdes;
buf_block_t *xdes= 0;
xdes_t* descr= xdes_get_descriptor_with_space_hdr(block, space, offset,
&xdes, mtr);
......
......@@ -980,7 +980,7 @@ void _ma_get_bitmap_description(MARIA_FILE_BITMAP *bitmap,
if (memcmp(buff, last, count))
{
memcpy(last, buff, count);
len= sprintf(out, "%8lu: ", (ulong) page - count);
len= sprintf(out, "%8lu: ", (ulong) (page - count));
memcpy(out+len, buff, count);
out+= len + count + 1;
out[-1]= '\n';
......@@ -996,7 +996,7 @@ void _ma_get_bitmap_description(MARIA_FILE_BITMAP *bitmap,
page++;
}
}
len= sprintf(out, "%8lu: ", (ulong) page - count);
len= sprintf(out, "%8lu: ", (ulong) (page - count));
memcpy(out+len, buff, count);
out[len + count]= '\n';
out[len + count + 1]= 0;
......
......@@ -343,7 +343,7 @@ grn_com_event_add(grn_ctx *ctx, grn_com_event *ev, grn_sock fd, int events, grn_
{
grn_com *c;
/* todo : expand events */
if (!ev || *ev->hash->n_entries == ev->max_nevents) {
if (!ev || *ev->hash->n_entries == (uint32_t) ev->max_nevents) {
if (ev) { GRN_LOG(ctx, GRN_LOG_ERROR, "too many connections (%d)", ev->max_nevents); }
return GRN_INVALID_ARGUMENT;
}
......@@ -757,7 +757,7 @@ grn_com_send(grn_ctx *ctx, grn_com *cs,
rc = ctx->rc;
}
}
if (ret != whole_size) {
if ((size_t) ret != whole_size) {
GRN_LOG(ctx, GRN_LOG_ERROR,
"sendmsg(%" GRN_FMT_SOCKET "): %" GRN_FMT_LLD " < %" GRN_FMT_LLU,
cs->fd, (long long int)ret, (unsigned long long int)whole_size);
......
......@@ -51,7 +51,7 @@ grn_config_set(grn_ctx *ctx,
if (value_size == -1) {
value_size = strlen(value);
}
if (value_size > GRN_CONFIG_MAX_VALUE_SIZE) {
if (value_size > (int32_t) GRN_CONFIG_MAX_VALUE_SIZE) {
ERR(GRN_INVALID_ARGUMENT,
"[config][set] too large value: max=<%" GRN_FMT_SIZE ">: <%d>",
GRN_CONFIG_MAX_VALUE_SIZE, value_size);
......
......@@ -1299,7 +1299,7 @@ grn_table_get_subrecs(grn_ctx *ctx, grn_obj *table, grn_id id,
byte *psubrec = (byte *)ri->subrecs;
uint32_t n_subrecs = (uint32_t)GRN_RSET_N_SUBRECS(ri);
uint32_t limit = value_size / (GRN_RSET_SCORE_SIZE + subrec_size);
if (limit > buf_size) {
if ((int) limit > buf_size) {
limit = buf_size;
}
if (limit > n_subrecs) {
......@@ -1522,7 +1522,7 @@ grn_table_add(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_si
if (hooks) {
// todo : grn_proc_ctx_open()
grn_obj id_, flags_, oldvalue_, value_;
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
GRN_UINT32_INIT(&id_, 0);
GRN_UINT32_INIT(&flags_, 0);
GRN_TEXT_INIT(&oldvalue_, 0);
......@@ -1748,7 +1748,7 @@ grn_table_get_key(grn_ctx *ctx, grn_obj *table, grn_id id, void *keybuf, int buf
{
grn_array *a = (grn_array *)table;
if (a->obj.header.domain) {
if (buf_size >= a->value_size) {
if ((unsigned int) buf_size >= a->value_size) {
r = grn_array_get_value(ctx, a, id, keybuf);
} else {
r = a->value_size;
......@@ -1823,7 +1823,7 @@ call_delete_hook(grn_ctx *ctx, grn_obj *table, grn_id rid, const void *key, unsi
if (hooks) {
// todo : grn_proc_ctx_open()
grn_obj id_, flags_, oldvalue_, value_;
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
GRN_UINT32_INIT(&id_, 0);
GRN_UINT32_INIT(&flags_, 0);
GRN_TEXT_INIT(&oldvalue_, GRN_OBJ_DO_SHALLOW_COPY);
......@@ -2463,7 +2463,7 @@ grn_table_cursor_open(grn_ctx *ctx, grn_obj *table,
if (offset < 0) {
ERR(GRN_TOO_SMALL_OFFSET,
"can't use negative offset with GRN_CURSOR_PREFIX: %d", offset);
} else if (offset != 0 && offset >= table_size) {
} else if (offset != 0 && offset >= (int) table_size) {
ERR(GRN_TOO_LARGE_OFFSET,
"offset is not less than table size: offset:%d, table_size:%d",
offset, table_size);
......@@ -5234,7 +5234,7 @@ grn_vector_get_element(grn_ctx *ctx, grn_obj *vector,
ERR(GRN_INVALID_ARGUMENT, "invalid vector");
goto exit;
}
if (vector->u.v.n_sections <= offset) {
if ((unsigned int) vector->u.v.n_sections <= offset) {
ERR(GRN_RANGE_ERROR, "offset out of range");
goto exit;
}
......@@ -7140,7 +7140,7 @@ call_hook(grn_ctx *ctx, grn_obj *obj, grn_id id, grn_obj *value, int flags)
if (hooks) {
// todo : grn_proc_ctx_open()
grn_obj id_, flags_;
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
GRN_UINT32_INIT(&id_, 0);
GRN_UINT32_INIT(&flags_, 0);
GRN_UINT32_SET(ctx, &id_, id);
......@@ -7973,11 +7973,11 @@ grn_obj_get_values(grn_ctx *ctx, grn_obj *obj, grn_id offset, void **values)
grn_obj *domain = grn_column_table(ctx, obj);
if (domain) {
int table_size = (int)grn_table_size(ctx, domain);
if (0 < offset && offset <= table_size) {
if (0 < offset && offset <= (grn_id) table_size) {
grn_ra *ra = (grn_ra *)obj;
void *p = grn_ra_ref(ctx, ra, offset);
if (p) {
if ((offset >> ra->element_width) == (table_size >> ra->element_width)) {
if ((offset >> ra->element_width) == ((unsigned int) table_size >> ra->element_width)) {
nrecords = (table_size & ra->element_mask) + 1 - (offset & ra->element_mask);
} else {
nrecords = ra->element_mask + 1 - (offset & ra->element_mask);
......@@ -12578,7 +12578,7 @@ grn_column_find_index_data_column_equal(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = target;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = target;
index_data[n].section = section;
}
......@@ -12640,7 +12640,7 @@ grn_column_find_index_data_column_match(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = target;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = target;
index_data[n].section = section;
}
......@@ -12667,7 +12667,7 @@ grn_column_find_index_data_column_match(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = target;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = target;
index_data[n].section = section;
}
......@@ -12721,7 +12721,7 @@ grn_column_find_index_data_column_range(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = target;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = target;
index_data[n].section = section;
}
......@@ -12956,7 +12956,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = target;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = target;
index_data[n].section = section;
}
......@@ -12982,7 +12982,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = index;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = index;
index_data[n].section = section;
}
......@@ -13003,7 +13003,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
if (n < buf_size) {
*ip++ = index;
}
if (n < n_index_data) {
if ((unsigned int) n < n_index_data) {
index_data[n].index = index;
index_data[n].section = section;
}
......@@ -13614,7 +13614,7 @@ grn_table_sort_key_from_str(grn_ctx *ctx, const char *str, unsigned int str_size
grn_rc
grn_table_sort_key_close(grn_ctx *ctx, grn_table_sort_key *keys, unsigned int nkeys)
{
int i;
unsigned int i;
if (keys) {
for (i = 0; i < nkeys; i++) {
grn_obj *key = keys[i].key;
......@@ -14019,7 +14019,7 @@ grn_ctx_merge_temporary_open_space(grn_ctx *ctx)
GRN_API_ENTER;
stack = &(ctx->impl->temporary_open_spaces.stack);
if (GRN_BULK_VSIZE(stack) < sizeof(grn_obj) * 2) {
if ((unsigned long) GRN_BULK_VSIZE(stack) < (unsigned long) sizeof(grn_obj) * 2) {
ERR(GRN_INVALID_ARGUMENT,
"[ctx][temporary-open-spaces][merge] "
"merge requires at least two spaces");
......
......@@ -989,7 +989,7 @@ parse_normalize_flags(grn_ctx *ctx, grn_obj *flag_names)
}
#define CHECK_FLAG(name)\
if (((names_end - names) >= (sizeof(#name) - 1)) &&\
if (((unsigned long) (names_end - names) >= (unsigned long) (sizeof(#name) - 1)) && \
(!memcmp(names, #name, sizeof(#name) - 1))) {\
flags |= GRN_STRING_ ## name;\
names += sizeof(#name) - 1;\
......
......@@ -41,7 +41,7 @@ grn_proc_column_parse_flags(grn_ctx *ctx,
#define CHECK_FLAG(name) \
name_size = strlen(#name); \
if ((end - text) >= name_size && \
if ((unsigned long) (end - text) >= (unsigned long) name_size && \
memcmp(text, #name, name_size) == 0) { \
flags |= GRN_OBJ_ ## name; \
text += name_size; \
......
......@@ -495,7 +495,7 @@ dump_record(grn_ctx *ctx, grn_dumper *dumper,
}
}
GRN_TEXT_PUTC(ctx, dumper->output, ']');
if (GRN_TEXT_LEN(dumper->output) >= DUMP_FLUSH_THRESHOLD_SIZE) {
if ((size_t) GRN_TEXT_LEN(dumper->output) >= DUMP_FLUSH_THRESHOLD_SIZE) {
grn_ctx_output_flush(ctx, 0);
}
}
......
......@@ -232,7 +232,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
key_length = grn_table_get_key(ctx, domain, rid, key_name, GRN_TABLE_MAX_KEY_SIZE);
if (!prefix_match_size ||
(prefix_match_size > 0 && key_length >= prefix_match_size &&
(prefix_match_size > 0 && key_length >= (int) prefix_match_size &&
!memcmp(sx, key_name, prefix_match_size))) {
distance = calc_edit_distance(ctx, sx, ex,
key_name, key_name + key_length, flags);
......@@ -250,7 +250,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
rid = GRN_RECORD_VALUE(&value);
key_length = grn_table_get_key(ctx, domain, rid, key_name, GRN_TABLE_MAX_KEY_SIZE);
if (!prefix_match_size ||
(prefix_match_size > 0 && key_length >= prefix_match_size &&
(prefix_match_size > 0 && key_length >= (int) prefix_match_size &&
!memcmp(sx, key_name, prefix_match_size))) {
distance = calc_edit_distance(ctx, sx, ex,
key_name, key_name + key_length, flags);
......@@ -277,7 +277,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
grn_obj_unlink(ctx, &value);
for (i = 0; i < heap->n_entries; i++) {
if (max_expansion > 0 && i >= max_expansion) {
if (max_expansion > 0 && (uint32_t) i >= max_expansion) {
break;
}
{
......
......@@ -297,7 +297,7 @@ grn_parse_table_group_calc_types(grn_ctx *ctx,
}
#define CHECK_TABLE_GROUP_CALC_TYPE(name)\
if (((calc_types_end - calc_types) >= (sizeof(#name) - 1)) &&\
if (((unsigned long) (calc_types_end - calc_types) >= (unsigned long) (sizeof(#name) - 1)) && \
(!memcmp(calc_types, #name, sizeof(#name) - 1))) {\
flags |= GRN_TABLE_GROUP_CALC_ ## name;\
calc_types += sizeof(#name) - 1;\
......@@ -577,7 +577,7 @@ grn_columns_collect(grn_ctx *ctx,
while (grn_table_cursor_next(ctx, cursor)) {
void *key;
char *variable_name;
int variable_name_len;
unsigned int variable_name_len;
char *column_name;
size_t column_name_len;
void *value_raw;
......@@ -1057,7 +1057,7 @@ grn_proc_expr_query_flags_parse(grn_ctx *ctx,
}
#define CHECK_EXPR_FLAG(name) \
if (((query_flags_end - query_flags) >= (sizeof(#name) - 1)) && \
if (((unsigned long) (query_flags_end - query_flags) >= (unsigned long) (sizeof(#name) - 1)) && \
(memcmp(query_flags, #name, sizeof(#name) - 1) == 0) && \
(((query_flags_end - query_flags) == (sizeof(#name) - 1)) || \
(query_flags[sizeof(#name) - 1] == '|') || \
......
......@@ -40,7 +40,7 @@ command_table_create_parse_flags(grn_ctx *ctx,
#define CHECK_FLAG(name) \
name_size = strlen(#name); \
if ((end - nptr) >= name_size && \
if ((unsigned long) (end - nptr) >= (unsigned long) name_size && \
memcmp(nptr, #name, name_size) == 0) { \
flags |= GRN_OBJ_ ## name; \
nptr += name_size; \
......
......@@ -39,7 +39,7 @@ parse_tokenize_flags(grn_ctx *ctx, grn_obj *flag_names)
}
#define CHECK_FLAG(name)\
if (((names_end - names) >= (sizeof(#name) - 1)) &&\
if (((unsigned long) (names_end - names) >= (unsigned long) (sizeof(#name) - 1)) &&\
(!memcmp(names, #name, sizeof(#name) - 1))) {\
flags |= GRN_TOKEN_CURSOR_ ## name;\
names += sizeof(#name) - 1;\
......
......@@ -349,7 +349,7 @@ static grn_ja *
_grn_ja_create(grn_ctx *ctx, grn_ja *ja, const char *path,
unsigned int max_element_size, uint32_t flags)
{
int i;
unsigned int i;
grn_io *io;
struct grn_ja_header *header;
struct grn_ja_header_v2 *header_v2;
......@@ -689,7 +689,7 @@ grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id,
return ctx->rc;
}
if (*pseg == JA_ESEG_VOID) {
int i = 0;
unsigned int i = 0;
while (SEGMENTS_AT(ja, i)) {
if (++i >= JA_N_DSEGMENTS) {
ERR(GRN_NOT_ENOUGH_SPACE, "grn_ja file (%s) is full", ja->io->path);
......@@ -750,8 +750,9 @@ grn_ja_alloc(grn_ctx *ctx, grn_ja *ja, grn_id id,
iw->tiny_p = 0;
if (grn_io_lock(ctx, ja->io, grn_lock_timeout)) { return ctx->rc; }
if (element_size + sizeof(grn_id) > JA_SEGMENT_SIZE) {
int i, j, n = (element_size + JA_SEGMENT_SIZE - 1) >> GRN_JA_W_SEGMENT;
for (i = 0, j = -1; i < JA_N_DSEGMENTS; i++) {
uint i;
int j, n = (element_size + JA_SEGMENT_SIZE - 1) >> GRN_JA_W_SEGMENT;
for (i = 0, j = -1; i < JA_N_DSEGMENTS; i++) {
if (SEGMENTS_AT(ja, i)) {
j = i;
} else {
......
......@@ -238,7 +238,7 @@ func_string_substring(grn_ctx *ctx, int n_args, grn_obj **args,
start = p;
} else {
unsigned int char_length = 0;
size_t n_chars = 0;
int64_t n_chars = 0;
for (;
p < end && (char_length = grn_charlen(ctx, p, end));
......@@ -252,7 +252,7 @@ func_string_substring(grn_ctx *ctx, int n_args, grn_obj **args,
if (start && length > 0) {
unsigned int char_length = 0;
size_t n_chars = 0;
int64_t n_chars = 0;
for (;
p < end && (char_length = grn_charlen(ctx, p, end));
......
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