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