提交 7d165a32 编写于 作者: C chengjinsong

newcodex

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
上级 91ae408d
...@@ -261,16 +261,20 @@ void WatcherManagerKits::ParameterChangeListener::OnParameterChange(const std::s ...@@ -261,16 +261,20 @@ void WatcherManagerKits::ParameterChangeListener::OnParameterChange(const std::s
} // namespace init_param } // namespace init_param
} // namespace OHOS } // namespace OHOS
int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, void *context) static int ParameterWatcherCheck(const char *keyPrefix)
{ {
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
int ret = 0;
std::string key(keyPrefix); std::string key(keyPrefix);
if (key.rfind("*") == key.length() - 1) { if (key.rfind("*") == key.length() - 1) {
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str()); return WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else { } else {
ret = WatchParamCheck(keyPrefix); return WatchParamCheck(keyPrefix);
} }
}
int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, void *context)
{
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
int ret = ParameterWatcherCheck(keyPrefix);
if (ret != 0) { if (ret != 0) {
return ret; return ret;
} }
...@@ -286,13 +290,7 @@ int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, voi ...@@ -286,13 +290,7 @@ int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, voi
int RemoveParameterWatcher(const char *keyPrefix, ParameterChgPtr callback, void *context) int RemoveParameterWatcher(const char *keyPrefix, ParameterChgPtr callback, void *context)
{ {
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix"); WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
int ret = 0; int ret = ParameterWatcherCheck(keyPrefix);
std::string key(keyPrefix);
if (key.rfind("*") == key.length() - 1) {
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else {
ret = WatchParamCheck(keyPrefix);
}
if (ret != 0) { if (ret != 0) {
return ret; return ret;
} }
......
...@@ -75,7 +75,7 @@ static void TestHashNodeFree(const HashNode *node) ...@@ -75,7 +75,7 @@ static void TestHashNodeFree(const HashNode *node)
static TestHashNode *TestCreateHashNode(const char *value) static TestHashNode *TestCreateHashNode(const char *value)
{ {
TestHashNode *node = (TestHashNode *)malloc(sizeof(TestHashNode) + strlen(value) + 1); TestHashNode *node = reinterpret_cast<TestHashNode *>(malloc(sizeof(TestHashNode) + strlen(value) + 1));
if (node == nullptr) { if (node == nullptr) {
return nullptr; return nullptr;
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef PARAM_TEST_STUB_ #ifndef PARAM_TEST_STUB
#define PARAM_TEST_STUB_ #define PARAM_TEST_STUB
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册