Commit dbac2039 authored by Monty's avatar Monty

Fixed some errors & warnings found by clang

- pcretest.c could use macro with side effect
- maria_chk could access freed memory
- Initialized some variables that could be accessed uninitalized
- Fixed compiler warning in my_atomic-t.c
parent 5fa2eb6f
......@@ -2864,7 +2864,8 @@ strncmpic(pcre_uint8 *s, pcre_uint8 *t, int n)
{
while (n--)
{
int c = tolower(*s++) - tolower(*t++);
int c = tolower(*s) - tolower(*t);
s++; t++;
if (c) return c;
}
return 0;
......
......@@ -974,6 +974,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
int error,lock_type,recreate;
uint warning_printed_by_chk_status;
my_bool rep_quick= MY_TEST(param->testflag & (T_QUICK | T_FORCE_UNIQUENESS));
my_bool born_transactional;
MARIA_HA *info;
File datafile;
char llbuff[22],llbuff2[22];
......@@ -1416,6 +1417,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
maria_lock_database(info, F_UNLCK);
end2:
born_transactional= share->base.born_transactional;
if (maria_close(info))
{
_ma_check_print_error(param, default_close_errmsg, my_errno, filename);
......@@ -1431,7 +1433,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
MYF(MY_REDEL_MAKE_BACKUP) : MYF(0)));
}
if (opt_transaction_logging &&
share->base.born_transactional && !error &&
born_transactional && !error &&
(param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_ZEROFILL)))
error= write_log_record(param);
......
......@@ -683,7 +683,7 @@ static grn_rc
grn_ts_select_output(grn_ctx *ctx, grn_obj *table, grn_ts_str str,
const grn_ts_record *in, size_t n_in, size_t n_hits)
{
grn_ts_writer *writer;
grn_ts_writer *writer= 0;
grn_rc rc = grn_ts_writer_open(ctx, table, str, &writer);
if (rc != GRN_SUCCESS) {
return rc;
......
......@@ -5173,7 +5173,7 @@ grn_ts_expr_node_deref(grn_ctx *ctx, grn_ts_expr_node **node_ptr)
{
grn_ts_expr_node *node = *node_ptr, **in_ptr = NULL;
while ((node->data_kind & ~GRN_TS_VECTOR_FLAG) == GRN_TS_REF) {
grn_ts_expr_node *new_node;
grn_ts_expr_node *new_node= 0;
grn_rc rc = grn_ts_expr_node_deref_once(ctx, node, &new_node);
if (rc != GRN_SUCCESS) {
if (in_ptr) {
......
......@@ -90,10 +90,10 @@ pthread_handler_t test_atomic_cas(void *arg)
y= my_atomic_load32(&bad);
x= (x*m+0x87654321) & INT_MAX32;
do {
ok= my_atomic_cas32(&bad, &y, (uint32)y+x);
ok= my_atomic_cas32((int32*) &bad, &y, y+x);
} while (!ok) ;
do {
ok= my_atomic_cas32(&bad, &y, y-x);
ok= my_atomic_cas32((int32*) &bad, &y, y-x);
} while (!ok) ;
}
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