From 848c7aa0b8ee852ff74b77a2283e4401f554356f Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Fri, 31 Oct 2014 11:38:57 +0200 Subject: [PATCH] Fixes to Coverity cases 72678 (retry), 72693 --- server/modules/include/readwritesplit.h | 1 + server/modules/routing/readwritesplit/readwritesplit.c | 7 ++++++- utils/skygw_utils.cc | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/modules/include/readwritesplit.h b/server/modules/include/readwritesplit.h index 46c3a2b16..62f209dc0 100644 --- a/server/modules/include/readwritesplit.h +++ b/server/modules/include/readwritesplit.h @@ -74,6 +74,7 @@ typedef enum backend_type_t { struct router_instance; typedef enum { + TARGET_UNDEFINED = 0x00, TARGET_MASTER = 0x01, TARGET_SLAVE = 0x02, TARGET_NAMED_SERVER = 0x04, diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index df849e2ea..82476d418 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -1241,7 +1241,7 @@ static route_target_t get_route_target ( target_t use_sql_variables_in, HINT* hint) { - route_target_t target; + route_target_t target = TARGET_UNDEFINED; /** * These queries are not affected by hints */ @@ -1355,6 +1355,11 @@ static route_target_t get_route_target ( } hint = hint->next; } /*< while (hint != NULL) */ + /** If nothing matches then choose the master */ + if ((target & (TARGET_ALL|TARGET_SLAVE|TARGET_MASTER)) == target) + { + target = TARGET_MASTER; + } } else { diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 24161ce26..138689c4f 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -243,6 +243,8 @@ int skygw_rwlock_init( strerror(err)); goto return_err; } + *rwlock = rwl; + return_err: return err; }